pub struct JwtAuthConfig {
pub enabled: bool,
pub secret: Option<String>,
pub public_key: Option<String>,
pub algorithm: String,
pub audience: Option<Vec<String>>,
pub issuer: Option<String>,
pub leeway: u64,
}Expand description
Per-route JWT authentication requirement.
spikard-http defines the canonical JwtConfig used by ServerConfig.jwt_auth, but
spikard-core cannot depend on spikard-http (the dependency runs the other way), so that
type cannot be reused here. This mirrors its fields so a later enforcement phase in
spikard-http can convert between the two without losing information. ~keep
secret and public_key are both optional because asymmetric algorithms (RS256, ES256, …)
verify against a public key rather than a shared secret; see fixtures/auth.json’s
jwt_config_algorithm_rs256, which carries public_key and no secret at all. Exactly one is
expected to be populated for a given algorithm, but that cross-field invariant is left to a
later enforcement phase rather than the type itself. ~keep
Fields§
§enabled: boolWhether this per-route JWT auth requirement is active. Present on 21/21 jwt_auth fixture
payloads in the corpus; defaults to true because presence of a jwt_auth block has always
meant “enabled” up to now. Without this field a fixture setting "enabled": false would
silently keep auth on while the fixture’s parse still succeeds — a vacuous pass. ~keep
secret: Option<String>Symmetric secret key for JWT verification (HS256, HS384, HS512)
public_key: Option<String>Asymmetric public key for JWT verification (RS256, ES256, etc.)
algorithm: StringRequired algorithm (HS256, HS384, HS512, RS256, etc.)
audience: Option<Vec<String>>Required audience claim
issuer: Option<String>Required issuer claim
leeway: u64Leeway for expiration checks (seconds)
Trait Implementations§
Source§impl Clone for JwtAuthConfig
impl Clone for JwtAuthConfig
Source§impl Debug for JwtAuthConfig
impl Debug for JwtAuthConfig
Source§impl<'de> Deserialize<'de> for JwtAuthConfig
impl<'de> Deserialize<'de> for JwtAuthConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for JwtAuthConfig
Source§impl PartialEq for JwtAuthConfig
impl PartialEq for JwtAuthConfig
Source§impl Serialize for JwtAuthConfig
impl Serialize for JwtAuthConfig
impl StructuralPartialEq for JwtAuthConfig
Auto Trait Implementations§
impl Freeze for JwtAuthConfig
impl RefUnwindSafe for JwtAuthConfig
impl Send for JwtAuthConfig
impl Sync for JwtAuthConfig
impl Unpin for JwtAuthConfig
impl UnsafeUnpin for JwtAuthConfig
impl UnwindSafe for JwtAuthConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.