mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 20:32:48 +00:00
oidc: Add checking of state returned by IdP
This commit is contained in:
@@ -131,6 +131,7 @@ pub async fn route_post_oidc(
|
||||
pub struct AuthCallbackQuery {
|
||||
code: AuthorizationCode,
|
||||
iss: IssuerUrl,
|
||||
state: String,
|
||||
}
|
||||
|
||||
/// Handle callback from IdP page
|
||||
@@ -139,7 +140,7 @@ pub async fn route_get_oidc_callback<AP: AuthenticationProvider>(
|
||||
oidc_config: Data<OidcConfig>,
|
||||
session: Session,
|
||||
auth_provider: Data<AP>,
|
||||
Query(AuthCallbackQuery { code, iss }): Query<AuthCallbackQuery>,
|
||||
Query(AuthCallbackQuery { code, iss, state }): Query<AuthCallbackQuery>,
|
||||
default_redirect_name: Data<DefaultRedirectRouteName>,
|
||||
) -> Result<impl Responder, OidcError> {
|
||||
assert_eq!(iss, oidc_config.issuer);
|
||||
@@ -148,6 +149,8 @@ pub async fn route_get_oidc_callback<AP: AuthenticationProvider>(
|
||||
.ok_or(OidcError::Other("No local OIDC state"))?
|
||||
.map_err(|_| OidcError::Other("Error parsing OIDC state"))?;
|
||||
|
||||
assert_eq!(oidc_state.state.secret(), &state);
|
||||
|
||||
let http_client = get_http_client();
|
||||
let oidc_client = get_oidc_client(
|
||||
oidc_config.get_ref().clone(),
|
||||
|
||||
Reference in New Issue
Block a user