pub struct TokenVerifier { /* private fields */ }Expand description
How bearer tokens are checked.
A shared secret (HS256) lets the server issue tokens itself. A public key (RS256, ES256 or EdDSA) lets another service sign tokens, for example one per database, while the server holds no secret at all.
Implementations§
Source§impl TokenVerifier
impl TokenVerifier
Verify HS256 tokens signed with secret.
Sourcepub fn public_key_pem(pem: &[u8]) -> Result<Self, String>
pub fn public_key_pem(pem: &[u8]) -> Result<Self, String>
Verify tokens signed by the private half of a PEM public key. The algorithm follows the key: RSA keys use RS256, EC P-256 keys ES256, Ed25519 keys EdDSA.
Sourcepub fn with_issuer_audience(
self,
issuer: Option<String>,
audience: Option<String>,
) -> Self
pub fn with_issuer_audience( self, issuer: Option<String>, audience: Option<String>, ) -> Self
Also require these iss / aud values when set.
Sourcepub fn verify(&self, token: &str) -> Result<Claims, ApiError>
pub fn verify(&self, token: &str) -> Result<Claims, ApiError>
Validate a token and return its claims.
Sourcepub fn authenticate(&self, token: &str) -> Result<AuthenticatedAgent, ApiError>
pub fn authenticate(&self, token: &str) -> Result<AuthenticatedAgent, ApiError>
Validate a token into the caller it represents.
Auto Trait Implementations§
impl Freeze for TokenVerifier
impl RefUnwindSafe for TokenVerifier
impl Send for TokenVerifier
impl Sync for TokenVerifier
impl Unpin for TokenVerifier
impl UnsafeUnpin for TokenVerifier
impl UnwindSafe for TokenVerifier
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request