pub struct CodecAuthTokenIssuer<C, F> { /* private fields */ }Expand description
Auth-token issuer backed by a webgates-codecs payload codec.
Callers provide a claims factory so this issuer can stay generic over both the subject type and the encoded claim shape.
§Examples
use webgates_codecs::jwt::{JsonWebToken, JwtClaims, RegisteredClaims};
use webgates_sessions::tokens::{AuthTokenIssuer, CodecAuthTokenIssuer};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
struct MyClaims {
sub: String,
}
// Install a crypto provider required by jsonwebtoken before using the codec.
webgates_codecs::jsonwebtoken::crypto::rust_crypto::DEFAULT_PROVIDER
.install_default()
.ok();
let codec = JsonWebToken::<JwtClaims<MyClaims>>::default();
let issuer = CodecAuthTokenIssuer::new(codec, |subject: &String| {
JwtClaims::new(
MyClaims { sub: subject.clone() },
RegisteredClaims::new("my-service", 4_102_444_800),
)
});
let token = issuer.issue_auth_token(&String::from("user-42")).await.unwrap();
assert!(!token.as_str().is_empty());Implementations§
Source§impl<C, F> CodecAuthTokenIssuer<C, F>
impl<C, F> CodecAuthTokenIssuer<C, F>
Trait Implementations§
Source§impl<Subject, Claims, C, F> AuthTokenIssuer<Subject> for CodecAuthTokenIssuer<C, F>
impl<Subject, Claims, C, F> AuthTokenIssuer<Subject> for CodecAuthTokenIssuer<C, F>
Auto Trait Implementations§
impl<C, F> Freeze for CodecAuthTokenIssuer<C, F>
impl<C, F> RefUnwindSafe for CodecAuthTokenIssuer<C, F>where
C: RefUnwindSafe,
F: RefUnwindSafe,
impl<C, F> Send for CodecAuthTokenIssuer<C, F>
impl<C, F> Sync for CodecAuthTokenIssuer<C, F>
impl<C, F> Unpin for CodecAuthTokenIssuer<C, F>
impl<C, F> UnsafeUnpin for CodecAuthTokenIssuer<C, F>where
C: UnsafeUnpin,
F: UnsafeUnpin,
impl<C, F> UnwindSafe for CodecAuthTokenIssuer<C, F>where
C: UnwindSafe,
F: UnwindSafe,
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