Skip to content

Remove Username assertion for web browser auth #2142

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/snowflake/connector/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ def __config(self, **kwargs):
self._token = f.read()

if not (self._master_token and self._session_token):
if not self.user and self._authenticator != OAUTH_AUTHENTICATOR:
if not self.user and self._authenticator != OAUTH_AUTHENTICATOR and self._authenticator != EXTERNAL_BROWSER_AUTHENTICATOR:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that for authentication itself user is not required, but it is required for storing a temporary credential (token) in the cache storage, to identify the owner.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make one SQL query to fetch the username of the current token and use that to store it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nicornk
You're right provided it would have taken place backend-side; however, the source of concern here is the client-side temporary credentials cache. As it's effectively a key-value storage, a unique key is required to built on the client-side as a prerequisite to authentication.
Technically it could've been some arbitrary identifier provided by a user, but probably it won't look like a much better user experience than currently required username, not sure. What's your opinion?

Copy link

@nicornk nicornk Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long is the temporary cached item valid for? Is it just for the duration of the login attempt, in that case wouldn’t there be another way to come up with a key for the KV store?

if it’s anyhow arbitrary, why not use a random uuid?

# OAuth Authentication does not require a username
Error.errorhandler_wrapper(
self,
Expand Down
Loading