#[non_exhaustive]pub struct AuthConfig {
pub enabled: bool,
pub api_keys: Vec<ApiKeyEntry>,
pub mtls: Option<MtlsConfig>,
pub rate_limit: Option<RateLimitConfig>,
pub oauth: Option<OAuthConfig>,
}Expand description
Authentication configuration.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.enabled: boolMaster switch - when false, all requests are allowed through.
api_keys: Vec<ApiKeyEntry>Bearer token API keys.
mtls: Option<MtlsConfig>mTLS client certificate authentication.
rate_limit: Option<RateLimitConfig>Rate limiting for auth attempts.
oauth: Option<OAuthConfig>OAuth 2.1 JWT bearer token authentication.
Implementations§
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn with_keys(keys: Vec<ApiKeyEntry>) -> Self
pub fn with_keys(keys: Vec<ApiKeyEntry>) -> Self
Create an enabled auth config with the given API keys.
Sourcepub fn with_rate_limit(self, rate_limit: RateLimitConfig) -> Self
pub fn with_rate_limit(self, rate_limit: RateLimitConfig) -> Self
Set rate limiting on this auth config.
Sourcepub fn check_oauth_feature(&self) -> Result<(), RmcpServerKitError>
pub fn check_oauth_feature(&self) -> Result<(), RmcpServerKitError>
Reject an [auth.oauth] table in a build compiled without the oauth
cargo feature.
Fails closed on purpose. Ignoring the table would start the server with OAuth silently disabled while the operator’s configuration says it is on – for a bearer-token deployment that is an unauthenticated server.
§Errors
Returns RmcpServerKitError::Config when auth.oauth is present and
the oauth feature is disabled. Always Ok when the feature is
enabled, where the table is parsed into
oauth::OAuthConfig instead.
Sourcepub fn validate_api_key_names(&self) -> Result<(), RmcpServerKitError>
pub fn validate_api_key_names(&self) -> Result<(), RmcpServerKitError>
Reject any configured API key whose name is blank (empty or
whitespace-only).
The key name is the session-binding fingerprint’s stable id for bearer auth, so two blank-named keys hash identically and one key’s session becomes usable by the other (CWE-384). The first offending index is named so an operator can locate the entry in their key list.
§Errors
Returns RmcpServerKitError::Config naming the first API-key index
whose name is blank.
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn summary(&self) -> AuthConfigSummary
pub fn summary(&self) -> AuthConfigSummary
Produce a hash-free summary of the auth config for admin endpoints.
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§fn clone(&self) -> AuthConfig
fn clone(&self) -> AuthConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more