@@ -81,6 +81,10 @@ type Opts struct {
8181 // If not set, falls back to ReadonlyUser for backward compatibility
8282 ResetUser string
8383 ResetPassword string
84+
85+ CfTurnstileSiteKey string
86+ CfTurnstileSecret string
87+ CfTurnstileTimeoutSeconds uint
8488}
8589
8690// ConfigError represents a configuration validation error.
@@ -432,13 +436,37 @@ func ParseArgs(args []string) (*Opts, error) {
432436 envStringOrDefault ("LDAP_RESET_PASSWORD" , "" ),
433437 "Password for the dedicated reset user." ,
434438 )
439+
440+ fCfTurnstileSiteKey = fs .String (
441+ "cf-turnstile-site-key" ,
442+ envStringOrDefault ("CF_TURNSTILE_SITEKEY" , "" ),
443+ "Cloudflare Turnstile site key. Empty disables Turnstile." ,
444+ )
445+ fCfTurnstileSecret = fs .String (
446+ "cf-turnstile-secret" ,
447+ envStringOrDefault ("CF_TURNSTILE_SECRET" , "" ),
448+ "Cloudflare Turnstile secret key." ,
449+ )
450+ fCfTurnstileTimeoutSeconds = fs .Uint (
451+ "cf-turnstile-timeout-seconds" ,
452+ envIntOrDefault ("CF_TURNSTILE_TIMEOUT_SECONDS" , 15 , errs ),
453+ "Timeout in seconds for Cloudflare Turnstile verification." ,
454+ )
435455 )
436456
437457 // Parse the provided command-line arguments (caller passes args without program name)
438458 if err := fs .Parse (args ); err != nil {
439459 errs .Add (fmt .Sprintf ("flag parsing error: %v" , err ))
440460 }
441461
462+ if (* fCfTurnstileSiteKey == "" ) != (* fCfTurnstileSecret == "" ) {
463+ errs .Add ("cf-turnstile-site-key and cf-turnstile-secret must be configured together" )
464+ }
465+
466+ if * fCfTurnstileTimeoutSeconds == 0 {
467+ errs .Add ("cf-turnstile-timeout-seconds must be greater than zero" )
468+ }
469+
442470 // Keep the conversions at the use sites total: see the bound constants.
443471 checkUintMax ("smtp-port" , * fSMTPPort , maxSMTPPort , errs )
444472 checkUintMax ("reset-token-expiry-minutes" , * fResetTokenExpiryMinutes , maxDurationMinutes , errs )
@@ -551,6 +579,10 @@ func ParseArgs(args []string) (*Opts, error) {
551579
552580 ResetUser : * fResetUser ,
553581 ResetPassword : * fResetPassword ,
582+
583+ CfTurnstileSiteKey : * fCfTurnstileSiteKey ,
584+ CfTurnstileSecret : * fCfTurnstileSecret ,
585+ CfTurnstileTimeoutSeconds : * fCfTurnstileTimeoutSeconds ,
554586 }, nil
555587}
556588
0 commit comments