pub struct LocalDecoder { /* private fields */ }Expand description
JWT decoder that validates tokens using locally stored keys.
Supports multiple decoding keys and tries them sequentially until one succeeds. Ideal for scenarios with key rotation or multiple valid signing keys.
§Example
ⓘ
use axum_jwt_auth::LocalDecoder;
use jsonwebtoken::{DecodingKey, Algorithm, Validation};
let keys = vec![DecodingKey::from_secret(b"secret")];
let mut validation = Validation::new(Algorithm::HS256);
validation.set_audience(&["my-app"]);
let decoder = LocalDecoder::builder()
.keys(keys)
.validation(validation)
.build()
.unwrap();Implementations§
Source§impl LocalDecoder
impl LocalDecoder
Sourcepub fn new(
keys: Vec<DecodingKey>,
validation: Validation,
) -> Result<Self, Error>
pub fn new( keys: Vec<DecodingKey>, validation: Validation, ) -> Result<Self, Error>
Creates a new LocalDecoder with the specified keys and validation settings.
§Errors
Returns Error::Configuration if:
- No decoding keys are provided
- No validation algorithms are configured
- No audience is specified in validation
Trait Implementations§
Source§impl Clone for LocalDecoder
impl Clone for LocalDecoder
Source§fn clone(&self) -> LocalDecoder
fn clone(&self) -> LocalDecoder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for LocalDecoder
impl RefUnwindSafe for LocalDecoder
impl Send for LocalDecoder
impl Sync for LocalDecoder
impl Unpin for LocalDecoder
impl UnwindSafe for LocalDecoder
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
Mutably borrows from an owned value. Read more