recaptcha host instead of alternative
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
parent
d60c600967
commit
a9851d8e74
@ -22,30 +22,32 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
addr string
|
addr string
|
||||||
config string
|
config string
|
||||||
database string
|
database string
|
||||||
scope string
|
scope string
|
||||||
commands string
|
commands string
|
||||||
logfile string
|
logfile string
|
||||||
staticg string
|
staticg string
|
||||||
locale string
|
locale string
|
||||||
baseurl string
|
baseurl string
|
||||||
prefixurl string
|
prefixurl string
|
||||||
viewMode string
|
viewMode string
|
||||||
recaptchakey string
|
port int
|
||||||
recaptchasecret string
|
recaptcha struct {
|
||||||
port int
|
host string
|
||||||
auth struct {
|
key string
|
||||||
|
secret string
|
||||||
|
}
|
||||||
|
auth struct {
|
||||||
method string
|
method string
|
||||||
header string
|
header string
|
||||||
}
|
}
|
||||||
allowCommands bool
|
allowCommands bool
|
||||||
allowEdit bool
|
allowEdit bool
|
||||||
allowNew bool
|
allowNew bool
|
||||||
allowPublish bool
|
allowPublish bool
|
||||||
showVer bool
|
showVer bool
|
||||||
alterRecaptcha bool
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -70,9 +72,9 @@ func init() {
|
|||||||
flag.StringVar(&locale, "defaults.locale", "", "Default locale for new users, set it empty to enable auto detect from browser")
|
flag.StringVar(&locale, "defaults.locale", "", "Default locale for new users, set it empty to enable auto detect from browser")
|
||||||
|
|
||||||
// Recaptcha settings
|
// Recaptcha settings
|
||||||
flag.BoolVar(&alterRecaptcha, "recaptcha.alternative", false, "Use recaptcha.net for serving and handling, useful in China")
|
flag.StringVar(&recaptcha.host, "recaptcha.host", "https://www.google.com", "Use another host for ReCAPTCHA. recaptcha.net might be useful in China")
|
||||||
flag.StringVar(&recaptchakey, "recaptcha.key", "", "ReCaptcha site key")
|
flag.StringVar(&recaptcha.key, "recaptcha.key", "", "ReCaptcha site key")
|
||||||
flag.StringVar(&recaptchasecret, "recaptcha.secret", "", "ReCaptcha secret")
|
flag.StringVar(&recaptcha.secret, "recaptcha.secret", "", "ReCaptcha secret")
|
||||||
|
|
||||||
// Auth settings
|
// Auth settings
|
||||||
flag.StringVar(&auth.method, "auth.method", "default", "Switch between 'none', 'default' and 'proxy' authentication")
|
flag.StringVar(&auth.method, "auth.method", "default", "Switch between 'none', 'default' and 'proxy' authentication")
|
||||||
@ -116,11 +118,11 @@ func setupViper() {
|
|||||||
viper.BindPFlag("Defaults.Locale", flag.Lookup("defaults.locale"))
|
viper.BindPFlag("Defaults.Locale", flag.Lookup("defaults.locale"))
|
||||||
|
|
||||||
// Recaptcha settings
|
// Recaptcha settings
|
||||||
viper.SetDefault("Recaptcha.Alternative", false)
|
viper.SetDefault("Recaptcha.Host", "https://www.google.com")
|
||||||
viper.SetDefault("Recaptcha.Key", "")
|
viper.SetDefault("Recaptcha.Key", "")
|
||||||
viper.SetDefault("Recaptcha.Secret", "")
|
viper.SetDefault("Recaptcha.Secret", "")
|
||||||
|
|
||||||
viper.BindPFlag("Recaptcha.Alternative", flag.Lookup("recaptcha.alternative"))
|
viper.BindPFlag("Recaptcha.Host", flag.Lookup("recaptcha.host"))
|
||||||
viper.BindPFlag("Recaptcha.Key", flag.Lookup("recaptcha.key"))
|
viper.BindPFlag("Recaptcha.Key", flag.Lookup("recaptcha.key"))
|
||||||
viper.BindPFlag("Recaptcha.Secret", flag.Lookup("recaptcha.secret"))
|
viper.BindPFlag("Recaptcha.Secret", flag.Lookup("recaptcha.secret"))
|
||||||
|
|
||||||
@ -221,18 +223,13 @@ func handler() http.Handler {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
recaptchaHost := "https://www.google.com"
|
|
||||||
if viper.GetBool("Recaptcha.Alternative") {
|
|
||||||
recaptchaHost = "https://recaptcha.net"
|
|
||||||
}
|
|
||||||
|
|
||||||
fm := &filebrowser.FileBrowser{
|
fm := &filebrowser.FileBrowser{
|
||||||
Auth: &filebrowser.Auth{
|
Auth: &filebrowser.Auth{
|
||||||
Method: viper.GetString("Auth.Method"),
|
Method: viper.GetString("Auth.Method"),
|
||||||
Header: viper.GetString("Auth.Header"),
|
Header: viper.GetString("Auth.Header"),
|
||||||
},
|
},
|
||||||
ReCaptcha: &filebrowser.ReCaptcha{
|
ReCaptcha: &filebrowser.ReCaptcha{
|
||||||
Host: recaptchaHost,
|
Host: viper.GetString("Recaptcha.Host"),
|
||||||
Key: viper.GetString("Recaptcha.Key"),
|
Key: viper.GetString("Recaptcha.Key"),
|
||||||
Secret: viper.GetString("Recaptcha.Secret"),
|
Secret: viper.GetString("Recaptcha.Secret"),
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user