CWaptcha'nın tüm yapılandırma seçenekleri, varsayılanlar ve notlarla.
{
"CWaptcha": {
"SecretKey": "", // required — set via user-secrets or env var
"NonceTtlSeconds": 300, // optional, default 300 (5 min)
"HoneypotFieldName": "cw_hp_email", // optional
"ProtectedPaths": [], // optional — routes intercepted by middleware
"RequireHttps": false // optional, enable true in production
}
}
| Seçenek | Tür | Varsayılan | Açıklama |
|---|---|---|---|
SecretKey |
string | required | Ana HMAC anahtarı. user-secrets veya ortam değişkeni ile ayarlayın. Boşsa başlangıçta OptionsValidationException fırlatır. |
NonceTtlSeconds |
int | 300 | Bir nonce'ın geçerli olduğu süre (saniye). Süresi dolduktan sonra token "expired" ile reddedilir. |
HoneypotFieldName |
string | "cw_hp_email" | JS tarafından eklenen gizli honeypot alanının adı. Betik etiketindeki data-honeypot özelliğiyle eşleşmelidir. |
ProtectedPaths |
string[] | [] | Middleware'in yakaladığı rotalar. OrdinalIgnoreCase önek eşleşmesiyle karşılaştırılır. Yalnızca POST fiili doğrulanır. |
RequireHttps |
bool | false | true olduğunda HTTPS olmayan istekleri reddeder. Ters proxy kurulumları için IsHttps veya X-Forwarded-Proto: https kontrol eder. |
dotnet user-secrets set "CWaptcha:SecretKey" "your-secret-here"
# System environment variable (double underscore = section separator)
CWaptcha__SecretKey=your-secret-here
<environmentVariables>
<environmentVariable name="CWaptcha__SecretKey" value="your-secret-here" />
</environmentVariables>
// Program.cs
builder.Services.AddStackExchangeRedisCache(o =>
o.Configuration = builder.Configuration["Redis:ConnectionString"]);
builder.Services.AddCWaptcha(builder.Configuration.GetSection("CWaptcha"))
.UseDistributedNonceStore();