-
Notifications
You must be signed in to change notification settings - Fork 14
fix: pass all OAuth params in consent redirect to prevent session race #630
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
Closed
cbcoutinho
wants to merge
2
commits into
H2CK:master
from
cbcoutinho:fix/consent-redirect-session-race
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,18 +213,39 @@ public function authorize( | |
| $scopeFromParam = $scope ?? 'null'; | ||
| $this->logger->debug('[SCOPE DEBUG] Scope from URL parameter: ' . $scopeFromParam); | ||
|
|
||
| if (empty($client_id)) { | ||
| $client_id = $this->session->get('oidc_client_id'); | ||
| $this->logger->debug('[CLIENT DEBUG] Client ID from session fallback: ' . ($client_id ?? 'null')); | ||
| $state = $this->session->get('oidc_state'); | ||
| $response_type = $this->session->get('oidc_response_type'); | ||
| $redirect_uri = $this->session->get('oidc_redirect_uri'); | ||
| $scope = $this->session->get('oidc_scope'); | ||
| if (empty($client_id) || empty($state) || empty($response_type) || empty($redirect_uri)) { | ||
| if (empty($client_id)) { | ||
| $client_id = $this->session->get('oidc_client_id'); | ||
| $this->logger->debug('[CLIENT DEBUG] Client ID from session fallback: ' . ($client_id ?? 'null')); | ||
| } | ||
| if (empty($state)) { | ||
| $state = $this->session->get('oidc_state'); | ||
| } | ||
| if (empty($response_type)) { | ||
| $response_type = $this->session->get('oidc_response_type'); | ||
| } | ||
| if (empty($redirect_uri)) { | ||
| $redirect_uri = $this->session->get('oidc_redirect_uri'); | ||
| } | ||
| $scope = $scope ?? $this->session->get('oidc_scope'); | ||
| $this->logger->debug('[SCOPE DEBUG] Scope from session fallback: ' . ($scope ?? 'null')); | ||
| $nonce = $this->session->get('oidc_nonce'); | ||
| $resource = $this->session->get('oidc_resource'); | ||
| $code_challenge = $this->session->get('oidc_code_challenge'); | ||
| $code_challenge_method = $this->session->get('oidc_code_challenge_method'); | ||
| $nonce = $nonce ?? $this->session->get('oidc_nonce'); | ||
| $resource = $resource ?? $this->session->get('oidc_resource'); | ||
| $code_challenge = $code_challenge ?? $this->session->get('oidc_code_challenge'); | ||
| $code_challenge_method = $code_challenge_method ?? $this->session->get('oidc_code_challenge_method'); | ||
| } | ||
|
|
||
| // Guard: if critical OAuth params are still missing after session fallback, | ||
| // return a meaningful error instead of letting downstream code crash with a 500 | ||
| // (e.g. matchRedirectUri(null, ...) or trim(null) in PHP 8.4). | ||
| if (empty($state) || empty($response_type) || empty($redirect_uri)) { | ||
|
Owner
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. This will break implicit flow implementation of guacamole. See #626. |
||
| $this->logger->error('Missing critical OAuth params after session fallback: ' | ||
| . 'state=' . var_export($state, true) . ', ' | ||
| . 'response_type=' . var_export($response_type, true) . ', ' | ||
| . 'redirect_uri=' . var_export($redirect_uri, true)); | ||
| return new TemplateResponse('core', '400', [ | ||
| 'message' => $this->l->t('Authorization session expired. Please try again.'), | ||
| ], 'error'); | ||
| } | ||
|
|
||
| // Set default scope if scope is not set at all | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This again allows a partial fallback (per missing attribute) to the session which leads to mixed oidc parameters and can cause problems as described in #621. Session fallback should only happen if client id is missing and then all parameters should be read from session. Otherwise parameters will be mixed if multiple client perform authentication.