OAuth: Enforce auto_assign_org_id setting when role mapping enabled using Generic OAuth (#22268)

* OAuth: Make use of auto_assign_org_id setting
This commit is contained in:
Arve Knudsen
2020-02-19 17:38:53 +01:00
committed by GitHub
parent 4c282c538a
commit 8d1bef3769
2 changed files with 17 additions and 16 deletions

View File

@@ -186,7 +186,13 @@ func (hs *HTTPServer) OAuthLogin(ctx *m.ReqContext) {
if userInfo.Role != "" {
rt := m.RoleType(userInfo.Role)
if rt.IsValid() {
extUser.OrgRoles[1] = rt
var orgID int64
if setting.AutoAssignOrg && setting.AutoAssignOrgId > 0 {
orgID = int64(setting.AutoAssignOrgId)
} else {
orgID = int64(1)
}
extUser.OrgRoles[orgID] = rt
}
}