pub struct JwtBuilder { /* private fields */ }Expand description
Sub-builder for JWT settings.
Entered via AuthBuilder::with_jwt(); call done()
to return to the parent builder.
Implementations§
Source§impl JwtBuilder
impl JwtBuilder
Sourcepub fn secret(self, secret: impl Into<String>) -> Self
pub fn secret(self, secret: impl Into<String>) -> Self
Set JWT secret key.
Must be at least 32 characters for HMAC algorithms.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_jwt().secret("my-long-secret-key-32-chars-min!!").done();Sourcepub fn secret_from_env(self, env_var: &str) -> Self
pub fn secret_from_env(self, env_var: &str) -> Self
Set JWT secret from environment variable.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_jwt().secret_from_env("MY_JWT_SECRET").done();Sourcepub fn issuer(self, issuer: impl Into<String>) -> Self
pub fn issuer(self, issuer: impl Into<String>) -> Self
Set JWT issuer.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_jwt().secret("secret-key-at-least-32-characters!!").issuer("my-service").done();Sourcepub fn audience(self, audience: impl Into<String>) -> Self
pub fn audience(self, audience: impl Into<String>) -> Self
Set JWT audience.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_jwt().secret("secret-key-at-least-32-characters!!").audience("my-api").done();Sourcepub fn token_lifetime(self, lifetime: Duration) -> Self
pub fn token_lifetime(self, lifetime: Duration) -> Self
Set token lifetime.
§Example
use auth_framework::prelude::*;
use std::time::Duration;
let builder = AuthFramework::builder()
.with_jwt()
.secret("secret-key-at-least-32-characters!!")
.token_lifetime(Duration::from_secs(1800))
.done();Sourcepub fn refresh_token_lifetime(self, lifetime: Duration) -> Self
pub fn refresh_token_lifetime(self, lifetime: Duration) -> Self
Set refresh token lifetime (defaults to 7 days).
§Example
use auth_framework::prelude::*;
use std::time::Duration;
let builder = AuthFramework::builder()
.with_jwt()
.secret("secret-key-at-least-32-characters!!")
.refresh_token_lifetime(Duration::from_secs(86400))
.done();Sourcepub fn algorithm(self, algorithm: JwtAlgorithm) -> Self
pub fn algorithm(self, algorithm: JwtAlgorithm) -> Self
Set the JWT signing algorithm (defaults to HS256).
§Example
use auth_framework::prelude::*;
use auth_framework::config::JwtAlgorithm;
let builder = AuthFramework::builder()
.with_jwt()
.secret("secret-key-at-least-32-characters!!")
.algorithm(JwtAlgorithm::HS512)
.done();Sourcepub fn done(self) -> AuthBuilder
pub fn done(self) -> AuthBuilder
Complete JWT configuration and return to main builder.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_jwt().secret("secret-key-at-least-32-characters!!").done()
.with_storage().memory().done();Auto Trait Implementations§
impl Freeze for JwtBuilder
impl !RefUnwindSafe for JwtBuilder
impl Send for JwtBuilder
impl Sync for JwtBuilder
impl Unpin for JwtBuilder
impl UnsafeUnpin for JwtBuilder
impl !UnwindSafe for JwtBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more