-
Notifications
You must be signed in to change notification settings - Fork 36
Support Azure AD Tokens instead of PAT tokens (Issue 121) #123
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
Conversation
Wow awesome thanks for the submission @divyavanmahajan! we'll take a look. |
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.
LGTM! 🚀
@divyavanmahajan could you please run |
Signed-off-by: divyavanmahajan <[email protected]>
Signed-off-by: divyavanmahajan <[email protected]>
Signed-off-by: divyavanmahajan <[email protected]>
Signed-off-by: divyavanmahajan <[email protected]>
Signed-off-by: divyavanmahajan <[email protected]>
17fbdf5
to
df5fa96
Compare
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 totally agree with the intent. It is unfortunately to wrong solution to the right issue.
Azure AD tokens work in all other drivers because Personal Access Token is implemented using Bearer tokens, and not basic auth. The fact that PAT works with basic auth is a Databricks idiosyncrasy.
So, the correct solution would be to set any token as Bearer, and not to add yet another flag to the driver interface.
Add the bearer Auth and change the code in DBSQLClient.ts
async connect(options: ConnectionOptions): Promise<IDBSQLClient> {
this.authProvider = new PlainHttpAuthentication({
username: 'token',
password: options.token, <-- root of the problem
headers: {
'User-Agent': buildUserAgentString(options.clientId),
},
});
Hi Andre,
In either case, you need to change the driver. Regards, |
Hi @divyavanmahajan, I think Andre means that you don't need to add an option to specify token type, because Databricks one can work as a Bearer token. So basically you can remove the whole branch related to --- a/lib/connection/auth/PlainHttpAuthentication.ts
+++ b/lib/connection/auth/PlainHttpAuthentication.ts
@@ -29,6 +29,6 @@ export default class PlainHttpAuthentication implements IAuthentication {
}
private getToken(username: string, password: string): string {
- return `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`;
+ return `Bearer ${password}`;
}
} |
Based on the suggestions from Andre - I am closing this pull request - and will create a new (smaller) pull request. |
Issue #121
Support Azure AD Tokens instead of PAT tokens
Summary:
PAT vs Azure AD tokens - PAT tokens are workspace specific and usually have a long expiry. Azure AD tokens expire within a few hours and the same token will work across all workspaces with SSO enabled.
Python driver supports Azure tokens but the NodeJS SQL driver does not.
This pull request is to support Azure AD tokens.
Description of change:
Workaround:
To use AAD token - you can tweak (@databricks/sql 1.1.1) as follows to use Azure AD tokens.
Submitted by:
Divya van Mahajan [email protected]