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: auto assign org id when logging in with ldap #80470

Closed
wants to merge 5 commits into from

Conversation

dmihai
Copy link
Contributor

@dmihai dmihai commented Jan 12, 2024

What is this feature?

Use AutoAssignOrgId from config as default org.

Why do we need this feature?

[Add a description of the problem the feature is trying to solve.]

Who is this feature for?

[Add information on what kind of user the feature is for.]

Which issue(s) does this PR fix?:

Fixes https://github.com/grafana/support-escalations/issues/8661.

Special notes for your reviewer:

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.

@grafana-delivery-bot grafana-delivery-bot bot added this to the 10.4.x milestone Jan 12, 2024
@dmihai dmihai changed the title Auth: auto assign org on authenticate Auth: auto assign org id when logging in with ldap Jan 16, 2024
Email: id.Email,
Name: id.Name,
IsAdmin: isAdmin,
OrgID: id.OrgID,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing it's because we assume the user orgs will be handled in https://github.com/grafana/grafana/blob/63cd5a5625c22dcb5603b10d54228363bcaa70a6/pkg/services/authn/authnimpl/sync/org_sync.go ?

Can't think right now of side effects of this

Copy link
Contributor

Choose a reason for hiding this comment

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

Me neither. But I think we need to set SkipOrgSetup: len(id.OrgRoles) > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I'm setting SkipOrgSetup then the org id won't be auto assigned with the value from the ini file. Maybe we can come up with a better condition here, something like len(id.OrgRoles) > 0 and id is not coming from ldap, but I don't know if we can do that.

Comment on lines 124 to 128
orgID := r.OrgID
if orgID == 0 {
orgID = identity.OrgID
}

Copy link
Contributor

@kalleep kalleep Jan 19, 2024

Choose a reason for hiding this comment

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

This can probably break some things, I think orgID = 0 is used in some global contexts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made some tests without this part and it seems to be working as well. I think I can remove it and leave only the changes from the s.userService.Create func parameters from this file.

@aangelisc aangelisc modified the milestones: 10.4.x, 11.0.x Feb 20, 2024
@dmihai
Copy link
Contributor Author

dmihai commented Mar 12, 2024

Closed in favour of #83918.

@dmihai dmihai closed this Mar 12, 2024
@grafana-delivery-bot grafana-delivery-bot bot removed this from the 11.0.x milestone Mar 12, 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

4 participants