Skip to content

Commit 3d18e20

Browse files
authored
Fix issues in the AAD login flow (#316)
1 parent da08a37 commit 3d18e20

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

packages/databricks-vscode/src/configuration/AuthProvider.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,13 @@ export abstract class AuthProvider {
3838
abstract toJSON(): Record<string, unknown>;
3939
abstract getEnvVars(): {[key: string]: string};
4040

41-
getCredentialProvider(): CredentialProvider {
42-
if (!this._credentialProvider) {
43-
this._credentialProvider = this.createCredentialProvider();
44-
}
45-
return this._credentialProvider;
46-
}
41+
public abstract getCredentialProvider(): CredentialProvider;
4742

4843
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4944
async check(silent: boolean): Promise<boolean> {
5045
return true;
5146
}
5247

53-
protected abstract createCredentialProvider(): CredentialProvider;
54-
5548
static fromJSON(json: Record<string, any>): AuthProvider {
5649
const url = json.url instanceof URL ? json.url : new URL(json.host);
5750
if (!url) {
@@ -109,7 +102,7 @@ export class TokenAuthProvider extends AuthProvider {
109102
};
110103
}
111104

112-
createCredentialProvider(): CredentialProvider {
105+
getCredentialProvider(): CredentialProvider {
113106
return fromToken(this.host, this.token);
114107
}
115108
}
@@ -138,7 +131,7 @@ export class ProfileAuthProvider extends AuthProvider {
138131
};
139132
}
140133

141-
createCredentialProvider(): CredentialProvider {
134+
getCredentialProvider(): CredentialProvider {
142135
return fromConfigFile(this.profile);
143136
}
144137
}
@@ -166,7 +159,7 @@ export class AzureCliAuthProvider extends AuthProvider {
166159
};
167160
}
168161

169-
createCredentialProvider(): CredentialProvider {
162+
getCredentialProvider(): CredentialProvider {
170163
return fromAzureCli(this.host);
171164
}
172165

packages/databricks-vscode/src/configuration/AzureCliCheck.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export class AzureCliCheck implements Disposable {
168168
} catch (e: any) {
169169
// parse error message
170170
const m = e.message.match(
171-
/Expected iss claim to be: https:\/\/sts\.windows\.net\/(.+), but was: https:\/\/sts\.windows\.net\/(.+)/
171+
/Expected iss claim to be: https:\/\/sts\.windows\.net\/([a-z0-9-]+?)\/?, but was: https:\/\/sts\.windows\.net\/([a-z0-9-]+)\/?/
172172
);
173173
if (m) {
174174
return m[1];

packages/databricks-vscode/src/configuration/configureWorkspaceWizard.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ export async function configureWorkspaceWizard(
107107
)
108108
.filter(
109109
(label) =>
110-
(
111-
profiles[label] as Profile
112-
).host.toString() === state.host!.toString()
110+
(profiles[label] as Profile).host
111+
.hostname ===
112+
new URL(state.host!).hostname
113113
)
114114
.map((label) => ({
115115
label,
@@ -206,6 +206,11 @@ async function validateDatabricksHost(
206206
host: string
207207
): Promise<string | undefined> {
208208
let url;
209+
210+
if (!host.startsWith("https://")) {
211+
host = `https://${host}`;
212+
}
213+
209214
try {
210215
url = new URL(host);
211216
} catch (e) {

0 commit comments

Comments
 (0)