-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fixes Microsoft 365 OAUTH2 authentication workflow no longer works #9598 #9939
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
Open
lambjs
wants to merge
2
commits into
roundcube:master
Choose a base branch
from
lambjs:fix/9598-m365-oauth-fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21
−2
Open
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 |
|---|---|---|
|
|
@@ -161,6 +161,7 @@ public function __construct($options = []) | |
| 'language' => ['locale'], | ||
| ]), | ||
| 'scope' => $this->rcmail->config->get('oauth_scope', ''), | ||
| 'scope_identity' => $this->rcmail->config->get('oauth_scope_identity', ''), | ||
| 'timeout' => $this->rcmail->config->get('oauth_timeout', 10), | ||
| 'verify_peer' => $this->rcmail->config->get('oauth_verify_peer', true), | ||
| 'auth_parameters' => $this->rcmail->config->get('oauth_auth_parameters', []), | ||
|
|
@@ -641,7 +642,14 @@ public function request_access_token($auth_code, $state = null) | |
|
|
||
| // request user identity (email) | ||
| if (empty($username)) { | ||
| $fetched_identity = $this->fetch_userinfo($authorization); | ||
| if($this->options['scope_identity']) { | ||
| $this->mask_auth_data($data); | ||
| $refresh_response = $this->refresh_access_token($data, $this->options['scope_identity']); | ||
| $data_ident = $refresh_response['token']; | ||
| $authorization_ident = $refresh_response['authorization']; | ||
| } | ||
|
|
||
| $fetched_identity = $this->fetch_userinfo($authorization_ident); | ||
|
Member
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->log_debug('fetched identity: %s', json_encode($fetched_identity, true)); | ||
|
|
||
|
|
@@ -720,11 +728,14 @@ public function request_access_token($auth_code, $state = null) | |
| * If successful, this will update the `oauth_token` entry in | ||
| * session data. | ||
| * | ||
| * @param array $token | ||
| * @param string $change_scope Optional, changes scope if specified | ||
| * | ||
| * @return array|false Updated authorization data | ||
| * | ||
| * @see https://datatracker.ietf.org/doc/html/rfc6749#section-6 | ||
| */ | ||
| public function refresh_access_token(array $token) | ||
| public function refresh_access_token(array $token, $change_scope = null) | ||
| { | ||
| $oauth_token_uri = $this->options['token_uri']; | ||
| $oauth_client_id = $this->options['client_id']; | ||
|
|
@@ -741,6 +752,10 @@ public function refresh_access_token(array $token) | |
| 'client_secret' => $oauth_client_secret, | ||
| ]; | ||
|
|
||
| if($change_scope) { | ||
|
Member
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. Add space after |
||
| $form['scope'] = $change_scope; | ||
| } | ||
|
|
||
| if ($this->options['pkce']) { | ||
| $form['code_verifier'] = $this->rcmail->decrypt($_SESSION['oauth_code_verifier']); | ||
| } | ||
|
|
||
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.
Add a space after
if, please.