Content-Length: 261884 | pFad | https://github.com/sebadob/rauthy/commit/e5d1d9dd30452fdf5c33cc8e1cfac9670a514c74

24 unauthorized session bugfix for password reset endpoint · sebadob/rauthy@e5d1d9d · GitHub
Skip to content

Commit

Permalink
unauthorized session bugfix for password reset endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: sebadob <sebastiandobe@mailbox.org>
  • Loading branch information
sebadob committed Nov 20, 2023
1 parent aea3c0e commit e5d1d9d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions rauthy-handlers/src/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,22 +569,23 @@ pub async fn post_webauthn_auth_start(
MfaPurpose::Login(_) => id.into_inner(),

MfaPurpose::PasswordReset => {
let binding_cookie = match req.cookie(PWD_RESET_COOKIE) {
match req.cookie(PWD_RESET_COOKIE) {
None => {
return Err(ErrorResponse::new(
ErrorResponseType::BadRequest,
"You are not allowed to do this operation without an active binding cookie"
.to_string(),
));
}
Some(c) => c,
Some(c) => {
if c.value().len() != 48 {
return Err(ErrorResponse::new(
ErrorResponseType::BadRequest,
"Malformed magic link binding cookie".to_string(),
));
};
}
};
if binding_cookie.value().len() != 48 {
return Err(ErrorResponse::new(
ErrorResponseType::BadRequest,
"Malformed magic link binding cookie".to_string(),
));
}

id.into_inner()
}
Expand Down Expand Up @@ -756,8 +757,6 @@ pub async fn post_webauthn_reg_start(
req: HttpRequest,
req_data: Json<WebauthnRegStartRequest>,
) -> Result<HttpResponse, ErrorResponse> {
principal.validate_session_auth()?;

// If we have a magic link ID in the payload, we do not validate the active session / principal.
// This is mandatory to make registering a passkey for a completely new account work.
if req_data.magic_link_id.is_some() && req_data.email.is_some() {
Expand All @@ -769,6 +768,7 @@ pub async fn post_webauthn_reg_start(
)
.await
} else {
principal.validate_session_auth()?;
// this endpoint is a CSRF check exception inside the Principal Middleware -> check here!
principal.validate_session_csrf_exception(&req)?;

Expand Down Expand Up @@ -805,8 +805,8 @@ pub async fn post_webauthn_reg_finish(
req: HttpRequest,
req_data: Json<WebauthnRegFinishRequest>,
) -> Result<HttpResponse, ErrorResponse> {
principal.validate_session_auth()?;

// If we have a magic link ID in the payload, we do not validate the active session / principal.
// This is mandatory to make registering a passkey for a completely new account work.
if req_data.magic_link_id.is_some() {
password_reset::handle_put_user_passkey_finish(
&data,
Expand All @@ -816,6 +816,7 @@ pub async fn post_webauthn_reg_finish(
)
.await
} else {
principal.validate_session_auth()?;
// this endpoint is a CSRF check exception inside the Principal Middleware -> check here!
principal.validate_session_csrf_exception(&req)?;

Expand Down

0 comments on commit e5d1d9d

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/sebadob/rauthy/commit/e5d1d9dd30452fdf5c33cc8e1cfac9670a514c74

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy