pub struct Jwt { /* private fields */ }Expand description
Issues and verifies the server’s tokens.
Implementations§
Source§impl Jwt
impl Jwt
Sourcepub fn new(
secret: &[u8],
issuer: impl Into<String>,
audience: impl Into<String>,
) -> Self
pub fn new( secret: &[u8], issuer: impl Into<String>, audience: impl Into<String>, ) -> Self
Signs with secret, as issuer, for the default audience.
Sourcepub fn issue(
&self,
typ: TokenKind,
ttl: Option<Duration>,
payload: Payload,
) -> Result<String, JwtError>
pub fn issue( &self, typ: TokenKind, ttl: Option<Duration>, payload: Payload, ) -> Result<String, JwtError>
Issues a token for the default audience (the authorization server itself).
Sourcepub fn issue_for(
&self,
typ: TokenKind,
ttl: Option<Duration>,
payload: Payload,
audience: &str,
) -> Result<String, JwtError>
pub fn issue_for( &self, typ: TokenKind, ttl: Option<Duration>, payload: Payload, audience: &str, ) -> Result<String, JwtError>
Issues a token whose aud is audience, with SERVER_SUBJECT as its subject. Access
tokens for people come from issue_as with their subject, and need the
grant’s ver and auth_time in payload to be accepted.
Sourcepub fn issue_as(
&self,
typ: TokenKind,
ttl: Option<Duration>,
payload: Payload,
audience: &str,
subject: &str,
) -> Result<String, JwtError>
pub fn issue_as( &self, typ: TokenKind, ttl: Option<Duration>, payload: Payload, audience: &str, subject: &str, ) -> Result<String, JwtError>
Issues a token for audience whose subject is subject: who signed in.
Sourcepub fn claims_issuer_here(&self, token: &str) -> bool
pub fn claims_issuer_here(&self, token: &str) -> bool
Whether token looks like one this server issued: a JWT whose (unverified) iss is this
server. Such a token is never treated as anything else, even when it fails verification.
Auto Trait Implementations§
impl Forget for Jwt
impl Freeze for Jwt
impl RefUnwindSafe for Jwt
impl Send for Jwt
impl Sync for Jwt
impl Unpin for Jwt
impl UnsafeUnpin for Jwt
impl UnwindSafe for Jwt
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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