mirror of
https://codeberg.org/pfzetto/axum-oidc
synced 2025-12-09 22:55:17 +01:00
Dependency Update, Added examples/basic, CI
Updated the dependencies to the newest version. Added `AsRef` and `Deref` traits to the extractors. Moved the example from `README.md` to `examples/basic`. Added a CI Pipeline.
This commit is contained in:
parent
abe316884e
commit
0b34935b5a
7 changed files with 158 additions and 49 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use std::ops::Deref;
|
||||
|
||||
use crate::{error::ExtractorError, AdditionalClaims};
|
||||
use async_trait::async_trait;
|
||||
use axum_core::extract::FromRequestParts;
|
||||
|
|
@ -27,6 +29,23 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<AC: AdditionalClaims> Deref for OidcClaims<AC> {
|
||||
type Target = IdTokenClaims<AC, CoreGenderClaim>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<AC> AsRef<IdTokenClaims<AC, CoreGenderClaim>> for OidcClaims<AC>
|
||||
where
|
||||
AC: AdditionalClaims,
|
||||
{
|
||||
fn as_ref(&self) -> &IdTokenClaims<AC, CoreGenderClaim> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Extractor for the OpenID Connect Access Token.
|
||||
///
|
||||
/// This Extractor will only return the Access Token when the cached session is valid and [crate::middleware::OidcAuthMiddleware] is loaded.
|
||||
|
|
@ -48,3 +67,17 @@ where
|
|||
.ok_or(ExtractorError::Unauthorized)
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for OidcAccessToken {
|
||||
type Target = str;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for OidcAccessToken {
|
||||
fn as_ref(&self) -> &str {
|
||||
self.0.as_str()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue