mirror of
https://github.com/pfzetto/axum-oidc.git
synced 2024-11-21 11:02:50 +01:00
update tower-sessions
This commit is contained in:
parent
991f24e31f
commit
dacaedf9ca
2 changed files with 17 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "axum-oidc"
|
||||
description = "A wrapper for the openidconnect crate for axum"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
edition = "2021"
|
||||
authors = [ "Paul Z <info@pfz4.de>" ]
|
||||
readme = "README.md"
|
||||
|
@ -17,7 +17,7 @@ axum-core = "0.4"
|
|||
axum = { version = "0.7", default-features = false, features = [ "query" ] }
|
||||
tower-service = "0.3.2"
|
||||
tower-layer = "0.3"
|
||||
tower-sessions = { version = "0.7", default-features = false, features = [ "axum-core" ] }
|
||||
tower-sessions = { version = "0.9", default-features = false, features = [ "axum-core" ] }
|
||||
http = "1.0"
|
||||
async-trait = "0.1"
|
||||
openidconnect = "3.4"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::{
|
||||
marker::PhantomData,
|
||||
str::FromStr,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
|
@ -16,20 +15,15 @@ use tower_service::Service;
|
|||
use tower_sessions::Session;
|
||||
|
||||
use openidconnect::{
|
||||
core::{
|
||||
CoreAuthenticationFlow, CoreGenderClaim, CoreIdTokenFields, CoreJsonWebKeyType,
|
||||
CoreJweContentEncryptionAlgorithm, CoreJwsSigningAlgorithm,
|
||||
},
|
||||
reqwest::async_http_client,
|
||||
AccessTokenHash, AuthorizationCode, CsrfToken, ExtraTokenFields, IdTokenFields, Nonce,
|
||||
OAuth2TokenResponse, PkceCodeChallenge, PkceCodeVerifier, RedirectUrl, RefreshToken, Scope,
|
||||
StandardTokenResponse, TokenResponse, TokenType,
|
||||
core::CoreAuthenticationFlow, reqwest::async_http_client, AccessTokenHash, AuthorizationCode,
|
||||
CsrfToken, Nonce, OAuth2TokenResponse, PkceCodeChallenge, PkceCodeVerifier, RedirectUrl, Scope,
|
||||
TokenResponse,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
error::{Error, MiddlewareError},
|
||||
extractor::{OidcAccessToken, OidcClaims},
|
||||
AdditionalClaims, BoxError, IdToken, OidcClient, OidcQuery, OidcSession, SESSION_KEY,
|
||||
AdditionalClaims, BoxError, OidcClient, OidcQuery, OidcSession, SESSION_KEY,
|
||||
};
|
||||
|
||||
/// Layer for the [OidcLoginMiddleware].
|
||||
|
@ -124,8 +118,10 @@ where
|
|||
.extensions
|
||||
.get::<Session>()
|
||||
.ok_or(MiddlewareError::SessionNotFound)?;
|
||||
let login_session: Option<OidcSession> =
|
||||
session.get(SESSION_KEY).map_err(MiddlewareError::from)?;
|
||||
let login_session: Option<OidcSession> = session
|
||||
.get(SESSION_KEY)
|
||||
.await
|
||||
.map_err(MiddlewareError::from)?;
|
||||
|
||||
let handler_uri =
|
||||
strip_oidc_from_path(oidcclient.application_base_url.clone(), &parts.uri)?;
|
||||
|
@ -178,7 +174,7 @@ where
|
|||
.refresh_token()
|
||||
.map(|x| x.secret().to_string());
|
||||
|
||||
session.insert(SESSION_KEY, login_session).unwrap();
|
||||
session.insert(SESSION_KEY, login_session).await.unwrap();
|
||||
|
||||
Ok(Redirect::temporary(&handler_uri.to_string()).into_response())
|
||||
} else {
|
||||
|
@ -208,7 +204,7 @@ where
|
|||
refresh_token: None,
|
||||
};
|
||||
|
||||
session.insert(SESSION_KEY, oidc_session).unwrap();
|
||||
session.insert(SESSION_KEY, oidc_session).await.unwrap();
|
||||
|
||||
Ok(Redirect::temporary(auth_url.as_str()).into_response())
|
||||
}
|
||||
|
@ -308,8 +304,10 @@ where
|
|||
.extensions
|
||||
.get::<Session>()
|
||||
.ok_or(MiddlewareError::SessionNotFound)?;
|
||||
let mut login_session: Option<OidcSession> =
|
||||
session.get(SESSION_KEY).map_err(MiddlewareError::from)?;
|
||||
let mut login_session: Option<OidcSession> = session
|
||||
.get(SESSION_KEY)
|
||||
.await
|
||||
.map_err(MiddlewareError::from)?;
|
||||
|
||||
let handler_uri =
|
||||
strip_oidc_from_path(oidcclient.application_base_url.clone(), &parts.uri)?;
|
||||
|
@ -384,7 +382,7 @@ where
|
|||
.get::<Session>()
|
||||
.ok_or(MiddlewareError::SessionNotFound)?;
|
||||
|
||||
session.insert(SESSION_KEY, login_session).unwrap();
|
||||
session.insert(SESSION_KEY, login_session).await.unwrap();
|
||||
}
|
||||
(None, None) => {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue