-
Notifications
You must be signed in to change notification settings - Fork 9
Auth: Always set config.oAuth2 for OAuth2 accounts #983
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: master
Are you sure you want to change the base?
Conversation
|
Untested so far. |
NeilRashbrook
left a comment
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.
Would have been r+ without the error in 64c7e5f.
| await onContinue(); | ||
| return; |
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 is inconsistent with line 168 which doesn't explicitly return (because it's the last code in its block).
| export function getOAuth2BuiltIn(config: Account): WebBasedAuth | undefined { | ||
| if (config.protocol == "owa") { | ||
| return new OWAAuth(config as OWAAccount); | ||
| } | ||
| let hostname = (config as TCPAccount).hostname ?? | ||
| config.url ? new URL(config.url).hostname : null; | ||
| let o = OAuth2URLs.find(o => o.hostnames.some(h => h == hostname)); | ||
| if (!o) { | ||
| return undefined; |
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.
config.oAuth2 normally defaults to null.
Also, while I'm here, ?? has higher precedence than ?:, so you'll need to wrap line 14 in ()s.
| if (!this.oAuth2) { | ||
| let urls = OAuth2URLs.find(a => a.hostnames.includes(this.hostname)); | ||
| assert(urls, gt`Could not find OAuth2 config for ${this.hostname}`); | ||
| this.oAuth2 = new OAuth2(this, urls.tokenURL, urls.authURL, urls.authDoneURL, urls.scope, urls.clientID, urls.clientSecret, urls.doPKCE); | ||
| this.oAuth2.setTokenURLPasswordAuth(urls.tokenURLPasswordAuth); | ||
| } | ||
| this.oAuth2 ??= getOAuth2BuiltIn(this); |
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 assert went missing, although one was kept on line 168.
| @@ -1,5 +1,5 @@ | |||
|
|
|||
| export function assert(test: boolean | Object | null, errorMessage: string): asserts test { | |||
| export function assert(test: boolean | Object | null | undefined, errorMessage: string): asserts test { | |||
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.
What's complaining about this?
There were cases where we did not fill in an OAuth2 config. This is a revision of PR #981.
The automatic account setup failed to fill in the OAuth2 config. Before PR #969, this appeared to work, because the login step would always show the separate window UI, but then the account would be created with the popup window as the default auth UI.