Auth: Add skip_org_role_sync to GitLab OAuth (#62055)

* Auth: Add skip_org_role_sync to GitLab OAuth

- add: tests
- docs added

* Update pkg/login/social/gitlab_oauth.go

Co-authored-by: Karl Persson <kalle.persson@grafana.com>

* fix: for import

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
This commit is contained in:
Eric Leijonmarck
2023-01-25 13:39:54 +01:00
committed by GitHub
parent 5f6616ff3e
commit 143ee0c49f
11 changed files with 85 additions and 13 deletions

View File

@@ -39,7 +39,7 @@ interface OwnProps extends GrafanaRouteComponentProps<{ id: string }> {
error?: UserAdminError;
}
const SyncedOAuthLabels: string[] = ['GitHub', 'GitLab', 'OAuth'];
const SyncedOAuthLabels: string[] = ['GitHub', 'OAuth'];
export class UserAdminPage extends PureComponent<Props> {
async componentDidMount() {
@@ -113,6 +113,7 @@ export class UserAdminPage extends PureComponent<Props> {
user?.isExternal && user?.authLabels?.some((r) => SyncedOAuthLabels.includes(r));
const isSAMLUser = user?.isExternal && user?.authLabels?.includes('SAML');
const isGoogleUser = user?.isExternal && user?.authLabels?.includes('Google');
const isGitLabUser = user?.isExternal && user?.authLabels?.includes('GitLab');
const isAuthProxyUser = user?.isExternal && user?.authLabels?.includes('Auth Proxy');
const isAzureADUser = user?.isExternal && user?.authLabels?.includes('AzureAD');
const isGrafanaComUser = user?.isExternal && user?.authLabels?.includes('grafana.com');
@@ -122,6 +123,7 @@ export class UserAdminPage extends PureComponent<Props> {
!(
isAuthProxyUser ||
isGoogleUser ||
isGitLabUser ||
isOAuthUserWithSkippableSync ||
isSAMLUser ||
isLDAPUser ||
@@ -136,6 +138,7 @@ export class UserAdminPage extends PureComponent<Props> {
// both OAuthSkipOrgRoleUpdateSync and specific provider settings needs to be false for a user to be synced
(!config.auth.OAuthSkipOrgRoleUpdateSync && !config.auth.GrafanaComSkipOrgRoleSync && isGrafanaComUser) ||
(!config.auth.OAuthSkipOrgRoleUpdateSync && !config.auth.AzureADSkipOrgRoleSync && isAzureADUser) ||
(!config.auth.OAuthSkipOrgRoleUpdateSync && !config.auth.GitLabSkipOrgRoleSync && isGitLabUser) ||
(!config.auth.OAuthSkipOrgRoleUpdateSync && !config.auth.GoogleSkipOrgRoleSync && isGoogleUser));
const pageNav: NavModelItem = {