chore: Update axum to 0.8

Signed-off-by: MATILLAT Quentin <qmatillat@gmail.com>
This commit is contained in:
MATILLAT Quentin 2025-01-11 17:38:34 +01:00
parent 57e571bd93
commit 3b4bbb6978
No known key found for this signature in database
GPG key ID: B9BAF56E288158D2
3 changed files with 45 additions and 12 deletions

View file

@ -1,9 +1,11 @@
use std::{borrow::Cow, ops::Deref};
use std::{borrow::Cow, convert::Infallible, ops::Deref};
use crate::{error::ExtractorError, AdditionalClaims, ClearSessionFlag};
use async_trait::async_trait;
use axum::response::Redirect;
use axum_core::{extract::FromRequestParts, response::IntoResponse};
use axum_core::{
extract::{FromRequestParts, OptionalFromRequestParts},
response::IntoResponse,
};
use http::{request::Parts, uri::PathAndQuery, Uri};
use openidconnect::{core::CoreGenderClaim, IdTokenClaims};
@ -13,7 +15,6 @@ use openidconnect::{core::CoreGenderClaim, IdTokenClaims};
#[derive(Clone)]
pub struct OidcClaims<AC: AdditionalClaims>(pub IdTokenClaims<AC, CoreGenderClaim>);
#[async_trait]
impl<S, AC> FromRequestParts<S> for OidcClaims<AC>
where
S: Send + Sync,
@ -30,6 +31,18 @@ where
}
}
impl<S, AC> OptionalFromRequestParts<S> for OidcClaims<AC>
where
S: Send + Sync,
AC: AdditionalClaims,
{
type Rejection = Infallible;
async fn from_request_parts(parts: &mut Parts, _: &S) -> Result<Option<Self>, Self::Rejection> {
Ok(parts.extensions.get::<Self>().cloned())
}
}
impl<AC: AdditionalClaims> Deref for OidcClaims<AC> {
type Target = IdTokenClaims<AC, CoreGenderClaim>;
@ -53,7 +66,6 @@ where
#[derive(Clone)]
pub struct OidcAccessToken(pub String);
#[async_trait]
impl<S> FromRequestParts<S> for OidcAccessToken
where
S: Send + Sync,
@ -69,6 +81,17 @@ where
}
}
impl<S> OptionalFromRequestParts<S> for OidcAccessToken
where
S: Send + Sync,
{
type Rejection = Infallible;
async fn from_request_parts(parts: &mut Parts, _: &S) -> Result<Option<Self>, Self::Rejection> {
Ok(parts.extensions.get::<Self>().cloned())
}
}
impl Deref for OidcAccessToken {
type Target = str;
@ -147,7 +170,6 @@ impl OidcRpInitiatedLogout {
}
}
#[async_trait]
impl<S> FromRequestParts<S> for OidcRpInitiatedLogout
where
S: Send + Sync,
@ -159,10 +181,22 @@ where
.extensions
.get::<Option<Self>>()
.cloned()
.ok_or(ExtractorError::Unauthorized)?{
.ok_or(ExtractorError::Unauthorized)?
{
Some(this) => Ok(this),
None => Err(ExtractorError::RpInitiatedLogoutNotSupported),
}
}
}
}
impl<S> OptionalFromRequestParts<S> for OidcRpInitiatedLogout
where
S: Send + Sync,
{
type Rejection = Infallible;
async fn from_request_parts(parts: &mut Parts, _: &S) -> Result<Option<Self>, Self::Rejection> {
Ok(parts.extensions.get::<Option<Self>>().cloned().flatten())
}
}