pub struct SecurityConfig {
pub profile: SecurityProfile,
pub settings: SecuritySettings,
pub api_key: Option<String>,
pub jwt_secret: Option<String>,
pub jwt_issuer: String,
pub jwt_audience: String,
pub config_file_path: Option<PathBuf>,
}Expand description
Main security configuration
Fields§
§profile: SecurityProfileSecurity profile
settings: SecuritySettingsSecurity settings
api_key: Option<String>API key for simple authentication
jwt_secret: Option<String>JWT secret for token validation
jwt_issuer: StringJWT issuer
jwt_audience: StringJWT audience
config_file_path: Option<PathBuf>Configuration file path (if loaded from file)
Implementations§
Source§impl SecurityConfig
impl SecurityConfig
Sourcepub fn new(profile: SecurityProfile, settings: SecuritySettings) -> Self
pub fn new(profile: SecurityProfile, settings: SecuritySettings) -> Self
Create a new security configuration with custom settings
Sourcepub fn development() -> Self
pub fn development() -> Self
Create development configuration
Sourcepub fn production() -> Self
pub fn production() -> Self
Create production configuration
Sourcepub fn from_env() -> SecurityResult<Self>
pub fn from_env() -> SecurityResult<Self>
Create configuration from environment variables
Sourcepub fn load_from_env(&mut self) -> SecurityResult<()>
pub fn load_from_env(&mut self) -> SecurityResult<()>
Load configuration overrides from environment variables
Sourcepub fn validate(&self) -> SecurityResult<()>
pub fn validate(&self) -> SecurityResult<()>
Validate the configuration
Sourcepub fn create_api_key_validator(
&self,
) -> SecurityResult<Option<ApiKeyValidator>>
pub fn create_api_key_validator( &self, ) -> SecurityResult<Option<ApiKeyValidator>>
Create an API key validator from this configuration
Sourcepub fn create_token_validator(&self) -> SecurityResult<Option<TokenValidator>>
pub fn create_token_validator(&self) -> SecurityResult<Option<TokenValidator>>
Create a token validator from this configuration
Sourcepub async fn create_middleware(&self) -> SecurityResult<SecurityMiddleware>
pub async fn create_middleware(&self) -> SecurityResult<SecurityMiddleware>
Create security middleware from this configuration
Sourcepub fn summary(&self) -> ConfigSummary
pub fn summary(&self) -> ConfigSummary
Get configuration summary for logging
Sourcepub fn with_api_key<S: Into<String>>(self, api_key: S) -> Self
pub fn with_api_key<S: Into<String>>(self, api_key: S) -> Self
Set API key
Sourcepub fn with_jwt_secret<S: Into<String>>(self, jwt_secret: S) -> Self
pub fn with_jwt_secret<S: Into<String>>(self, jwt_secret: S) -> Self
Set JWT secret
Sourcepub fn with_jwt_issuer<S: Into<String>>(self, issuer: S) -> Self
pub fn with_jwt_issuer<S: Into<String>>(self, issuer: S) -> Self
Set JWT issuer
Sourcepub fn with_jwt_audience<S: Into<String>>(self, audience: S) -> Self
pub fn with_jwt_audience<S: Into<String>>(self, audience: S) -> Self
Set JWT audience
Trait Implementations§
Source§impl Clone for SecurityConfig
impl Clone for SecurityConfig
Source§fn clone(&self) -> SecurityConfig
fn clone(&self) -> SecurityConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SecurityConfig
impl RefUnwindSafe for SecurityConfig
impl Send for SecurityConfig
impl Sync for SecurityConfig
impl Unpin for SecurityConfig
impl UnwindSafe for SecurityConfig
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
Mutably borrows from an owned value. Read more