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