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:
Paul Zinselmeyer 2024-03-08 17:17:00 +01:00
parent abe316884e
commit 0b34935b5a
Signed by: pfzetto
GPG key ID: B471A1AF06C895FD
7 changed files with 158 additions and 49 deletions

View file

@ -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()
}
}