mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LDAP: FIX Enable users on successfull login (#75073)
* LDAP: Enable users on successfull login * Force enable ldap users on successful login * Fix tests * Fix tests
This commit is contained in:
parent
0884f78110
commit
c8149d50f9
@ -107,7 +107,7 @@ func (c *LDAP) disableUser(ctx context.Context, username string) (*authn.Identit
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *LDAP) identityFromLDAPInfo(orgID int64, info *login.ExternalUserInfo) *authn.Identity {
|
func (c *LDAP) identityFromLDAPInfo(orgID int64, info *login.ExternalUserInfo) *authn.Identity {
|
||||||
return &authn.Identity{
|
id := &authn.Identity{
|
||||||
OrgID: orgID,
|
OrgID: orgID,
|
||||||
OrgRoles: info.OrgRoles,
|
OrgRoles: info.OrgRoles,
|
||||||
Login: info.Login,
|
Login: info.Login,
|
||||||
@ -131,4 +131,12 @@ func (c *LDAP) identityFromLDAPInfo(orgID int64, info *login.ExternalUserInfo) *
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The ldap service is not aware of the internal state of the user. Fetching the user
|
||||||
|
// from the store to know if that user is disabled or not, is almost as costly as
|
||||||
|
// running an update systematically. We are setting IsDisabled to true so that the
|
||||||
|
// EnableDisabledUserHook force-enable that user.
|
||||||
|
id.IsDisabled = true
|
||||||
|
|
||||||
|
return id
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ func TestLDAP_AuthenticateProxy(t *testing.T) {
|
|||||||
AuthenticatedBy: login.LDAPAuthModule,
|
AuthenticatedBy: login.LDAPAuthModule,
|
||||||
AuthID: "123",
|
AuthID: "123",
|
||||||
Groups: []string{"1", "2"},
|
Groups: []string{"1", "2"},
|
||||||
|
IsDisabled: true, // Users are marked as disabled to force enablement on successful login
|
||||||
ClientParams: authn.ClientParams{
|
ClientParams: authn.ClientParams{
|
||||||
SyncUser: true,
|
SyncUser: true,
|
||||||
SyncTeams: true,
|
SyncTeams: true,
|
||||||
@ -129,6 +130,7 @@ func TestLDAP_AuthenticatePassword(t *testing.T) {
|
|||||||
AuthenticatedBy: login.LDAPAuthModule,
|
AuthenticatedBy: login.LDAPAuthModule,
|
||||||
AuthID: "123",
|
AuthID: "123",
|
||||||
Groups: []string{"1", "2"},
|
Groups: []string{"1", "2"},
|
||||||
|
IsDisabled: true, // Users are marked as disabled to force enablement on successful login
|
||||||
ClientParams: authn.ClientParams{
|
ClientParams: authn.ClientParams{
|
||||||
SyncUser: true,
|
SyncUser: true,
|
||||||
SyncTeams: true,
|
SyncTeams: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user