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

LDAP: Fix LDAP users authenticated via auth proxy not being able to use LDAP active sync #83715

Merged
merged 4 commits into from
Mar 1, 2024

Conversation

Jguer
Copy link
Contributor

@Jguer Jguer commented Feb 29, 2024

What is this feature?

Users authenticated with auth proxy via the LDAP client were being stored as auth_proxy (grafana db) users instead of ldap users.

The changes to the auth client should gradually fix this users to have an LDAP entry instead.

(Possible research avenue into changing behavior of search to ignore the latest login method used)

SELECT id from user_auth

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 #

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.

@Jguer Jguer added type/bug backport v10.3.x Mark PR for automatic backport to v10.3.x backport v10.4.x labels Feb 29, 2024
@Jguer Jguer requested a review from kalleep February 29, 2024 17:26
@Jguer Jguer self-assigned this Feb 29, 2024
@Jguer Jguer requested a review from a team as a code owner February 29, 2024 17:26
@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.0.x milestone Feb 29, 2024
Copy link
Contributor

This PR must be merged before a backport PR will be created.

2 similar comments
Copy link
Contributor

This PR must be merged before a backport PR will be created.

Copy link
Contributor

This PR must be merged before a backport PR will be created.

@Jguer Jguer changed the title LDAP: fix LDAP users authenticated via auth proxy not being able to use ldap sync LDAP: Fix LDAP users authenticated via auth proxy not being able to use LDAP active sync Feb 29, 2024
Comment on lines 107 to 114
// Get the authentication information for the user
authedBy, err := c.authInfoService.GetAuthInfo(ctx, &login.GetAuthInfoQuery{UserId: usr.UserID})
if err != nil || authedBy == nil {
c.log.FromContext(ctx).Warn("Cached user had no valid auth info", "error", err, "userId", string(entry))
} else {
c.log.FromContext(ctx).Debug("User was loaded from cache, skip syncs", "userId", usr.UserID)
return authn.IdentityFromSignedInUser(authn.NamespacedID(authn.NamespaceUser, usr.UserID), usr, authn.ClientParams{SyncPermissions: true}, authedBy.AuthModule), nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this part. We are not doing any syncing.

If we want to always display the correct authenticated by, even when using session, maybe this should be part of user fetch hook instead. Otherwise only auth proxy would always display this info correctly

Then we should probably use that hook to fetch all user info instead of doing it manually 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.

👍 let me see how that looks like

Copy link
Contributor

@kalleep kalleep left a comment

Choose a reason for hiding this comment

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

Looks good just a question / suggestion before we merge this

@Jguer Jguer requested a review from a team as a code owner March 1, 2024 08:15
@Jguer Jguer requested review from zserge, mildwonkey and idafurjes and removed request for a team March 1, 2024 08:15
@Jguer Jguer merged commit 2182cc4 into main Mar 1, 2024
12 checks passed
@Jguer Jguer deleted the jguer/fix-auth-proxy-ldap-and-ldap-sync branch March 1, 2024 09:14
grafana-delivery-bot bot pushed a commit that referenced this pull request Mar 1, 2024
…se LDAP active sync (#83715)

* fix LDAP users authenticated via auth proxy not being able to use ldap sync

* simplify id resolution at the cost of no fallthrough

* remove unused services

* remove unused cache key

(cherry picked from commit 2182cc4)
grafana-delivery-bot bot pushed a commit that referenced this pull request Mar 1, 2024
…se LDAP active sync (#83715)

* fix LDAP users authenticated via auth proxy not being able to use ldap sync

* simplify id resolution at the cost of no fallthrough

* remove unused services

* remove unused cache key

(cherry picked from commit 2182cc4)
Jguer added a commit that referenced this pull request Mar 1, 2024
… able to use LDAP active sync (#83751)

LDAP: Fix LDAP users authenticated via auth proxy not being able to use LDAP active sync (#83715)

* fix LDAP users authenticated via auth proxy not being able to use ldap sync

* simplify id resolution at the cost of no fallthrough

* remove unused services

* remove unused cache key

(cherry picked from commit 2182cc4)

Co-authored-by: Jo <joao.guerreiro@grafana.com>
Jguer added a commit that referenced this pull request Mar 1, 2024
… able to use LDAP active sync (#83750)

LDAP: Fix LDAP users authenticated via auth proxy not being able to use LDAP active sync (#83715)

* fix LDAP users authenticated via auth proxy not being able to use ldap sync

* simplify id resolution at the cost of no fallthrough

* remove unused services

* remove unused cache key

(cherry picked from commit 2182cc4)

Co-authored-by: Jo <joao.guerreiro@grafana.com>
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

3 participants