Skip to main content

webgates_codecs/jwt/
validation_result.rs

1//! Types describing the outcome of JWT validation.
2//!
3//! This module contains [`JwtValidationResult`], the high-level result returned
4//! by JWT validation helpers after decoding and issuer checks.
5
6use super::JwtClaims;
7
8/// Result of validating a JWT token.
9///
10/// This type separates successful validation from the two expected failure
11/// categories exposed by this crate:
12/// - the token could not be decoded or validated
13/// - the token decoded successfully but did not match the expected issuer
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub enum JwtValidationResult<T> {
16    /// Token is valid and contains decoded claims.
17    Valid(JwtClaims<T>),
18
19    /// Token could not be decoded or failed JWT validation.
20    ///
21    /// This includes malformed tokens and tokens rejected by the configured JWT
22    /// validation settings.
23    InvalidToken,
24
25    /// Token decoded successfully but has the wrong issuer.
26    InvalidIssuer {
27        /// Issuer expected by the validation service.
28        expected: String,
29
30        /// Issuer found in the decoded token.
31        actual: String,
32    },
33}