-
Notifications
You must be signed in to change notification settings - Fork 908
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
New Azure Auth Provider #9664
New Azure Auth Provider #9664
Conversation
import { MemoryDatabase } from '../utils/memoryDatabase'; | ||
const localize = nls.loadMessageBundle(); | ||
|
||
export interface AccountKey { |
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.
Not sure if those comments are useful unless they provide some information about the fields
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.
True haha
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.
Similar cases in the interfaces below :)
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.
The other ones seem pretty self explanatory :D
} catch (err) { | ||
console.dir(err); | ||
const msg = localize('azure.noToken', "Retrieving the token failed."); | ||
throw new Error(msg); |
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.
I think you missed showing the localized error to the user here instead of throwing the localized error.
could you please provide more description for this PR? |
The PR here should provide the information @alanrenmsft #9618 This PR is essentially that one just split into multiple chunks. This provides a new Azure Account Provider that is far less error prone and is ready to upgrade to MSAL when we're unblocked from doing so. |
|
||
if (!accessToken || !refreshToken) { | ||
console.log('Access or refresh token were undefined'); | ||
const msg = localize('azure.refreshTokenError', "Error when refreshing your account."); |
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.
User error
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.
Hmm not this one. It's called from two places and one of them I don't want to show it to the user.
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.
// 2) Remove them | ||
let results = await this._tokenCache.findThenable(query); | ||
this._tokenCache.removeThenable(results); | ||
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{}> { |
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.
Shouldn't the type here be TokenResponse (and really should be TokenResponse | undefined given what _getSecurityToken can actually 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.
Yeah technically this is only called as an interface method defined
azuredatastudio/src/sql/azdata.d.ts
Line 2277 in 43d9ed0
getSecurityToken(account: Account, resource: AzureResource): Thenable<{}>; |
But yeah since that accepts any object I'll do that and actually update the azdata definition as well.
let self = this; | ||
if (this.authMappings.size === 0) { | ||
const msg = localize('azure.NoAuthMethod', "No Azure auth method selected"); | ||
console.log('noAuthMethodSelected'); |
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.
Do we really need to log 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.
It's just so when we get bug reports in the future, more logs isn't a problem potentially?
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.
I guess - should probably consider logging to a separate stream though if we care about that so we don't have to pick through console logging. Anyways fine with it either way - although I'd prefer you make the output more descriptive since someone seeing this in the logs would have absolutely no idea what this is referring to unless they knew the code.
In reply to: 395911374 [](ancestors = 395911374)
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.
That makes sense, i'll update the message.
If it helps this is a serious edgecase if you have multiple auth methods enabled. (Default will just be one)
}; | ||
}); | ||
}); | ||
const pick = await vscode.window.showQuickPick(options, { canPickMany: false }); |
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.
Handle user cancelling out of this correctly
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.
Some smaller stuff but didn't see anything hugely stand out. I didn't really delve deep into the logic though since it gets pretty complex - I think we're just going to have to make sure to do thorough testing on it manually.
protected readonly memdb = new MemoryDatabase(); | ||
|
||
protected readonly WorkSchoolAccountType: string = 'work_school'; | ||
protected readonly MicrosoftAccountType: string = 'microsoft'; |
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.
These feel like they should be defined in a more central location (or at least as const values somewhere)
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.
Yeah I'm not really sure where though
extensions/azurecore/src/account-provider/azureAccountProvider.ts
Outdated
Show resolved
Hide resolved
extensions/azurecore/src/account-provider/azureAccountProviderService.ts
Outdated
Show resolved
Hide resolved
@@ -199,12 +230,16 @@ | |||
"@azure/arm-subscriptions": "1.0.0", | |||
"adal-node": "^0.2.1", | |||
"axios": "^0.19.2", | |||
"keytar": "^5.4.0", | |||
"qs": "^6.9.1", |
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.
we should update the 3rd-party notices when adding new runtime NPM modules.
|
||
function getSystemKeytar(): Keytar | undefined { | ||
try { | ||
return require('keytar'); |
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 do we do on Linux systems that don't have an installed key manager?
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.
It'll fallback to encrypted file based storage.
#9618
This is the largest chunk of the PRs we're looking for this feature.