Struct mz_frontegg_auth::FronteggAuthentication
source · [−]pub struct FronteggAuthentication {
pub(crate) admin_api_token_url: String,
pub(crate) decoding_key: DecodingKey,
pub(crate) tenant_id: Uuid,
pub(crate) now: NowFn,
pub(crate) validation: Validation,
pub(crate) refresh_before_secs: i64,
pub(crate) password_prefix: String,
}
Fields
admin_api_token_url: String
decoding_key: DecodingKey
tenant_id: Uuid
now: NowFn
validation: Validation
refresh_before_secs: i64
password_prefix: String
Implementations
sourceimpl FronteggAuthentication
impl FronteggAuthentication
sourcepub fn new(config: FronteggConfig) -> Self
pub fn new(config: FronteggConfig) -> Self
Creates a new frontegg auth. jwk_rsa_pem
is the RSA public key to
validate the JWTs. tenant_id
must be parseable as a UUID.
sourcepub async fn exchange_password_for_token(
&self,
password: &str
) -> Result<ApiTokenResponse, FronteggError>
pub async fn exchange_password_for_token(
&self,
password: &str
) -> Result<ApiTokenResponse, FronteggError>
Exchanges a password for a JWT token.
Somewhat unusually, the password encodes both the client ID and secret for the API key in use. Both the client ID and secret are UUIDs. The password can have one of two formats:
-
The URL-safe base64 encoding of the concatenated bytes of the UUIDs.
This format is a very compact representation (only 43 or 44 bytes) that is safe to use in a connection string without escaping.
-
The concatenated hex-encoding of the UUIDs, with any number of special characters that are ignored.
This format allows for the UUIDs to be formatted with hyphens, or not, and for the two
sourcepub async fn exchange_client_secret_for_token(
&self,
client_id: Uuid,
secret: Uuid
) -> Result<ApiTokenResponse, FronteggError>
pub async fn exchange_client_secret_for_token(
&self,
client_id: Uuid,
secret: Uuid
) -> Result<ApiTokenResponse, FronteggError>
Exchanges a client id and secret for a jwt token.
sourcepub fn validate_access_token(
&self,
token: &str,
expected_email: Option<&str>
) -> Result<Claims, FronteggError>
pub fn validate_access_token(
&self,
token: &str,
expected_email: Option<&str>
) -> Result<Claims, FronteggError>
Validates an access token and its tenant_id
.
sourcepub fn check_expiry(
&self,
token: ApiTokenResponse,
expected_email: String
) -> Result<impl Future<Output = ()>, FronteggError>
pub fn check_expiry(
&self,
token: ApiTokenResponse,
expected_email: String
) -> Result<impl Future<Output = ()>, FronteggError>
Returns a future that resolves if the token has expired.
Trait Implementations
sourceimpl Clone for FronteggAuthentication
impl Clone for FronteggAuthentication
sourcefn clone(&self) -> FronteggAuthentication
fn clone(&self) -> FronteggAuthentication
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for FronteggAuthentication
impl Send for FronteggAuthentication
impl Sync for FronteggAuthentication
impl Unpin for FronteggAuthentication
impl !UnwindSafe for FronteggAuthentication
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> FutureExt for T
impl<T> FutureExt for T
sourcefn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
sourcefn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more