Browse Source

Add ArcGIS Online to the list of supported providers

pull/1718/head
Kévin Chalet 3 years ago
parent
commit
bedba2a992
  1. 36
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs
  2. 24
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml

36
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs

@ -26,6 +26,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers
*/ */
AttachRequestHeaders.Descriptor, AttachRequestHeaders.Descriptor,
AttachAccessTokenParameter.Descriptor, AttachAccessTokenParameter.Descriptor,
AttachNonStandardParameters.Descriptor,
/* /*
* Userinfo response extraction: * Userinfo response extraction:
@ -125,6 +126,41 @@ public static partial class OpenIddictClientWebIntegrationHandlers
} }
} }
/// <summary>
/// Contains the logic responsible for attaching non-standard
/// parameters to the request for the providers that require it.
/// </summary>
public sealed class AttachNonStandardParameters : IOpenIddictClientHandler<PrepareUserinfoRequestContext>
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<PrepareUserinfoRequestContext>()
.UseSingletonHandler<AttachNonStandardParameters>()
.SetOrder(AttachQueryStringParameters<PrepareUserinfoRequestContext>.Descriptor.Order - 250)
.SetType(OpenIddictClientHandlerType.BuiltIn)
.Build();
/// <inheritdoc/>
public ValueTask HandleAsync(PrepareUserinfoRequestContext context)
{
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
// ArcGIS Online doesn't support header-based content negotiation and requires using
// the non-standard "f" parameter to get back JSON responses instead of HTML pages.
if (context.Registration.ProviderName is Providers.ArcGisOnline)
{
context.Request["f"] = "json";
}
return default;
}
}
/// <summary> /// <summary>
/// Contains the logic responsible for normalizing the returned content /// Contains the logic responsible for normalizing the returned content
/// type of userinfo responses for the providers that require it. /// type of userinfo responses for the providers that require it.

24
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml

@ -29,6 +29,30 @@
Description="The optional value used as the 'resource' parameter (e.g urn:microsoft:userinfo)" /> Description="The optional value used as the 'resource' parameter (e.g urn:microsoft:userinfo)" />
</Provider> </Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█ ▄▄▀██ ▄▄▀██ ▄▄▀██ ▄▄ █▄ ▄██ ▄▄▄ ████ ▄▄▄ ██ ▀██ ██ ████▄ ▄██ ▀██ ██ ▄▄▄██
█ ▀▀ ██ ▀▀▄██ █████ █▀▀██ ███▄▄▄▀▀████ ███ ██ █ █ ██ █████ ███ █ █ ██ ▄▄▄██
█ ██ ██ ██ ██ ▀▀▄██ ▀▀▄█▀ ▀██ ▀▀▀ ████ ▀▀▀ ██ ██▄ ██ ▀▀ █▀ ▀██ ██▄ ██ ▀▀▀██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="ArcGisOnline" DisplayName="ArcGIS Online"
Documentation="https://developers.arcgis.com/documentation/mapping-apis-and-services/security/oauth-2.0/">
<Environment Issuer="https://www.arcgis.com/">
<Configuration AuthorizationEndpoint="https://www.arcgis.com/sharing/rest/oauth2/authorize"
TokenEndpoint="https://www.arcgis.com/sharing/rest/oauth2/token"
UserinfoEndpoint="https://www.arcgis.com/sharing/rest/community/self">
<CodeChallengeMethod Value="plain" />
<CodeChallengeMethod Value="S256" />
<GrantType Value="authorization_code" />
<GrantType Value="client_credentials" />
<GrantType Value="refresh_token" />
</Configuration>
</Environment>
</Provider>
<!-- <!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█ ▄▄▀██ ▄▄ ██ ▄▄ ██ █████ ▄▄▄██ █ ▄▄▀██ ▄▄ ██ ▄▄ ██ █████ ▄▄▄██

Loading…
Cancel
Save