From 74760e3e9ff8912c503cc0ddd66b4baf6075a9dd Mon Sep 17 00:00:00 2001 From: Joel Verhagen Date: Wed, 4 Jan 2023 18:05:16 -0500 Subject: [PATCH 1/3] Remove the client secret from AAD V2 authenticator We were only ever using the id_token which contains enough detail for NuGet.org sign in. The code response is not used. Progress on https://github.com/NuGet/Engineering/issues/4099 --- .../AzureActiveDirectoryV2Authenticator.cs | 15 ++++++++++++--- ...ActiveDirectoryV2AuthenticatorConfiguration.cs | 12 +----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2Authenticator.cs b/src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2Authenticator.cs index d63331ed2f..dc2a60613d 100644 --- a/src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2Authenticator.cs +++ b/src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2Authenticator.cs @@ -101,12 +101,13 @@ protected override void AttachToOwinApp(IGalleryConfigurationService config, IAp RedirectUri = siteRoot + _callbackPath, PostLogoutRedirectUri = siteRoot, Scope = OpenIdConnectScope.OpenIdProfile + " email", - ResponseType = OpenIdConnectResponseType.CodeIdToken, + ResponseType = OpenIdConnectResponseType.IdToken, TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() { ValidateIssuer = false }, Notifications = new OpenIdConnectAuthenticationNotifications { AuthenticationFailed = AuthenticationFailed, - RedirectToIdentityProvider = RedirectToIdentityProvider + RedirectToIdentityProvider = RedirectToIdentityProvider, + AuthorizationCodeReceived = AuthorizationCodeReceived, } }; @@ -257,7 +258,7 @@ private Task RedirectToIdentityProvider(RedirectToIdentityProviderNotification Date: Wed, 4 Jan 2023 20:04:30 -0500 Subject: [PATCH 2/3] Remove secret config --- src/NuGetGallery/Web.config | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NuGetGallery/Web.config b/src/NuGetGallery/Web.config index c622639fb5..db6bd8ee50 100644 --- a/src/NuGetGallery/Web.config +++ b/src/NuGetGallery/Web.config @@ -101,7 +101,6 @@ - From d648bf9dc4d5a60eb7daf97fd6833c61575e6702 Mon Sep 17 00:00:00 2001 From: Joel Verhagen Date: Wed, 4 Jan 2023 20:05:21 -0500 Subject: [PATCH 3/3] Fix comment --- .../AzureActiveDirectoryV2AuthenticatorConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2AuthenticatorConfiguration.cs b/src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2AuthenticatorConfiguration.cs index 04a405a7b7..f0a954f5d1 100644 --- a/src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2AuthenticatorConfiguration.cs +++ b/src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2AuthenticatorConfiguration.cs @@ -30,7 +30,7 @@ public override void ApplyToOwinSecurityOptions(AuthenticationOptions options) // the auth flow. openIdOptions.AuthenticationMode = AuthenticationMode.Passive; - // Make sure ClientId + // Make sure ClientId is configured if (String.IsNullOrEmpty(ClientId)) { throw new ConfigurationErrorsException(String.Format(