pub enum SecurityError {
Show 21 variants
RateLimitExceeded {
retry_after: u64,
limit: usize,
window_secs: u64,
},
QueryTooDeep {
depth: usize,
max_depth: usize,
},
QueryTooComplex {
complexity: usize,
max_complexity: usize,
},
QueryTooLarge {
size: usize,
max_size: usize,
},
OriginNotAllowed(String),
MethodNotAllowed(String),
HeaderNotAllowed(String),
InvalidCSRFToken(String),
CSRFSessionMismatch,
AuditLogFailure(String),
SecurityConfigError(String),
TlsRequired {
detail: String,
},
TlsVersionTooOld {
current: TlsVersion,
required: TlsVersion,
},
MtlsRequired {
detail: String,
},
InvalidClientCert {
detail: String,
},
AuthRequired,
InvalidToken,
TokenExpired {
expired_at: DateTime<Utc>,
},
TokenMissingClaim {
claim: String,
},
InvalidTokenAlgorithm {
algorithm: String,
},
IntrospectionDisabled {
detail: String,
},
}Expand description
Main security error type for all security operations.
Covers rate limiting, query validation, CORS, CSRF, audit logging, and security configuration errors.
Variants§
RateLimitExceeded
Rate limiting exceeded - client has made too many requests.
Contains:
retry_after: Seconds to wait before retryinglimit: Maximum allowed requestswindow_secs: Time window in seconds
Fields
QueryTooDeep
Query validation: depth exceeds maximum allowed.
GraphQL queries can nest arbitrarily deep, which can cause excessive database queries or resource consumption.
QueryTooComplex
Query validation: complexity exceeds configured limit.
Complexity is calculated as a weighted sum of field costs, accounting for pagination and nested selections.
Fields
QueryTooLarge
Query validation: size exceeds maximum allowed bytes.
Very large queries can consume memory or cause DoS.
OriginNotAllowed(String)
CORS origin not in allowed list.
MethodNotAllowed(String)
CORS HTTP method not allowed.
HeaderNotAllowed(String)
CORS header not in allowed list.
InvalidCSRFToken(String)
CSRF token validation failed.
CSRFSessionMismatch
CSRF token session ID mismatch.
AuditLogFailure(String)
Audit log write failure.
Audit logging to the database failed. The underlying reason is captured in the error string.
SecurityConfigError(String)
Security configuration error.
The security configuration is invalid or incomplete.
TlsRequired
TLS/HTTPS required but connection is not secure.
The security profile requires all connections to be HTTPS/TLS, but an HTTP connection was received.
TlsVersionTooOld
TLS version is below the minimum required version.
The connection uses TLS but the version is too old. For example, if TLS 1.3 is required but the connection uses TLS 1.2.
Fields
current: TlsVersionThe TLS version actually used
required: TlsVersionThe minimum TLS version required
MtlsRequired
Mutual TLS (client certificate) required but not provided.
The security profile requires mTLS, meaning clients must present a valid X.509 certificate, but none was provided.
InvalidClientCert
Client certificate validation failed.
A client certificate was presented, but it failed validation. This could be due to an invalid signature, expired certificate, revoked certificate, or other validation errors.
AuthRequired
Authentication is required but none was provided.
Used in auth middleware when authentication is required (configured or policy enforces it) but no valid credentials were found in the request.
InvalidToken
Authentication token is invalid or malformed.
The provided authentication token (e.g., JWT) failed to parse or validate. Could be due to invalid signature, bad format, etc.
TokenExpired
Authentication token has expired.
The authentication token has an ‘exp’ claim and that timestamp has passed. The user needs to re-authenticate.
TokenMissingClaim
Authentication token is missing a required claim.
The authentication token doesn’t have a required claim like ‘sub’, ‘exp’, etc.
InvalidTokenAlgorithm
Authentication token algorithm doesn’t match expected algorithm.
The token was signed with a different algorithm than expected (e.g., token used HS256 but system expects RS256).
IntrospectionDisabled
GraphQL introspection query is not allowed.
The security policy disallows introspection queries (__schema, __type), typically in production to prevent schema information leakage.
Trait Implementations§
Source§impl Clone for SecurityError
impl Clone for SecurityError
Source§fn clone(&self) -> SecurityError
fn clone(&self) -> SecurityError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecurityError
impl Debug for SecurityError
Source§impl Display for SecurityError
impl Display for SecurityError
Source§impl Error for SecurityError
impl Error for SecurityError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl PartialEq for SecurityError
impl PartialEq for SecurityError
impl Eq for SecurityError
Auto Trait Implementations§
impl Freeze for SecurityError
impl RefUnwindSafe for SecurityError
impl Send for SecurityError
impl Sync for SecurityError
impl Unpin for SecurityError
impl UnsafeUnpin for SecurityError
impl UnwindSafe for SecurityError
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.