Browse Source

Update the web providers generator to support optional display names

pull/1667/head
Kévin Chalet 3 years ago
parent
commit
2d22e67c3e
  1. 27
      gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
  2. 15
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml
  3. 10
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xsd

27
gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs

@ -67,7 +67,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
{
{{~ for provider in providers ~}}
/// <summary>
/// Enables the {{ provider.name }} integration and registers the associated services in the DI container.
/// Enables the {{ provider.display_name }} integration and registers the associated services in the DI container.
{{~ if provider.documentation ~}}
/// For more information, read <see href=""{{ provider.documentation }}"">the documentation</see>.
/// </summary>
@ -89,13 +89,13 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
}
/// <summary>
/// Enables the {{ provider.name }} integration and registers the associated services in the DI container.
/// Enables the {{ provider.display_name }} integration and registers the associated services in the DI container.
{{~ if provider.documentation ~}}
/// For more information, read <see href=""{{ provider.documentation }}"">the documentation</see>.
/// </summary>
{{~ end ~}}
/// <remarks>This extension can be safely called multiple times.</remarks>
/// <param name=""configuration"">The delegate used to configure the OpenIddict/{{ provider.name }} options.</param>
/// <param name=""configuration"">The delegate used to configure the OpenIddict/{{ provider.display_name }} options.</param>
/// <returns>The <see cref=""OpenIddictClientWebIntegrationBuilder""/> instance.</returns>
public OpenIddictClientWebIntegrationBuilder Use{{ provider.name }}(Action<OpenIddictClientWebIntegrationBuilder.{{ provider.name }}> configuration)
{
@ -112,7 +112,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
{{~ for provider in providers ~}}
/// <summary>
/// Exposes the necessary methods required to configure the {{ provider.name }} integration.
/// Exposes the necessary methods required to configure the {{ provider.display_name }} integration.
/// </summary>
public sealed partial class {{ provider.name }}
{
@ -130,7 +130,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
public IServiceCollection Services { get; }
/// <summary>
/// Amends the default OpenIddict client {{ provider.name }} configuration.
/// Amends the default OpenIddict client {{ provider.display_name }} configuration.
/// </summary>
/// <param name=""configuration"">The delegate used to configure the OpenIddict options.</param>
/// <remarks>This extension can be safely called multiple times.</remarks>
@ -596,6 +596,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
.Select(provider => new
{
Name = (string) provider.Attribute("Name"),
DisplayName = (string?) provider.Attribute("DisplayName") ?? (string) provider.Attribute("Name"),
Documentation = (string?) provider.Attribute("Documentation"),
Environments = provider.Elements("Environment").Select(environment => new
@ -701,7 +702,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration
{
{{~ for provider in providers ~}}
/// <summary>
/// Contains the methods required to register the {{ provider.name }} integration in the OpenIddict client options.
/// Contains the methods required to register the {{ provider.display_name }} integration in the OpenIddict client options.
/// </summary>
public sealed class {{ provider.name }} : IConfigureOptions<OpenIddictClientOptions>,
IPostConfigureOptions<OpenIddictClientWebIntegrationOptions.{{ provider.name }}>
@ -938,6 +939,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration
.Select(provider => new
{
Name = (string) provider.Attribute("Name"),
DisplayName = (string?) provider.Attribute("DisplayName") ?? (string) provider.Attribute("Name"),
Environments = provider.Elements("Environment").Select(environment => new
{
@ -1058,10 +1060,10 @@ public static partial class OpenIddictClientWebIntegrationHelpers
{
{{~ for provider in providers ~}}
/// <summary>
/// Resolves the {{ provider.name }} provider options from the specified registration.
/// Resolves the {{ provider.display_name }} provider options from the specified registration.
/// </summary>
/// <param name=""registration"">The client registration.</param>
/// <returns>The {{ provider.name }} provider options.</returns>
/// <returns>The {{ provider.display_name }} provider options.</returns>
/// <exception cref=""InvalidOperationException"">The provider options cannot be resolved.</exception>
public static OpenIddictClientWebIntegrationOptions.{{ provider.name }} Get{{ provider.name }}Options(this OpenIddictClientRegistration registration)
=> registration.ProviderOptions is OpenIddictClientWebIntegrationOptions.{{ provider.name }} options ? options :
@ -1073,7 +1075,11 @@ public static partial class OpenIddictClientWebIntegrationHelpers
return template.Render(new
{
Providers = document.Root.Elements("Provider")
.Select(provider => new { Name = (string) provider.Attribute("Name") })
.Select(provider => new
{
Name = (string) provider.Attribute("Name"),
DisplayName = (string?) provider.Attribute("DisplayName") ?? (string) provider.Attribute("Name")
})
.ToList()
});
}
@ -1091,7 +1097,7 @@ public sealed partial class OpenIddictClientWebIntegrationOptions
{
{{~ for provider in providers ~}}
/// <summary>
/// Provides various options needed to configure the {{ provider.name }} integration.
/// Provides various options needed to configure the {{ provider.display_name }} integration.
/// </summary>
public sealed class {{ provider.name }}
{
@ -1154,6 +1160,7 @@ public sealed partial class OpenIddictClientWebIntegrationOptions
.Select(provider => new
{
Name = (string) provider.Attribute("Name"),
DisplayName = (string?) provider.Attribute("DisplayName") ?? (string) provider.Attribute("Name"),
Settings = provider.Elements("Setting").Select(setting => new
{

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

@ -13,7 +13,8 @@
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="Apple" Documentation="https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api">
<Provider Name="Apple" DisplayName="Sign in with Apple"
Documentation="https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api">
<Environment Issuer="https://appleid.apple.com/" />
<Setting PropertyName="SigningKey" ParameterName="key" Type="SigningKey" Required="true"
@ -33,7 +34,8 @@
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="Cognito" Documentation="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-reference.html">
<Provider Name="Cognito" DisplayName="Amazon Cognito"
Documentation="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-reference.html">
<Environment Issuer="https://cognito-idp.{region}.amazonaws.com/{userPoolId}" />
<Setting PropertyName="Region" ParameterName="region" Type="String" Required="true"
@ -163,7 +165,8 @@
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="Microsoft" Documentation="https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc">
<Provider Name="Microsoft" DisplayName="Microsoft Account/Azure Active Directory"
Documentation="https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc">
<!--
Note: Microsoft is a multitenant provider that relies on virtual paths to identify instances.
As such, the issuer includes a {tenant} placeholder that will be dynamically replaced
@ -222,7 +225,8 @@
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="ProSantéConnect" Documentation="https://industriels.esante.gouv.fr/en/products-services/health-pro-authentication-pro-sante-connect">
<Provider Name="ProSantéConnect" DisplayName="Pro Santé Connect"
Documentation="https://industriels.esante.gouv.fr/en/products-services/health-pro-authentication-pro-sante-connect">
<!--
Note: Pro Santé Connect requires sending the "scope_all" scope (which is currently the only supported value).
-->
@ -286,7 +290,8 @@
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="StackExchange" Documentation="https://api.stackexchange.com/docs/authentication">
<Provider Name="StackExchange" DisplayName="Stack Exchange"
Documentation="https://api.stackexchange.com/docs/authentication">
<Environment Issuer="https://api.stackexchange.com/">
<Configuration AuthorizationEndpoint="https://stackoverflow.com/oauth"
TokenEndpoint="https://stackoverflow.com/oauth/access_token/json"

10
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xsd

@ -425,6 +425,16 @@
</xs:simpleType>
</xs:attribute>
<xs:attribute name="DisplayName" use="optional">
<xs:annotation>
<xs:documentation>The display name used in the documentation, if applicable.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Documentation" type="xs:anyURI" use="optional">
<xs:annotation>
<xs:documentation>The documentation URI, if applicable.</xs:documentation>

Loading…
Cancel
Save