pub struct RedapProvider { /* private fields */ }Expand description
A secret key that is used to generate and verify tokens.
This represents a symmetric authentication scheme, which means that the same key is used to both sign and verify the token. In the future, we will need to support asymmetric schemes too.
The key is stored unencrypted in memory.
Implementations§
Source§impl RedapProvider
impl RedapProvider
Sourcepub fn from_secret_key(secret_key: SecretKey) -> Self
pub fn from_secret_key(secret_key: SecretKey) -> Self
Create an authentication provider from a secret key.
Sourcepub fn from_secret_key_base64(secret_key: &str) -> Result<Self, Error>
pub fn from_secret_key_base64(secret_key: &str) -> Result<Self, Error>
Create an authentication provider from a secret key encoded as base64.
Sourcepub fn token(
&self,
duration: Duration,
issuer: impl Into<String>,
subject: impl Into<String>,
permission: Permission,
allowed_host: Option<&str>,
) -> Result<Jwt, Error>
pub fn token( &self, duration: Duration, issuer: impl Into<String>, subject: impl Into<String>, permission: Permission, allowed_host: Option<&str>, ) -> Result<Jwt, Error>
Generates a new JWT token that is valid for the given duration.
It is important to note that the token is not encrypted, but merely
signed by the RedapProvider. This means that its contents are readable
by everyone.
If duration is None, the token will be valid forever. scope can be
used to restrict the token to a specific context.
If allowed_host is provided, it is set as the allowed_hosts claim
so the token can be restricted to a specific server hostname.
Trait Implementations§
Source§impl Clone for RedapProvider
impl Clone for RedapProvider
Source§fn clone(&self) -> RedapProvider
fn clone(&self) -> RedapProvider
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RedapProvider
impl RefUnwindSafe for RedapProvider
impl Send for RedapProvider
impl Sync for RedapProvider
impl Unpin for RedapProvider
impl UnsafeUnpin for RedapProvider
impl UnwindSafe for RedapProvider
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request