mirror of
https://github.com/pfzetto/axum-oidc.git
synced 2025-01-18 04:49:03 +01:00
chore: Update axum to 0.8
Signed-off-by: MATILLAT Quentin <qmatillat@gmail.com>
This commit is contained in:
parent
57e571bd93
commit
3b4bbb6978
3 changed files with 45 additions and 12 deletions
|
@ -13,13 +13,12 @@ keywords = [ "axum", "oidc", "openidconnect", "authentication" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
axum-core = "0.4"
|
axum-core = "0.5"
|
||||||
axum = { version = "0.7", default-features = false, features = [ "query" ] }
|
axum = { version = "0.8", default-features = false, features = [ "query" ] }
|
||||||
tower-service = "0.3"
|
tower-service = "0.3"
|
||||||
tower-layer = "0.3"
|
tower-layer = "0.3"
|
||||||
tower-sessions = { version = "0.13", default-features = false, features = [ "axum-core" ] }
|
tower-sessions = { version = "0.13", default-features = false, features = [ "axum-core" ] }
|
||||||
http = "1.1"
|
http = "1.1"
|
||||||
async-trait = "0.1"
|
|
||||||
openidconnect = "3.5"
|
openidconnect = "3.5"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
|
|
|
@ -7,7 +7,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.37", features = ["net", "macros", "rt-multi-thread"] }
|
tokio = { version = "1.37", features = ["net", "macros", "rt-multi-thread"] }
|
||||||
axum = "0.7"
|
axum = { version = "0.8", features = ["macros"] }
|
||||||
axum-oidc = { path = "./../.." }
|
axum-oidc = { path = "./../.." }
|
||||||
tower = "0.4"
|
tower = "0.4"
|
||||||
tower-sessions = "0.13"
|
tower-sessions = "0.13"
|
||||||
|
|
|
@ -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 crate::{error::ExtractorError, AdditionalClaims, ClearSessionFlag};
|
||||||
use async_trait::async_trait;
|
|
||||||
use axum::response::Redirect;
|
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 http::{request::Parts, uri::PathAndQuery, Uri};
|
||||||
use openidconnect::{core::CoreGenderClaim, IdTokenClaims};
|
use openidconnect::{core::CoreGenderClaim, IdTokenClaims};
|
||||||
|
|
||||||
|
@ -13,7 +15,6 @@ use openidconnect::{core::CoreGenderClaim, IdTokenClaims};
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct OidcClaims<AC: AdditionalClaims>(pub IdTokenClaims<AC, CoreGenderClaim>);
|
pub struct OidcClaims<AC: AdditionalClaims>(pub IdTokenClaims<AC, CoreGenderClaim>);
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<S, AC> FromRequestParts<S> for OidcClaims<AC>
|
impl<S, AC> FromRequestParts<S> for OidcClaims<AC>
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
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> {
|
impl<AC: AdditionalClaims> Deref for OidcClaims<AC> {
|
||||||
type Target = IdTokenClaims<AC, CoreGenderClaim>;
|
type Target = IdTokenClaims<AC, CoreGenderClaim>;
|
||||||
|
|
||||||
|
@ -53,7 +66,6 @@ where
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct OidcAccessToken(pub String);
|
pub struct OidcAccessToken(pub String);
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<S> FromRequestParts<S> for OidcAccessToken
|
impl<S> FromRequestParts<S> for OidcAccessToken
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
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 {
|
impl Deref for OidcAccessToken {
|
||||||
type Target = str;
|
type Target = str;
|
||||||
|
|
||||||
|
@ -147,7 +170,6 @@ impl OidcRpInitiatedLogout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<S> FromRequestParts<S> for OidcRpInitiatedLogout
|
impl<S> FromRequestParts<S> for OidcRpInitiatedLogout
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
|
@ -159,10 +181,22 @@ where
|
||||||
.extensions
|
.extensions
|
||||||
.get::<Option<Self>>()
|
.get::<Option<Self>>()
|
||||||
.cloned()
|
.cloned()
|
||||||
.ok_or(ExtractorError::Unauthorized)?{
|
.ok_or(ExtractorError::Unauthorized)?
|
||||||
|
{
|
||||||
Some(this) => Ok(this),
|
Some(this) => Ok(this),
|
||||||
None => Err(ExtractorError::RpInitiatedLogoutNotSupported),
|
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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue