AuthN: add flag for org roles sync (#63507)

* AuthN: Add flag to control org role syncs

* JWT: Only sync org roles if the skip flag for jwt is false

* LDAP: Only sync org role if skip flag for ldap is false

* OAuth: Skip org roles sync if no roles were provided by upstream service

* Grafana: Set SyncOrgRoles to true for authentication through proxy with grafana as backend
This commit is contained in:
Karl Persson
2023-02-22 10:27:48 +01:00
committed by GitHub
parent 1e84d5d93c
commit 207a55be66
12 changed files with 92 additions and 74 deletions

View File

@@ -25,7 +25,7 @@ type OrgSync struct {
}
func (s *OrgSync) SyncOrgRolesHook(ctx context.Context, id *authn.Identity, _ *authn.Request) error {
if !id.ClientParams.SyncUser {
if !id.ClientParams.SyncOrgRoles {
return nil
}

View File

@@ -79,7 +79,7 @@ func TestOrgSync_SyncOrgRolesHook(t *testing.T) {
OrgRoles: map[int64]roletype.RoleType{1: org.RoleAdmin, 2: org.RoleEditor},
IsGrafanaAdmin: ptrBool(false),
ClientParams: authn.ClientParams{
SyncUser: true,
SyncOrgRoles: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: ptrString("test"),
@@ -97,7 +97,7 @@ func TestOrgSync_SyncOrgRolesHook(t *testing.T) {
OrgID: 1, //set using org
IsGrafanaAdmin: ptrBool(false),
ClientParams: authn.ClientParams{
SyncUser: true,
SyncOrgRoles: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: ptrString("test"),