mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2025-11-08 15:15:05 +01:00
🍱 fix lint
This commit is contained in:
18
bouncer.go
18
bouncer.go
@@ -233,16 +233,6 @@ func New(_ context.Context, next http.Handler, config *configuration.Config, nam
|
||||
config.CaptchaSiteKey, _ = configuration.GetVariable(config, "CaptchaSiteKey")
|
||||
config.CaptchaSecretKey, _ = configuration.GetVariable(config, "CaptchaSecretKey")
|
||||
|
||||
var infoProvider *captcha.InfoProvider
|
||||
if config.CaptchaProvider == configuration.CustomProvider {
|
||||
infoProvider = &captcha.InfoProvider{
|
||||
js: config.CaptchaCustomJsURL,
|
||||
key: config.CaptchaCustomKey,
|
||||
response: config.CaptchaCustomResponse,
|
||||
validate: config.CaptchaCustomValidateURL,
|
||||
}
|
||||
}
|
||||
|
||||
err = bouncer.captchaClient.New(
|
||||
log,
|
||||
bouncer.cacheClient,
|
||||
@@ -250,7 +240,13 @@ func New(_ context.Context, next http.Handler, config *configuration.Config, nam
|
||||
Transport: &http.Transport{MaxIdleConns: 10, IdleConnTimeout: 30 * time.Second},
|
||||
Timeout: time.Duration(config.HTTPTimeoutSeconds) * time.Second,
|
||||
},
|
||||
infoProvider,
|
||||
captcha.GetInfoProvider(
|
||||
config.CaptchaProvider,
|
||||
config.CaptchaCustomJsURL,
|
||||
config.CaptchaCustomKey,
|
||||
config.CaptchaCustomResponse,
|
||||
config.CaptchaCustomValidateURL,
|
||||
),
|
||||
config.CaptchaProvider,
|
||||
config.CaptchaSiteKey,
|
||||
config.CaptchaSecretKey,
|
||||
|
||||
@@ -294,12 +294,7 @@
|
||||
<h1 class="text-2xl lg:text-3xl xl:text-4xl">CrowdSec Captcha</h1>
|
||||
</div>
|
||||
<form action="" method="POST" class="flex flex-col items-center space-y-1" id="captcha-form">
|
||||
<div
|
||||
id="captcha"
|
||||
class="{{ .FrontendKey }}"
|
||||
data-sitekey="{{ .SiteKey }}"
|
||||
data-callback="captchaCallback"
|
||||
>
|
||||
<div id="captcha" class="{{ .FrontendKey }}" data-sitekey="{{ .SiteKey }}" data-callback="captchaCallback">
|
||||
</div>
|
||||
</form>
|
||||
<div class="flex justify-center flex-wrap">
|
||||
|
||||
@@ -58,16 +58,24 @@ var infoProviders = map[string]*InfoProvider{
|
||||
},
|
||||
}
|
||||
|
||||
// GetInfoProvider Get InfoProvider.
|
||||
func GetInfoProvider(provider, js, key, response, validate string) *InfoProvider {
|
||||
var infoProvider InfoProvider
|
||||
if provider == configuration.CustomProvider {
|
||||
infoProvider = &captcha.InfoProvider{js, key, response, validate}
|
||||
} else {
|
||||
infoProvider = infoProviders[provider]
|
||||
}
|
||||
return infoProvider
|
||||
}
|
||||
|
||||
// New Initialize captcha client.
|
||||
func (c *Client) New(log *logger.Log, cacheClient *cache.Client, httpClient *http.Client, infoProvider *InfoProvider, provider, siteKey, secretKey, remediationCustomHeader, captchaTemplatePath string, gracePeriodSeconds int64) error {
|
||||
func (c *Client) New(log *logger.Log, cacheClient *cache.Client, httpClient *http.Client, infoProvider *InfoProvider, siteKey, secretKey, remediationCustomHeader, captchaTemplatePath string, gracePeriodSeconds int64) error {
|
||||
c.Valid = provider != ""
|
||||
if !c.Valid {
|
||||
return nil
|
||||
}
|
||||
c.infoProvider = infoProvider
|
||||
if c.infoProvider == nil {
|
||||
c.infoProvider = infoProviders[provider]
|
||||
}
|
||||
c.siteKey = siteKey
|
||||
c.secretKey = secretKey
|
||||
c.remediationCustomHeader = remediationCustomHeader
|
||||
|
||||
Reference in New Issue
Block a user