aster_forge_auth/error.rs
1//! Stable, product-mappable authentication failures.
2
3/// Result returned by authentication primitives.
4pub type Result<T> = std::result::Result<T, AuthError>;
5
6/// Errors produced by the product-neutral authentication mechanism.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
8pub enum AuthError {
9 /// The product entrypoint has not successfully initialized the process-wide JWT provider.
10 #[error("JWT crypto provider has not been initialized")]
11 CryptoProviderNotInitialized,
12 /// The upstream JWT provider was already installed; Forge never overwrites or adopts it.
13 #[error("JWT crypto provider was already installed")]
14 CryptoProviderAlreadyInstalled,
15 /// The caller supplied an invalid policy, key, identifier, or claim value.
16 #[error("invalid authentication policy")]
17 InvalidPolicy,
18 /// The token exceeded the configured parser budget.
19 #[error("authentication token exceeds the configured size limit")]
20 TokenTooLarge,
21 /// The token could not be decoded or its signature was not accepted.
22 #[error("invalid authentication token")]
23 InvalidToken,
24 /// The token signature was valid, but it is no longer valid at the current clock value.
25 #[error("authentication token expired")]
26 Expired,
27 /// The token's issuance or optional not-before time is beyond the accepted clock skew.
28 #[error("authentication token is not yet valid")]
29 NotYetValid,
30 /// A required claim is absent or malformed.
31 #[error("authentication token is missing a required claim")]
32 MissingClaim,
33 /// The token type does not match the operation.
34 #[error("authentication token type mismatch")]
35 WrongTokenType,
36 /// The token was signed with a disallowed algorithm.
37 #[error("authentication token algorithm is not allowed")]
38 AlgorithmMismatch,
39 /// The issuer does not match the configured policy.
40 #[error("authentication token issuer mismatch")]
41 IssuerMismatch,
42 /// The audience does not match the configured policy.
43 #[error("authentication token audience mismatch")]
44 AudienceMismatch,
45 /// Token creation failed without exposing secret material.
46 #[error("authentication token creation failed")]
47 Encoding,
48 /// The instance's bounded refresh request budget is exhausted.
49 #[error("refresh request budget exhausted")]
50 ResourceLimit,
51 /// Request cancellation or instance shutdown occurred before persistence started.
52 #[error("refresh request cancelled")]
53 Cancelled,
54}