Skip to main content

Module security

Module security 

Source
Expand description

Security module providing authentication and authorization.

§Spring Equivalent

org.springframework.security package

§Module Structure

  • authenticator - User authentication implementations (MemoryAuthenticator)
  • authorizer - Request authorization implementations (RequestMatcherAuthorizer)
  • config - Core traits (Authenticator, Authorizer)
  • crypto - Password encoding (Argon2, BCrypt, NoOp, Delegating)
  • extractor - Actix Web extractors (AuthenticatedUser, OptionalUser)
  • http_basic - HTTP Basic Authentication support
  • jwt - JWT (JSON Web Token) Authentication
  • session - Session-based Authentication
  • manager - Factory methods (AuthenticationManager, AuthorizationManager)
  • middleware - Security middleware (SecurityTransform)
  • user - User model
  • web - Re-exports for backward compatibility
  • expression - Security Expression Language (SpEL-like)
  • context - Security context for accessing current user
  • headers - Security headers middleware (X-Frame-Options, CSP, HSTS, etc.)
  • rate_limit - Rate limiting middleware (brute-force protection)
  • audit - Security audit logging
  • account - Account locking on failed attempts
  • ldap - LDAP/Active Directory Authentication
  • saml - SAML 2.0 Single Sign-On
  • ant_matcher - Ant-style URL pattern matching
  • channel - Channel security (HTTPS enforcement)

§Feature Flags

  • argon2: Enables Argon2PasswordEncoder and DelegatingPasswordEncoder
  • bcrypt: Enables BCryptPasswordEncoder
  • http-basic: Enables HTTP Basic Authentication
  • jwt: Enables JWT Authentication
  • session: Enables Session-based Authentication
  • oauth2: Enables OAuth2/OIDC Authentication
  • rate-limit: Enables Rate Limiting middleware
  • audit: Enables Security Audit Logging
  • account-lock: Enables Account Locking
  • ldap: Enables LDAP/Active Directory Authentication
  • saml: Enables SAML 2.0 Single Sign-On

Modules§

account
Account locking and login attempt tracking.
ant_matcher
Ant-style Path Matcher
audit
Security Audit Logging system.
authenticator
In-Memory User Details Manager.
authorizer
Request Matcher based Authorization.
channel
Channel Security Module
context
Security Context for accessing the current authenticated user.
crypto
Password encoding utilities.
csrf
CSRF (Cross-Site Request Forgery) Protection.
expression
Security Expression Language (SpEL-like) for authorization.
form_login
Form-based Login Authentication.
headers
Security headers middleware for HTTP security.
http_basic
HTTP Basic Authentication support.
jwt
JWT (JSON Web Token) Authentication.
ldap
LDAP Authentication module.
manager
middleware
Security middleware for Actix Web.
oauth2
OAuth2 and OpenID Connect (OIDC) Authentication
rate_limit
Rate Limiting middleware for brute-force protection.
remember_me
Remember-Me Authentication.
saml
SAML 2.0 Authentication Module
session
Session-based Authentication.
user_details
User Details Service for loading users from any data source.
web
Re-exports for backward compatibility.

Structs§

Access
Access configuration for URL patterns.
AccountLockManager
Account lock manager for tracking failed attempts and locking accounts.
AccountStats
Account statistics.
AntMatcher
Ant-style path matcher
AntMatcherBuilder
Builder for creating multiple AntMatchers with common configuration
AntMatchers
Collection of AntMatchers for efficient path matching
Argon2PasswordEncoder
Argon2 password encoder - the recommended encoder for new applications.
AuditLogger
The main audit logger.
AuthenticatedUser
Extractor for the authenticated user.
AuthenticationManager
AuthnRequest
SAML AuthnRequest
AuthorizationManager
BCryptPasswordEncoder
BCrypt password encoder - widely compatible with other frameworks.
CachingUserDetailsService
Caching wrapper for UserDetailsService.
ChannelSecurity
Channel security middleware
ChannelSecurityConfig
Configuration for channel security
CsrfConfig
CSRF protection configuration.
CsrfProtection
CSRF protection middleware.
CsrfToken
CSRF Token.
DelegatingPasswordEncoder
Delegating password encoder that supports multiple encoding formats.
FormLoginConfig
Form login configuration.
FormLoginHandler
Form login handler for processing login/logout requests.
FormLoginService
Complete form login service combining authentication and session management.
HttpBasicConfig
HTTP Basic Authentication configuration.
InMemoryEventStore
In-memory event store for testing and debugging.
InMemoryUserDetailsService
In-memory implementation of UserDetailsService.
JwtAuthenticator
JWT-based authenticator.
JwtClaims
Standard JWT claims with security extensions.
JwtConfig
JWT configuration.
JwtTokenService
Service for generating and managing JWT tokens.
LdapAuthResult
LDAP authentication result.
LdapAuthenticator
LDAP Authenticator for actix-security.
LdapConfig
LDAP connection configuration.
LockConfig
Account lock configuration.
LoginForm
Login form data structure.
MemoryAuthenticator
In-memory user store for authentication.
MockLdapClient
Mock LDAP client for testing.
NoOpPasswordEncoder
No-op password encoder that stores passwords in plain text.
OAuth2Authenticator
OAuth2 authenticator that validates OAuth2 access tokens
OAuth2Client
OAuth2 client for handling authorization flows
OAuth2Config
OAuth2 configuration for a client registration
OAuth2User
User information retrieved from OAuth2 provider
OidcUser
OIDC user with ID token claims
OptionalUser
Optional extractor for the authenticated user.
PortMapper
Port mapping for HTTP/HTTPS redirects
RateLimitConfig
Rate limit configuration.
RateLimitInfo
Rate limit information for headers.
RateLimiter
Rate limiter middleware.
RateLimiterState
Rate limiter state.
RememberMeConfig
Remember-Me configuration.
RememberMeServices
Remember-Me authentication services.
RememberMeToken
Remember-Me token structure.
RequestMatcherAuthorizer
URL pattern-based authorization.
SamlAssertion
SAML Assertion
SamlAuthResult
Result of successful SAML authentication
SamlAuthenticator
SAML Authenticator for actix-web
SamlConfig
SAML Service Provider configuration
SamlResponse
SAML Response
SecurityContext
Holder for the current security context.
SecurityEvent
A security audit event.
SecurityHeaders
Security headers configuration.
SessionAuthenticator
Session-based authenticator.
SessionConfig
Session authentication configuration.
SessionCsrfTokenRepository
Session-based CSRF token repository.
SessionLoginService
Service for handling login/logout with sessions.
SessionUser
Serializable user data stored in session.
StdoutHandler
Simple logging handler that prints to stdout.
User
Represents an authenticated user with roles and authorities.
UserDetailsAuthenticator
Authenticator that uses a UserDetailsService for credential validation.

Enums§

AuthnContextClass
SAML 2.0 authentication context classes
ChannelRequirement
Channel security requirement
CsrfError
CSRF-related errors.
DefaultEncoder
Default encoding algorithm for DelegatingPasswordEncoder.
FormLoginError
Form login related errors.
KeyExtractor
Strategy for identifying clients for rate limiting.
LdapError
LDAP authentication error.
LockStatus
Account lock status.
LoginCheckResult
Result of a login check.
NameIdFormat
SAML 2.0 name ID formats
OAuth2Provider
Common OAuth2/OIDC providers with pre-configured endpoints
RateLimitAlgorithm
Rate limiting algorithm.
RememberMeError
Remember-Me related errors.
SamlBinding
SAML 2.0 binding types
SamlError
SAML authentication error
SamlStatusCode
SAML Status codes
SecurityEventSeverity
Severity level of security events.
SecurityEventType
Security event types for audit logging.
SessionError
Session-related errors.
SessionFixationStrategy
Strategy for session fixation protection.
UserDetailsError
Errors that can occur when loading or managing user details.

Traits§

Authenticator
Trait for extracting user identity from an HTTP request.
Authorizer
Trait for deciding whether an authenticated user can access a resource.
CredentialAuthenticator
Trait for authenticators that can validate username/password credentials.
CsrfTokenRepository
Trait for storing and retrieving CSRF tokens.
IntoAntMatcher
Extension trait for converting patterns to AntMatcher
LdapContextMapper
LDAP context mapper for custom user creation.
PasswordEncoder
Trait for encoding and verifying passwords.
SecurityEventHandler
Trait for handling security events.
SecurityExt
Extension trait for HttpRequest to check authentication.
UserDetailsManager
Extended trait for managing users (CRUD operations).
UserDetailsService
Async trait for loading user details from any data source.

Functions§

audit_log
Log a security event using the global logger.
check_login
Helper function to check login and return detailed result.
global_logger
Get the global audit logger.
init_global_logger
Initialize the global audit logger.