pub struct AuthConfig {
pub enabled: bool,
pub validation_endpoint: Option<String>,
pub trusted_issuers: Vec<String>,
pub required_scopes: ScopeRequirements,
pub cache_ttl_seconds: u64,
pub validate_resource_indicators: bool,
pub jwt_secret: Option<String>,
pub require_signature_verification: bool,
}Expand description
Authentication configuration
§Security Implications
Authentication is critical for preventing unauthorized access:
- Always enable in production - Disabling authentication exposes all operations
- Use strong JWT secrets - Weak secrets enable token forgery
- Validate resource indicators - Prevents token reuse across services
- Short cache TTLs - Reduces window for compromised tokens
§Example: Secure Production Configuration
[auth]
enabled = true
validation_endpoint = "https://auth.example.com/validate"
trusted_issuers = ["https://auth.example.com"]
cache_ttl_seconds = 300 # 5 minutes
validate_resource_indicators = true
jwt_secret = "base64-encoded-256-bit-secret"
require_signature_verification = true
[auth.required_scopes]
default = ["kindlyguard:access"]
[auth.required_scopes.tools]
"security/scan" = ["security:read"]
"security/neutralize" = ["security:write", "security:admin"]Fields§
§enabled: boolEnable authentication (if false, all requests are allowed)
Default: false (for easier testing) Security: MUST be true in production. When false, anyone can access all operations without restriction. Warning: Running with authentication disabled is a critical security risk
validation_endpoint: Option<String>Token validation endpoint (optional, for remote validation)
Default: None (local validation only) Security: Use HTTPS endpoints only. Remote validation adds latency but enables centralized token management and revocation. Example: “https://auth.example.com/oauth2/introspect”
trusted_issuers: Vec<String>Trusted issuers
Default: empty (no issuers trusted) Security: Only tokens from these issuers will be accepted. Use specific issuer URLs, not wildcards or patterns. Example: [“https://auth.example.com”, “https://login.company.com”]
required_scopes: ScopeRequirementsRequired scopes for different operations
Default: No specific requirements Security: Define granular scopes to implement least privilege. Prevents tokens with limited scopes from accessing sensitive operations.
cache_ttl_seconds: u64Token cache settings
Default: 300 seconds (5 minutes) Security: Shorter TTLs reduce the window for compromised tokens but increase validation overhead. Balance security with performance. Range: 60-3600 seconds (recommend 300-900 for most cases)
validate_resource_indicators: boolEnable resource indicators validation
Default: true (secure by default) Security: Validates that tokens are intended for this specific service. Prevents token reuse attacks across different services (RFC 8707). Warning: Disabling allows tokens meant for other services
jwt_secret: Option<String>JWT signing secret (base64 encoded) for HMAC-SHA256 verification
Default: None
Security: Use a cryptographically secure 256-bit (32 byte) secret.
Must be kept confidential and rotated regularly.
Generation: openssl rand -base64 32
Warning: Weak secrets enable token forgery attacks
require_signature_verification: boolRequire JWT signature verification
Default: false Security: When true, all tokens must have valid signatures. Essential for preventing token tampering and forgery. Dependencies: Requires jwt_secret to be configured
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§fn clone(&self) -> AuthConfig
fn clone(&self) -> AuthConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuthConfig
impl Debug for AuthConfig
Source§impl Default for AuthConfig
impl Default for AuthConfig
Source§impl<'de> Deserialize<'de> for AuthConfig
impl<'de> Deserialize<'de> for AuthConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnwindSafe for AuthConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more