From de290cf6a591ef84e09b19b1980672517c2898d5 Mon Sep 17 00:00:00 2001 From: Misi Date: Fri, 10 Jan 2025 14:21:16 +0100 Subject: [PATCH] Auth: Fallback to default client authentication setting in AzureAD OAuth (#98798) Fallback to default client authentication setting for backwards compatibility --- pkg/login/social/connectors/azuread_oauth.go | 3 +-- public/app/features/auth-config/FieldRenderer.tsx | 7 +++++++ public/app/features/auth-config/utils/data.ts | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/login/social/connectors/azuread_oauth.go b/pkg/login/social/connectors/azuread_oauth.go index c6b8691f4c7..cd2e81367b5 100644 --- a/pkg/login/social/connectors/azuread_oauth.go +++ b/pkg/login/social/connectors/azuread_oauth.go @@ -198,9 +198,8 @@ func (s *SocialAzureAD) Exchange(ctx context.Context, code string, authOptions . case social.ClientSecretPost: // Default behavior for ClientSecretPost, no additional setup needed - default: - return nil, fmt.Errorf("invalid client authentication method: %s", s.info.ClientAuthentication) + s.log.Debug("ClientAuthentication is not set. Using default client authentication method") } // Default token exchange diff --git a/public/app/features/auth-config/FieldRenderer.tsx b/public/app/features/auth-config/FieldRenderer.tsx index ce870c7fef4..de12cc004bf 100644 --- a/public/app/features/auth-config/FieldRenderer.tsx +++ b/public/app/features/auth-config/FieldRenderer.tsx @@ -42,6 +42,13 @@ export const FieldRenderer = ({ } }, [unregister, name, parentValue, isDependantField]); + useEffect(() => { + if (fieldData.defaultValue) { + setValue(name, fieldData.defaultValue.value); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + if (!field) { console.log('missing field:', name); return null; diff --git a/public/app/features/auth-config/utils/data.ts b/public/app/features/auth-config/utils/data.ts index 9b610a3cc82..47ed8112ab0 100644 --- a/public/app/features/auth-config/utils/data.ts +++ b/public/app/features/auth-config/utils/data.ts @@ -15,8 +15,11 @@ export const emptySettings: SSOProviderDTO = { authStyle: '', authUrl: '', autoLogin: false, + clientAuthentication: '', clientId: '', clientSecret: '', + managedIdentityClientId: '', + federatedCredentialAudience: '', emailAttributeName: '', emailAttributePath: '', emptyScopes: false,