Skip to main content

actix_security_core/http/security/
mod.rs

1//! Security module providing authentication and authorization.
2//!
3//! # Spring Equivalent
4//! `org.springframework.security` package
5//!
6//! # Module Structure
7//!
8//! - `authenticator` - User authentication implementations (MemoryAuthenticator)
9//! - `authorizer` - Request authorization implementations (RequestMatcherAuthorizer)
10//! - `config` - Core traits (Authenticator, Authorizer)
11//! - `crypto` - Password encoding (Argon2, BCrypt, NoOp, Delegating)
12//! - `extractor` - Actix Web extractors (AuthenticatedUser, OptionalUser)
13//! - `http_basic` - HTTP Basic Authentication support
14//! - `jwt` - JWT (JSON Web Token) Authentication
15//! - `session` - Session-based Authentication
16//! - `manager` - Factory methods (AuthenticationManager, AuthorizationManager)
17//! - `middleware` - Security middleware (SecurityTransform)
18//! - `user` - User model
19//! - `web` - Re-exports for backward compatibility
20//! - `expression` - Security Expression Language (SpEL-like)
21//! - `context` - Security context for accessing current user
22//! - `headers` - Security headers middleware (X-Frame-Options, CSP, HSTS, etc.)
23//! - `rate_limit` - Rate limiting middleware (brute-force protection)
24//! - `audit` - Security audit logging
25//! - `account` - Account locking on failed attempts
26//! - `ldap` - LDAP/Active Directory Authentication
27//! - `saml` - SAML 2.0 Single Sign-On
28//! - `ant_matcher` - Ant-style URL pattern matching
29//! - `channel` - Channel security (HTTPS enforcement)
30//!
31//! # Feature Flags
32//! - `argon2`: Enables `Argon2PasswordEncoder` and `DelegatingPasswordEncoder`
33//! - `bcrypt`: Enables `BCryptPasswordEncoder`
34//! - `http-basic`: Enables HTTP Basic Authentication
35//! - `jwt`: Enables JWT Authentication
36//! - `session`: Enables Session-based Authentication
37//! - `oauth2`: Enables OAuth2/OIDC Authentication
38//! - `rate-limit`: Enables Rate Limiting middleware
39//! - `audit`: Enables Security Audit Logging
40//! - `account-lock`: Enables Account Locking
41//! - `ldap`: Enables LDAP/Active Directory Authentication
42//! - `saml`: Enables SAML 2.0 Single Sign-On
43
44// Re-exports for convenience
45pub use authenticator::MemoryAuthenticator;
46pub use authorizer::{Access, RequestMatcherAuthorizer};
47pub use config::{Authenticator, Authorizer};
48pub use crypto::{NoOpPasswordEncoder, PasswordEncoder};
49#[cfg(feature = "argon2")]
50pub use crypto::{Argon2PasswordEncoder, DelegatingPasswordEncoder, DefaultEncoder};
51#[cfg(feature = "bcrypt")]
52pub use crypto::BCryptPasswordEncoder;
53pub use extractor::{AuthenticatedUser, OptionalUser, SecurityExt};
54#[cfg(feature = "http-basic")]
55pub use http_basic::HttpBasicConfig;
56#[cfg(feature = "jwt")]
57pub use jwt::{JwtAuthenticator, JwtConfig, JwtTokenService, Claims as JwtClaims};
58#[cfg(feature = "session")]
59pub use session::{
60    CredentialAuthenticator, SessionAuthenticator, SessionConfig, SessionError,
61    SessionFixationStrategy, SessionLoginService, SessionUser,
62};
63#[cfg(feature = "remember-me")]
64pub use remember_me::{RememberMeConfig, RememberMeError, RememberMeServices, RememberMeToken};
65#[cfg(feature = "csrf")]
66pub use csrf::{CsrfConfig, CsrfError, CsrfProtection, CsrfToken, CsrfTokenRepository, SessionCsrfTokenRepository};
67#[cfg(feature = "form-login")]
68pub use form_login::{FormLoginConfig, FormLoginError, FormLoginHandler, FormLoginService, LoginForm};
69#[cfg(feature = "user-details")]
70pub use user_details::{
71    CachingUserDetailsService, InMemoryUserDetailsService, UserDetailsAuthenticator,
72    UserDetailsError, UserDetailsManager, UserDetailsService,
73};
74#[cfg(feature = "oauth2")]
75pub use oauth2::{OAuth2Authenticator, OAuth2Client, OAuth2Config, OAuth2Provider, OAuth2User, OidcUser};
76pub use context::SecurityContext;
77pub use headers::SecurityHeaders;
78pub use manager::{AuthenticationManager, AuthorizationManager};
79pub use user::User;
80#[cfg(feature = "rate-limit")]
81pub use rate_limit::{
82    KeyExtractor, RateLimitAlgorithm, RateLimitConfig, RateLimitInfo, RateLimiter,
83    RateLimiterState,
84};
85#[cfg(feature = "audit")]
86pub use audit::{
87    audit_log, global_logger, init_global_logger, AuditLogger, InMemoryEventStore,
88    SecurityEvent, SecurityEventHandler, SecurityEventSeverity, SecurityEventType, StdoutHandler,
89};
90#[cfg(feature = "account-lock")]
91pub use account::{
92    check_login, AccountLockManager, AccountStats, LockConfig, LockStatus, LoginCheckResult,
93};
94#[cfg(feature = "ldap")]
95pub use ldap::{
96    LdapAuthResult, LdapAuthenticator, LdapConfig, LdapContextMapper, LdapError, MockLdapClient,
97};
98#[cfg(feature = "saml")]
99pub use saml::{
100    AuthnContextClass, AuthnRequest, NameIdFormat, SamlAssertion, SamlAuthResult,
101    SamlAuthenticator, SamlBinding, SamlConfig, SamlError, SamlResponse, SamlStatusCode,
102};
103pub use ant_matcher::{AntMatcher, AntMatcherBuilder, AntMatchers, IntoAntMatcher};
104pub use channel::{ChannelRequirement, ChannelSecurity, ChannelSecurityConfig, PortMapper};
105
106// Internal modules (private implementation details)
107mod config;
108mod extractor;
109mod user;
110
111// Public modules
112pub mod authenticator;
113pub mod authorizer;
114pub mod context;
115pub mod crypto;
116pub mod expression;
117pub mod headers;
118pub mod http_basic;
119#[cfg(feature = "jwt")]
120pub mod jwt;
121#[cfg(feature = "session")]
122pub mod session;
123#[cfg(feature = "remember-me")]
124pub mod remember_me;
125#[cfg(feature = "csrf")]
126pub mod csrf;
127#[cfg(feature = "form-login")]
128pub mod form_login;
129#[cfg(feature = "user-details")]
130pub mod user_details;
131#[cfg(feature = "oauth2")]
132pub mod oauth2;
133#[cfg(feature = "rate-limit")]
134pub mod rate_limit;
135#[cfg(feature = "audit")]
136pub mod audit;
137#[cfg(feature = "account-lock")]
138pub mod account;
139#[cfg(feature = "ldap")]
140pub mod ldap;
141#[cfg(feature = "saml")]
142pub mod saml;
143pub mod ant_matcher;
144pub mod channel;
145pub mod manager;
146pub mod middleware;
147
148// Backward compatibility module
149pub mod web;