pub struct JwtConfig {
pub algorithm: JwtAlgorithm,
pub issuer: Option<String>,
pub include_metadata: bool,
}Expand description
Configuration for JWT sessions
Fields§
§algorithm: JwtAlgorithmAlgorithm and keys for JWT
issuer: Option<String>Issuer claim
include_metadata: boolWhether to include metadata (IP, user agent) in the JWT
Implementations§
Source§impl JwtConfig
impl JwtConfig
Sourcepub fn new_rs256(private_key: Vec<u8>, public_key: Vec<u8>) -> Self
pub fn new_rs256(private_key: Vec<u8>, public_key: Vec<u8>) -> Self
Create a new JWT configuration with RS256 algorithm
Sourcepub fn new_hs256(secret_key: Vec<u8>) -> Self
pub fn new_hs256(secret_key: Vec<u8>) -> Self
Create a new JWT configuration with HS256 algorithm
Sourcepub fn from_rs256_pem_files(
private_key_path: impl AsRef<Path>,
public_key_path: impl AsRef<Path>,
) -> Result<Self, Error>
pub fn from_rs256_pem_files( private_key_path: impl AsRef<Path>, public_key_path: impl AsRef<Path>, ) -> Result<Self, Error>
Create a new JWT configuration from RSA key files (PEM format)
Sourcepub fn with_issuer(self, issuer: impl Into<String>) -> Self
pub fn with_issuer(self, issuer: impl Into<String>) -> Self
Set the issuer claim
Sourcepub fn with_metadata(self, include_metadata: bool) -> Self
pub fn with_metadata(self, include_metadata: bool) -> Self
Set whether to include metadata in the JWT
Sourcepub fn jwt_algorithm(&self) -> Algorithm
pub fn jwt_algorithm(&self) -> Algorithm
Get the algorithm to use with jsonwebtoken
Sourcepub fn get_encoding_key(&self) -> Result<EncodingKey, Error>
pub fn get_encoding_key(&self) -> Result<EncodingKey, Error>
Get the encoding key for signing
Sourcepub fn get_decoding_key(&self) -> Result<DecodingKey, Error>
pub fn get_decoding_key(&self) -> Result<DecodingKey, Error>
Get the decoding key for verification
Sourcepub fn get_validation(&self) -> Validation
pub fn get_validation(&self) -> Validation
Get the validation configuration for JWT verification
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JwtConfig
impl RefUnwindSafe for JwtConfig
impl Send for JwtConfig
impl Sync for JwtConfig
impl Unpin for JwtConfig
impl UnwindSafe for JwtConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.