-
Notifications
You must be signed in to change notification settings - Fork 0
fix(oauth2): prevent profile redirect during OIDC consent flow #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -461,7 +461,16 @@ protected function processUserHint(OAuth2AuthenticationRequest $request, Client | |
| $token_hint = $request->getIdTokenHint(); | ||
| $otp_login_hint = $request->getOTPLoginHint(); | ||
|
|
||
| Log::debug(sprintf("InteractiveGrant::processUserHint request %s client %s", $request->__toString(), $client->getId())); | ||
| Log::debug | ||
| ( | ||
| sprintf | ||
| ( | ||
| "InteractiveGrant::processUserHint request %s client %s", | ||
| $request->__toString(), | ||
| $client->getId() | ||
| ) | ||
| ); | ||
|
|
||
| // process login hint | ||
| $user = null; | ||
| if (!empty($otp_login_hint) && !empty ($login_hint) | ||
|
|
@@ -484,7 +493,7 @@ protected function processUserHint(OAuth2AuthenticationRequest $request, Client | |
| $user = $this->auth_service->getUserById($user_id); | ||
| } | ||
| $request->markParamAsProcessed(OAuth2Protocol::OAuth2Protocol_LoginHint); | ||
| } else if(!empty($token_hint)) { | ||
| } else if(!empty($token_hint) && !$request->isProcessedParam(OAuth2Protocol::OAuth2Protocol_IDTokenHint)) { | ||
| Log::debug("InteractiveGrant::processUserHint processing Token hint..."); | ||
|
|
||
| $jwt = BasicJWTFactory::build($token_hint); | ||
|
|
@@ -544,6 +553,7 @@ protected function processUserHint(OAuth2AuthenticationRequest $request, Client | |
|
|
||
| $this->auth_service->reloadSession($jti->getValue()); | ||
|
|
||
| $request->markParamAsProcessed(OAuth2Protocol::OAuth2Protocol_IDTokenHint); | ||
| } | ||
| if(!is_null($user)) | ||
| { | ||
|
|
@@ -689,6 +699,15 @@ protected function shouldForceReLogin(OAuth2AuthorizationRequest $request, IClie | |
| */ | ||
| protected function mustAuthenticateUser(OAuth2AuthorizationRequest $request, Client $client) | ||
| { | ||
| Log::debug | ||
| ( | ||
| sprintf | ||
| ( | ||
| "InteractiveGrant::mustAuthenticateUser: request %s client %s", | ||
| $request->__toString(), | ||
| $client->getClientId() | ||
| ) | ||
| ); | ||
|
|
||
| if ($request instanceof OAuth2AuthenticationRequest) { | ||
| try { | ||
|
|
@@ -702,19 +721,22 @@ protected function mustAuthenticateUser(OAuth2AuthorizationRequest $request, Cli | |
| throw $ex; | ||
| } | ||
| catch (Exception $ex){ | ||
| Log::warning($ex); | ||
| Log::warning("InteractiveGrant::mustAuthenticateUser processUserHint generic error", [ 'error' => $ex]); | ||
| $this->auth_service->logout(false); | ||
| return true; | ||
|
Comment on lines
723
to
726
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if there's a narrow catch for protocol exceptions before the generic catch
ast-grep --pattern $'catch (InvalidLoginHint $$$) {
$$$
}'
# Also search for any catch blocks in mustAuthenticateUser
rg -n -A5 'catch.*Exception' app/libs/OAuth2/GrantTypes/InteractiveGrantType.php | head -40Repository: OpenStackweb/openstackid Length of output: 1379 🏁 Script executed: #!/bin/bash
# Find the processUserHint method to understand what exceptions it can throw
rg -n -B 20 'catch (JWSInvalidJWKException' app/libs/OAuth2/GrantTypes/InteractiveGrantType.php | head -80Repository: OpenStackweb/openstackid Length of output: 154 🏁 Script executed: #!/bin/bash
# Search for InvalidLoginHint and InteractionRequiredException in the codebase
rg -r 'InvalidLoginHint|InteractionRequiredException' --type php | head -20Repository: OpenStackweb/openstackid Length of output: 464 🏁 Script executed: #!/bin/bash
# Look for the processUserHint method definition to see what it can throw
rg -n -A 30 'function processUserHint' app/libs/OAuth2/GrantTypes/InteractiveGrantType.php | head -60Repository: OpenStackweb/openstackid Length of output: 1802 🏁 Script executed: #!/bin/bash
# Search for InvalidLoginHint and InteractionRequiredException definitions
rg 'InvalidLoginHint|InteractionRequiredException' --type php -nRepository: OpenStackweb/openstackid Length of output: 1791 🏁 Script executed: #!/bin/bash
# Get broader context of the try-catch block starting from line 458
sed -n '458,730p' app/libs/OAuth2/GrantTypes/InteractiveGrantType.php | cat -nRepository: OpenStackweb/openstackid Length of output: 12696 🏁 Script executed: #!/bin/bash
# Check the end of processUserHint method to see where try starts
rg -n 'try' app/libs/OAuth2/GrantTypes/InteractiveGrantType.php | grep -A2 -B2 "70[0-9]:"Repository: OpenStackweb/openstackid Length of output: 50 Add narrow catch for protocol exceptions before the generic The The current code catches all Suggested structurecatch (InvalidLoginHint | InteractionRequiredException $ex) {
throw $ex;
}
catch (Exception $ex){
Log::warning("InteractiveGrant::mustAuthenticateUser processUserHint generic error", [ 'error' => $ex]);
$this->auth_service->logout(false);
return true;
}🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
| if($this->shouldPromptLogin($request)) | ||
| { | ||
| Log::warning("InteractiveGrant::mustAuthenticateUser: shouldPromptLogin"); | ||
| $this->auth_service->logout(false); | ||
| return true; | ||
| } | ||
|
|
||
| if($this->shouldForceReLogin($request, $client)) | ||
| { | ||
| Log::warning("InteractiveGrant::mustAuthenticateUser: shouldForceReLogin"); | ||
| $this->auth_service->logout(false); | ||
| return true; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't log raw OIDC request payloads here.
OAuth2Request::__toString()serializes the full message, so these new debug lines will writelogin_hint,id_token_hint, OTP hints, and other auth parameters into logs. That's sensitive user/token material on a hot path; keep the trace to booleans, client ID, and processed-flag state instead.Also applies to: 702-710
🤖 Prompt for AI Agents