From 5d0e410b8bb0dcd931387fec0d1424eb9a54cf0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 13 May 2024 16:59:12 +0200 Subject: [PATCH] Introduce new advanced APIs in the web provider builders to allow configuring explicit code challenge methods, grant types, response modes and response types --- ...OpenIddictClientWebIntegrationGenerator.cs | 98 ++++++++++++++++--- 1 file changed, 83 insertions(+), 15 deletions(-) diff --git a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs index e749c97cd..fccd11a25 100644 --- a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs +++ b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs @@ -124,6 +124,89 @@ public sealed partial class {{ provider.name }} [EditorBrowsable(EditorBrowsableState.Never)] public OpenIddictClientRegistration Registration { get; } + /// + /// Adds one or more code challenge methods to the list of code challenge methods that can be negotiated for this provider. + /// + /// The code challenge methods. + /// Note: explicitly configuring the allowed code challenge methods is NOT recommended in most cases. + /// The instance. + [EditorBrowsable(EditorBrowsableState.Advanced)] + public {{ provider.name }} AddCodeChallengeMethods(params string[] methods) + { + if (methods is null) + { + throw new ArgumentNullException(nameof(methods)); + } + + return Set(registration => registration.CodeChallengeMethods.UnionWith(methods)); + } + + /// + /// Adds one or more grant types to the list of grant types that can be negotiated for this provider. + /// + /// The grant types. + /// Note: explicitly configuring the allowed grant types is NOT recommended in most cases. + /// The instance. + [EditorBrowsable(EditorBrowsableState.Advanced)] + public {{ provider.name }} AddGrantTypes(params string[] types) + { + if (types is null) + { + throw new ArgumentNullException(nameof(types)); + } + + return Set(registration => registration.GrantTypes.UnionWith(types)); + } + + /// + /// Adds one or more response modes to the list of response modes that can be negotiated for this provider. + /// + /// The response modes. + /// Note: explicitly configuring the allowed response modes is NOT recommended in most cases. + /// The instance. + [EditorBrowsable(EditorBrowsableState.Advanced)] + public {{ provider.name }} AddResponseModes(params string[] modes) + { + if (modes is null) + { + throw new ArgumentNullException(nameof(modes)); + } + + return Set(registration => registration.ResponseModes.UnionWith(modes)); + } + + /// + /// Adds one or more response types to the list of response types that can be negotiated for this provider. + /// + /// The response types. + /// Note: explicitly configuring the allowed response types is NOT recommended in most cases. + /// The instance. + [EditorBrowsable(EditorBrowsableState.Advanced)] + public {{ provider.name }} AddResponseTypes(params string[] types) + { + if (types is null) + { + throw new ArgumentNullException(nameof(types)); + } + + return Set(registration => registration.ResponseTypes.UnionWith(types)); + } + + /// + /// Adds one or more scopes to the list of requested scopes, if applicable. + /// + /// The scopes. + /// The instance. + public {{ provider.name }} AddScopes(params string[] scopes) + { + if (scopes is null) + { + throw new ArgumentNullException(nameof(scopes)); + } + + return Set(registration => registration.Scopes.UnionWith(scopes)); + } + /// /// Sets the provider name. /// @@ -275,21 +358,6 @@ public sealed partial class {{ provider.name }} return SetRedirectUri(new Uri(uri, UriKind.RelativeOrAbsolute)); } - /// - /// Adds one or more scopes to the list of requested scopes, if applicable. - /// - /// The scopes. - /// The instance. - public {{ provider.name }} AddScopes(params string[] scopes) - { - if (scopes is null) - { - throw new ArgumentNullException(nameof(scopes)); - } - - return Set(registration => registration.Scopes.UnionWith(scopes)); - } - {{~ for environment in provider.environments ~}} /// /// Configures the provider to use the ""{{ environment.name }}"" environment.