From 8f2ee984d25dca634b49548c685f779e10e28547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 20 Feb 2023 18:15:20 +0100 Subject: [PATCH] Update the ADFS provider to support configuring the requested resources --- .../OpenIddictClientSystemIntegrationHandlers.cs | 2 +- .../OpenIddictClientWebIntegrationHandlers.cs | 9 +++++++++ .../OpenIddictClientWebIntegrationProviders.xml | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs index c7ce6f8e..ccf4d1a3 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs @@ -1321,7 +1321,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers = OpenIddictClientHandlerDescriptor.CreateBuilder() .AddFilter() .UseSingletonHandler() - .SetOrder(SendUserinfoRequest.Descriptor.Order + 500) + .SetOrder(ValidateUserinfoTokenSubject.Descriptor.Order + 500) .SetType(OpenIddictClientHandlerType.BuiltIn) .Build(); diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs index 7b47c129..dd830fd0 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs @@ -673,6 +673,15 @@ public static partial class OpenIddictClientWebIntegrationHandlers throw new ArgumentNullException(nameof(context)); } + // Active Directory Federation Services allows sending a custom "resource" + // parameter to define what API resources the access token will give access to. + if (context.Registration.ProviderName is Providers.ActiveDirectoryFederationServices) + { + var options = context.Registration.GetActiveDirectoryFederationServicesOptions(); + + context.Request["resource"] = options.Resource; + } + // By default, Google doesn't return a refresh token but allows sending an "access_type" // parameter to retrieve one (but it is only returned during the first authorization dance). if (context.Registration.ProviderName is Providers.Google) diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml index 9fc27b13..2ddab692 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml @@ -24,6 +24,9 @@ + + +