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

Auth: Set the default org after User login #83918

Merged
merged 14 commits into from Mar 12, 2024

Conversation

mgyongyosi
Copy link
Contributor

What is this feature?
This PR adds the ability to set the default organization the user will see after successful login when the User is assigned to multiple Grafana organizations.

Why do we need this feature?

Who is this feature for?

Which issue(s) does this PR fix?:

Fixes #

Special notes for your reviewer:

Please test it on HG with /deploy-to-hg before merging the PR.

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@mgyongyosi
Copy link
Contributor Author

/deploy-to-hg

@ephemeral-instances-bot
Copy link

  • Preparing your instance. A comment containing your instance's url will be added to this PR when the instance is ready.
  • Your instance will be ready in ~10 minutes.
  • Check the GitHub actions tab to follow the workflow progress
  • Slack channel: #proj-ephemeral-hg-instances
  • Building instance with mgyongyosi/default-org-setting oss branch and main enterprise branch. How to choose a branch

@mgyongyosi
Copy link
Contributor Author

/deploy-to-hg

@ephemeral-instances-bot
Copy link

  • Preparing your instance. A comment containing your instance's url will be added to this PR when the instance is ready.
  • Your instance will be ready in ~10 minutes.
  • Check the GitHub actions tab to follow the workflow progress
  • Slack channel: #proj-ephemeral-hg-instances
  • Building instance with mgyongyosi/default-org-setting oss branch and main enterprise branch. How to choose a branch

@ephemeral-instances-bot
Copy link

pkg/services/authn/authnimpl/hook/default_org_hook.go Outdated Show resolved Hide resolved
conf/defaults.ini Outdated Show resolved Hide resolved
pkg/services/authn/authnimpl/hook/default_org_hook.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@chri2547 chri2547 left a comment

Choose a reason for hiding this comment

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

One small docs nit. Otherwise, docs approved. Thanks for the contribution.

mgyongyosi and others added 3 commits March 9, 2024 19:22
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
@mgyongyosi mgyongyosi requested a review from kalleep March 11, 2024 08:47
@mgyongyosi
Copy link
Contributor Author

/deploy-to-hg

@ephemeral-instances-bot
Copy link

  • Preparing your instance. A comment containing your instance's url will be added to this PR when the instance is ready.
  • Your instance will be ready in ~10 minutes.
  • Check the GitHub actions tab to follow the workflow progress
  • Slack channel: #proj-ephemeral-hg-instances
  • Building instance with mgyongyosi/default-org-setting oss branch and main enterprise branch. How to choose a branch

pkg/services/authn/authnimpl/sync/org_sync.go Outdated Show resolved Hide resolved
Comment on lines 171 to 173
if err != nil {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not ignore error here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed, validateUsingOrgs returns the error from GetUserOrgList, the hook logs the error and skips setting the default org (same logic that is in SyncOrgRolesHook).

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
@ephemeral-instances-bot
Copy link

@mgyongyosi mgyongyosi merged commit 63f1c30 into main Mar 12, 2024
13 checks passed
@mgyongyosi mgyongyosi deleted the mgyongyosi/default-org-setting branch March 12, 2024 08:35
@grafana grafana deleted a comment from ephemeral-instances-bot bot Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants