Skip to main content

hyperlane_plugin_auth/
enum.rs

1/// Authentication mechanism that verified an [`crate::AuthPrincipal`].
2#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
3pub enum AuthScheme {
4    /// JSON Web Token (`Authorization: Bearer <jwt>`).
5    #[default]
6    BearerJwt,
7    /// Static or rotated API key header (for example `X-Api-Key`).
8    ApiKey,
9    /// HTTP Basic credentials (`Authorization: Basic <base64>`).
10    Basic,
11    /// Application-defined custom authenticator scheme.
12    Custom,
13}
14
15/// Errors produced during token decoding, credential verification, or RBAC authorization.
16#[derive(Clone, Debug, Eq, PartialEq)]
17pub enum AuthError {
18    /// No credentials were provided on the request.
19    MissingCredentials,
20    /// Credentials or token failed parsing or signature verification.
21    InvalidCredentials,
22    /// JWT `exp` timestamp has passed beyond the configured leeway.
23    TokenExpired,
24    /// JWT `nbf` timestamp is still in the future beyond the configured leeway.
25    TokenNotYetValid,
26    /// JWT `alg` header is not supported (for example `none` or RS256 on HS256 codec).
27    UnsupportedAlgorithm,
28    /// JWT `iss` or `aud` claim did not satisfy policy requirements.
29    ClaimMismatch,
30    /// Authenticated principal lacks one or more required roles.
31    Forbidden,
32}