mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
Authn: allow ResolveIdentity to authenticate in "global" scope (#85835)
* Authn: allow ResolveIdentity to authenticate in "global" scope * Use constant
This commit is contained in:
parent
a3ed1855ff
commit
ebb4bb859e
@ -59,6 +59,8 @@ type ClientParams struct {
|
||||
SyncPermissions bool
|
||||
// FetchPermissionsParams are the arguments used to fetch permissions from the DB
|
||||
FetchPermissionsParams FetchPermissionsParams
|
||||
// AllowGlobalOrg would allow a client to authenticate in global scope AKA org 0
|
||||
AllowGlobalOrg bool
|
||||
}
|
||||
|
||||
type FetchPermissionsParams struct {
|
||||
|
@ -132,6 +132,13 @@ func (s *UserSync) FetchSyncedUserHook(ctx context.Context, identity *authn.Iden
|
||||
return errFetchingSignedInUser.Errorf("failed to resolve user: %w", err)
|
||||
}
|
||||
|
||||
if identity.ClientParams.AllowGlobalOrg && identity.OrgID == authn.GlobalOrgID {
|
||||
usr.Teams = nil
|
||||
usr.OrgName = ""
|
||||
usr.OrgRole = org.RoleNone
|
||||
usr.OrgID = authn.GlobalOrgID
|
||||
}
|
||||
|
||||
syncSignedInUserToIdentity(usr, identity)
|
||||
return nil
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ func (i *IdentityClient) Authenticate(ctx context.Context, r *authn.Request) (*a
|
||||
OrgID: r.OrgID,
|
||||
ID: i.namespaceID,
|
||||
ClientParams: authn.ClientParams{
|
||||
AllowGlobalOrg: true,
|
||||
FetchSyncedUser: true,
|
||||
SyncPermissions: true,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user