Skip to content
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

server: only set default tenant if login successful #98983

Conversation

dhartunian
Copy link
Collaborator

Previously, we would always set the default tenant cookie to the default tenant cluster setting regardless of what tenants the user logged-in to successfully.

This change ensures that the default tenant selection is only used when the successful logins include that tenant. Otherwise, we select the first tenant from the list of successful logins.

Epic: CRDB-12100
Release note: None

@dhartunian dhartunian requested a review from a team as a code owner March 19, 2023 15:48
@dhartunian dhartunian requested a review from a team March 19, 2023 15:48
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

LGTM, but could you also help me understand what happens (in terms of UX) if login doesn't succeed on any of the tenants at all?

@dhartunian dhartunian force-pushed the only-use-default-tenant-in-session-if-successful branch from e1ac486 to 08a1948 Compare March 20, 2023 18:27
Copy link
Collaborator Author

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

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

LGTM, but could you also help me understand what happens (in terms of UX) if login doesn't succeed on any of the tenants at all?

Good reminder. I checked and the error messages weren't passing through so I added that in to retain the feedback in the UI.

Additionally, I changed the fanout login to always do so on login because otherwise existing sessions would make things work oddly. For instance, clicking the demo login link would overwrite a multi-tenant session with one that was just for a single tenant and the dropdown would disappear.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dhartunian)

@dhartunian dhartunian added the backport-23.1.x Flags PRs that need to be backported to 23.1 label Mar 21, 2023
@dhartunian
Copy link
Collaborator Author

bors r=knz

@craig
Copy link
Contributor

craig bot commented Mar 22, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Mar 22, 2023

Build failed (retrying...):

@yuzefovich
Copy link
Member

The new test seems to be flaky (failed on bors and in extended CI).

bors r-

@craig
Copy link
Contributor

craig bot commented Mar 22, 2023

Canceled.

@dhartunian dhartunian force-pushed the only-use-default-tenant-in-session-if-successful branch 3 times, most recently from 167d18f to 5a918a7 Compare March 29, 2023 14:21
Previously, we would always set the default tenant cookie to the
default tenant cluster setting regardless of what tenants the user
logged-in to successfully.

This change ensures that the default tenant selection is only used
when the successful logins include that tenant. Otherwise, we select
the first tenant from the list of successful logins.

Always fanout login requests to ensure that an existing session
doesn't prevent login from proceeding. Otherwise a multi-tenant
session can get clobbered by a single-tenant one.

Include errors from failed login requests in the error repsonse so
that users can see the error message in the Login box on DB Console.
Otherwise it's blank.

Epic: CRDB-12100
Release note: None
@dhartunian dhartunian force-pushed the only-use-default-tenant-in-session-if-successful branch from 5a918a7 to e883c70 Compare March 30, 2023 03:43
@dhartunian
Copy link
Collaborator Author

bors r=knz

@craig
Copy link
Contributor

craig bot commented Mar 30, 2023

Build succeeded:

@craig craig bot merged commit f9ac216 into cockroachdb:master Mar 30, 2023
@dhartunian dhartunian deleted the only-use-default-tenant-in-session-if-successful branch February 5, 2024 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants