Browse Source

Remove the obsolete members

pull/1874/head
Kévin Chalet 2 years ago
parent
commit
36b2de9681
  1. 220
      gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
  2. 4
      src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs
  3. 4
      src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs
  4. 46
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs
  5. 14
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs
  6. 28
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationConfiguration.cs
  7. 10
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml
  8. 6
      src/OpenIddict.Client/OpenIddictClientEvents.Exchange.cs
  9. 10
      src/OpenIddict.Client/OpenIddictClientRegistration.cs
  10. 422
      src/OpenIddict.Client/OpenIddictClientService.cs
  11. 46
      src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs

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

@ -39,10 +39,6 @@ namespace OpenIddict.Client.WebIntegration.Generators
"OpenIddictClientWebIntegrationHelpers.generated.cs", "OpenIddictClientWebIntegrationHelpers.generated.cs",
SourceText.From(GenerateHelpers(document), Encoding.UTF8)); SourceText.From(GenerateHelpers(document), Encoding.UTF8));
context.AddSource(
"OpenIddictClientWebIntegrationOptions.generated.cs",
SourceText.From(GenerateOptions(document), Encoding.UTF8));
context.AddSource( context.AddSource(
"OpenIddictClientWebIntegrationSettings.generated.cs", "OpenIddictClientWebIntegrationSettings.generated.cs",
SourceText.From(GenerateSettings(document), Encoding.UTF8)); SourceText.From(GenerateSettings(document), Encoding.UTF8));
@ -101,43 +97,6 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
return this; return this;
} }
/// <summary>
/// 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>.
{{~ end ~}}
/// </summary>
/// <remarks>This extension can be safely called multiple times.</remarks>
/// <returns>The <see cref=""OpenIddictClientWebIntegrationBuilder.{{ provider.name }}""/> instance.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete($""This method was replaced by {nameof(Add{{ provider.name }})} and will be removed in a future version."")]
public OpenIddictClientWebIntegrationBuilder.{{ provider.name }} Use{{ provider.name }}()
{
var registration = new OpenIddictClientRegistration
{
ProviderSettings = new OpenIddictClientWebIntegrationSettings.{{ provider.name }}(),
ProviderType = ProviderTypes.{{ provider.name }}
};
Services.Configure<OpenIddictClientOptions>(options => options.Registrations.Add(registration));
return new OpenIddictClientWebIntegrationBuilder.{{ provider.name }}(registration);
}
/// <summary>
/// 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>.
{{~ end ~}}
/// </summary>
/// <remarks>This extension can be safely called multiple times.</remarks>
/// <param name=""configuration"">The delegate used to configure the OpenIddict/{{ provider.display_name }} options.</param>
/// <returns>The <see cref=""OpenIddictClientWebIntegrationBuilder""/> instance.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete($""This method was replaced by {nameof(Add{{ provider.name }})} and will be removed in a future version."")]
public OpenIddictClientWebIntegrationBuilder Use{{ provider.name }}(Action<OpenIddictClientWebIntegrationBuilder.{{ provider.name }}> configuration)
=> Add{{ provider.name }}(configuration);
{{~ end ~}} {{~ end ~}}
{{~ for provider in providers ~}} {{~ for provider in providers ~}}
@ -146,14 +105,6 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
/// </summary> /// </summary>
public sealed partial class {{ provider.name }} public sealed partial class {{ provider.name }}
{ {
/// <summary>
/// Initializes a new instance of <see cref=""OpenIddictClientWebIntegrationBuilder.{{ provider.name }}""/>.
/// </summary>
/// <param name=""services"">The services collection.</param>
[Obsolete(""This constructor is no longer supported and will be removed in a future version."", error: true)]
public {{ provider.name }}(IServiceCollection services)
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <summary> /// <summary>
/// Initializes a new instance of <see cref=""OpenIddictClientWebIntegrationBuilder.{{ provider.name }}""/>. /// Initializes a new instance of <see cref=""OpenIddictClientWebIntegrationBuilder.{{ provider.name }}""/>.
/// </summary> /// </summary>
@ -167,22 +118,6 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public OpenIddictClientRegistration Registration { get; } public OpenIddictClientRegistration Registration { get; }
/// <summary>
/// Gets the services collection.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public IServiceCollection Services => throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <summary>
/// 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>
/// <returns>The <see cref=""OpenIddictClientWebIntegrationBuilder.{{ provider.name }}""/> instance.</returns>
[Obsolete(""This method is no longer supported and will be removed in a future version."", error: true)]
public {{ provider.name }} Configure(Action<OpenIddictClientWebIntegrationOptions.{{ provider.name }}> configuration)
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <summary> /// <summary>
/// Sets the provider name. /// Sets the provider name.
/// </summary> /// </summary>
@ -868,34 +803,6 @@ namespace OpenIddict.Client.WebIntegration;
public sealed partial class OpenIddictClientWebIntegrationConfiguration public sealed partial class OpenIddictClientWebIntegrationConfiguration
{ {
{{~ for provider in providers ~}}
/// <summary>
/// Contains the methods required to register the {{ provider.display_name }} integration in the OpenIddict client options.
/// </summary>
[Obsolete(""This class is no longer supported and will be removed in a future version."", error: true)]
public sealed class {{ provider.name }} : IConfigureOptions<OpenIddictClientOptions>,
IPostConfigureOptions<OpenIddictClientWebIntegrationOptions.{{ provider.name }}>
{
/// <summary>
/// Creates a new instance of the <see cref=""OpenIddictClientWebIntegrationConfiguration.{{ provider.name }}"" /> class.
/// </summary>
/// <param name=""provider"">The service provider.</param>
[Obsolete(""This constructor is no longer supported and will be removed in a future version."", error: true)]
public {{ provider.name }}(IServiceProvider provider)
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <inheritdoc/>
[Obsolete(""This method is no longer supported and will be removed in a future version."", error: true)]
public void PostConfigure(string? name, OpenIddictClientWebIntegrationOptions.{{ provider.name }} options)
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <inheritdoc/>
[Obsolete(""This method is no longer supported and will be removed in a future version."", error: true)]
public void Configure(OpenIddictClientOptions options)
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
}
{{~ end ~}}
static partial void ConfigureProvider(OpenIddictClientRegistration registration) static partial void ConfigureProvider(OpenIddictClientRegistration registration)
{ {
{{~ for provider in providers ~}} {{~ for provider in providers ~}}
@ -1237,16 +1144,6 @@ namespace OpenIddict.Client.WebIntegration;
public static partial class OpenIddictClientWebIntegrationHelpers public static partial class OpenIddictClientWebIntegrationHelpers
{ {
{{~ for provider in providers ~}} {{~ for provider in providers ~}}
/// <summary>
/// Resolves the {{ provider.display_name }} provider options from the specified registration.
/// </summary>
/// <param name=""registration"">The client registration.</param>
/// <returns>The {{ provider.display_name }} provider options.</returns>
/// <exception cref=""InvalidOperationException"">The provider options cannot be resolved.</exception>
[Obsolete($""This extension was replaced by {nameof(Get{{ provider.name }}Settings)} and will be removed in a future version."", error: true)]
public static OpenIddictClientWebIntegrationOptions.{{ provider.name }} Get{{ provider.name }}Options(this OpenIddictClientRegistration registration)
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <summary> /// <summary>
/// Resolves the {{ provider.display_name }} provider settings from the specified registration. /// Resolves the {{ provider.display_name }} provider settings from the specified registration.
/// </summary> /// </summary>
@ -1272,123 +1169,6 @@ public static partial class OpenIddictClientWebIntegrationHelpers
}); });
} }
static string GenerateOptions(XDocument document)
{
var template = Template.Parse(@"#nullable enable
using System.Security.Cryptography.X509Certificates;
using Microsoft.IdentityModel.Tokens;
namespace OpenIddict.Client.WebIntegration;
public sealed partial class OpenIddictClientWebIntegrationOptions
{
{{~ for provider in providers ~}}
/// <summary>
/// Provides various options needed to configure the {{ provider.display_name }} integration.
/// </summary>
[Obsolete(""This class is no longer supported and will be removed in a future version."")]
public sealed class {{ provider.name }}
{
/// <summary>
/// Gets or sets the client identifier.
/// </summary>
public string? ClientId { get; set; }
/// <summary>
/// Gets or sets the client secret, if applicable.
/// </summary>
public string? ClientSecret { get; set; }
/// <summary>
/// Gets or sets the post-logout redirect URI.
/// </summary>
/// <remarks>
/// Note: this value is automatically added to
/// <see cref=""OpenIddictClientOptions.PostLogoutRedirectionEndpointUris""/>.
/// </remarks>
public Uri? PostLogoutRedirectUri { get; set; }
/// <summary>
/// Gets or sets the redirect URI.
/// </summary>
/// <remarks>
/// Note: this value is automatically added to
/// <see cref=""OpenIddictClientOptions.RedirectionEndpointUris""/>.
/// </remarks>
public Uri? RedirectUri { get; set; }
/// <summary>
/// Gets the scopes requested to the authorization server.
/// </summary>
public HashSet<string> Scopes { get; } = new(StringComparer.Ordinal);
/// <summary>
/// Gets or sets the environment that determines the endpoints to use (by default, ""Production"").
/// </summary>
public string? Environment { get; set; } = OpenIddictClientWebIntegrationConstants.{{ provider.name }}.Environments.Production;
{{~ for setting in provider.settings ~}}
/// <summary>
/// Gets or sets {{ setting.description }}.
/// </summary>
{{~ if setting.obsolete ~}}
[Obsolete(""This option is no longer supported and will be removed in a future version."")]
{{~ end ~}}
{{~ if setting.collection ~}}
public HashSet<{{ setting.clr_type }}> {{ setting.property_name }} { get; } = new();
{{~ else ~}}
public {{ setting.clr_type }}? {{ setting.property_name }} { get; set; }
{{~ end ~}}
{{~ end ~}}
}
{{~ end ~}}
}
");
return template.Render(new
{
Providers = document.Root.Elements("Provider")
.Select(provider => new
{
Name = (string) provider.Attribute("Name"),
DisplayName = (string?) provider.Attribute("DisplayName") ?? (string) provider.Attribute("Name"),
Settings = provider.Elements("Setting").Select(setting => new
{
PropertyName = (string) setting.Attribute("PropertyName"),
Collection = (bool?) setting.Attribute("Collection") ?? false,
Obsolete = (bool?) setting.Attribute("Obsolete") ?? false,
Description = (string) setting.Attribute("Description") is string description ?
char.ToLower(description[0], CultureInfo.GetCultureInfo("en-US")) + description[1..] : null,
ClrType = (string) setting.Attribute("Type") switch
{
"EncryptionKey" when (string) setting.Element("EncryptionAlgorithm").Attribute("Value")
is "RS256" or "RS384" or "RS512" => "RsaSecurityKey",
"SigningKey" when (string) setting.Element("SigningAlgorithm").Attribute("Value")
is "ES256" or "ES384" or "ES512" => "ECDsaSecurityKey",
"SigningKey" when (string) setting.Element("SigningAlgorithm").Attribute("Value")
is "PS256" or "PS384" or "PS512" or
"RS256" or "RS384" or "RS512" => "RsaSecurityKey",
"Certificate" => "X509Certificate2",
"String" => "string",
"StringHashSet" => "HashSet<string>",
"Uri" => "Uri",
string value => value
}
})
.ToList()
})
.ToList()
});
}
static string GenerateSettings(XDocument document) static string GenerateSettings(XDocument document)
{ {
var template = Template.Parse(@"#nullable enable var template = Template.Parse(@"#nullable enable

4
src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs

@ -21,10 +21,6 @@ public sealed class OpenIddictClientAspNetCoreConfiguration : IConfigureOptions<
{ {
private readonly IServiceProvider _provider; private readonly IServiceProvider _provider;
/// <inheritdoc/>
[Obsolete("This constructor is no longer supported and will be removed in a future version.", error: true)]
public OpenIddictClientAspNetCoreConfiguration() => throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <summary> /// <summary>
/// Creates a new instance of the <see cref="OpenIddictClientAspNetCoreConfiguration"/> class. /// Creates a new instance of the <see cref="OpenIddictClientAspNetCoreConfiguration"/> class.
/// </summary> /// </summary>

4
src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs

@ -19,10 +19,6 @@ public sealed class OpenIddictClientOwinConfiguration : IConfigureOptions<OpenId
{ {
private readonly IServiceProvider _provider; private readonly IServiceProvider _provider;
/// <inheritdoc/>
[Obsolete("This constructor is no longer supported and will be removed in a future version.", error: true)]
public OpenIddictClientOwinConfiguration() => throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <summary> /// <summary>
/// Creates a new instance of the <see cref="OpenIddictClientOwinConfiguration"/> class. /// Creates a new instance of the <see cref="OpenIddictClientOwinConfiguration"/> class.
/// </summary> /// </summary>

46
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs

@ -327,9 +327,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>() = OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>() .AddFilter<RequireHttpMetadataUri>()
.UseSingletonHandler<AttachHttpParameters<TContext>>() .UseSingletonHandler<AttachHttpParameters<TContext>>()
#pragma warning disable CS0618 .SetOrder(int.MaxValue - 100_000)
.SetOrder(AttachQueryStringParameters<TContext>.Descriptor.Order - 1_000)
#pragma warning restore CS0618
.SetType(OpenIddictClientHandlerType.BuiltIn) .SetType(OpenIddictClientHandlerType.BuiltIn)
.Build(); .Build();
@ -377,48 +375,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
} }
} }
/// <summary>
/// Contains the logic responsible for attaching the query string parameters to the HTTP request.
/// </summary>
[Obsolete("This class is obsolete and will be removed in a future version.")]
public sealed class AttachQueryStringParameters<TContext> : IOpenIddictClientHandler<TContext> where TContext : BaseExternalContext
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.UseSingletonHandler<AttachQueryStringParameters<TContext>>()
.SetOrder(AttachFormParameters<TContext>.Descriptor.Order - 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
.Build();
/// <inheritdoc/>
public ValueTask HandleAsync(TContext context) => default;
}
/// <summary>
/// Contains the logic responsible for attaching the form parameters to the HTTP request.
/// </summary>
[Obsolete("This class is obsolete and will be removed in a future version.")]
public sealed class AttachFormParameters<TContext> : IOpenIddictClientHandler<TContext> where TContext : BaseExternalContext
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.UseSingletonHandler<AttachFormParameters<TContext>>()
.SetOrder(int.MaxValue - 100_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
.Build();
/// <inheritdoc/>
public ValueTask HandleAsync(TContext context) => default;
}
/// <summary> /// <summary>
/// Contains the logic responsible for sending the HTTP request to the remote server. /// Contains the logic responsible for sending the HTTP request to the remote server.
/// </summary> /// </summary>

14
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpOptions.cs

@ -49,18 +49,4 @@ public sealed class OpenIddictClientSystemNetHttpOptions
/// instances created by the OpenIddict client/System.Net.Http integration. /// instances created by the OpenIddict client/System.Net.Http integration.
/// </summary> /// </summary>
public List<Action<OpenIddictClientRegistration, HttpClientHandler>> UnfilteredHttpClientHandlerActions { get; } = new(); public List<Action<OpenIddictClientRegistration, HttpClientHandler>> UnfilteredHttpClientHandlerActions { get; } = new();
/// <summary>
/// Gets the user-defined actions used to amend the <see cref="HttpClient"/>
/// instances created by the OpenIddict client/System.Net.Http integration.
/// </summary>
[Obsolete($"This property was replaced by {nameof(UnfilteredHttpClientActions)} and will be removed in a future version.")]
public Dictionary<string, List<Action<HttpClient>>> HttpClientActions { get; } = new();
/// <summary>
/// Gets the user-defined actions used to amend the <see cref="HttpClientHandler"/>
/// instances created by the OpenIddict client/System.Net.Http integration.
/// </summary>
[Obsolete($"This property was replaced by {nameof(UnfilteredHttpClientActions)} and will be removed in a future version.")]
public Dictionary<string, List<Action<HttpClientHandler>>> HttpClientHandlerActions { get; } = new();
} }

28
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationConfiguration.cs

@ -6,7 +6,6 @@
using System.ComponentModel; using System.ComponentModel;
using System.Net.Http; using System.Net.Http;
using Microsoft.Extensions.Http;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.Client.SystemNetHttp; using OpenIddict.Client.SystemNetHttp;
using static OpenIddict.Client.WebIntegration.OpenIddictClientWebIntegrationConstants; using static OpenIddict.Client.WebIntegration.OpenIddictClientWebIntegrationConstants;
@ -19,25 +18,8 @@ namespace OpenIddict.Client.WebIntegration;
[EditorBrowsable(EditorBrowsableState.Advanced)] [EditorBrowsable(EditorBrowsableState.Advanced)]
public sealed partial class OpenIddictClientWebIntegrationConfiguration : IConfigureOptions<OpenIddictClientOptions>, public sealed partial class OpenIddictClientWebIntegrationConfiguration : IConfigureOptions<OpenIddictClientOptions>,
IConfigureOptions<OpenIddictClientSystemNetHttpOptions>, IConfigureOptions<OpenIddictClientSystemNetHttpOptions>,
IConfigureNamedOptions<HttpClientFactoryOptions>,
IPostConfigureOptions<OpenIddictClientOptions> IPostConfigureOptions<OpenIddictClientOptions>
{ {
/// <summary>
/// Creates a new instance of the <see cref="OpenIddictClientWebIntegrationConfiguration"/> class.
/// </summary>
public OpenIddictClientWebIntegrationConfiguration()
{
}
/// <summary>
/// Creates a new instance of the <see cref="OpenIddictClientWebIntegrationConfiguration"/> class.
/// </summary>
/// <param name="provider">The service provider.</param>
[Obsolete("This constructor is no longer supported and will be removed in a future version.")]
public OpenIddictClientWebIntegrationConfiguration(IServiceProvider provider)
{
}
/// <inheritdoc/> /// <inheritdoc/>
public void Configure(OpenIddictClientOptions options) public void Configure(OpenIddictClientOptions options)
{ {
@ -80,16 +62,6 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration : IConfi
}); });
} }
/// <inheritdoc/>
[Obsolete("This method is no longer supported and will be removed in a future version.", error: true)]
public void Configure(HttpClientFactoryOptions options)
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <inheritdoc/>
[Obsolete("This method is no longer supported and will be removed in a future version.", error: true)]
public void Configure(string? name, HttpClientFactoryOptions options)
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
/// <inheritdoc/> /// <inheritdoc/>
public void PostConfigure(string? name, OpenIddictClientOptions options) public void PostConfigure(string? name, OpenIddictClientOptions options)
{ {

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

@ -589,16 +589,6 @@
<Scope Name="profile" Default="true" Required="true" /> <Scope Name="profile" Default="true" Required="true" />
</Environment> </Environment>
<Setting PropertyName="Fields" ParameterName="fields" Collection="true" Obsolete="true" Type="String"
Description="The fields that should be retrieved from the userinfo endpoint (by default, all known basic fields are requested)">
<Item Value="firstName" Default="true" Required="false" />
<Item Value="id" Default="true" Required="false" />
<Item Value="lastName" Default="true" Required="false" />
<Item Value="localizedFirstName" Default="true" Required="false" />
<Item Value="localizedLastName" Default="true" Required="false" />
<Item Value="profilePicture(displayImage~:playableStreams)" Default="true" Required="false" />
</Setting>
</Provider> </Provider>
<!-- <!--

6
src/OpenIddict.Client/OpenIddictClientEvents.Exchange.cs

@ -166,11 +166,5 @@ public static partial class OpenIddictClientEvents
get => Response.RefreshToken; get => Response.RefreshToken;
set => Response.RefreshToken = value; set => Response.RefreshToken = value;
} }
/// <summary>
/// Gets or sets the principal containing the claims resolved from the token response.
/// </summary>
[Obsolete("This property is no longer supported and will be removed in a future version.")]
public ClaimsPrincipal? Principal { get; set; }
} }
} }

10
src/OpenIddict.Client/OpenIddictClientRegistration.cs

@ -121,16 +121,6 @@ public sealed class OpenIddictClientRegistration
/// </remarks> /// </remarks>
public string? ProviderName { get; set; } public string? ProviderName { get; set; }
/// <summary>
/// Gets or sets the provider options, if applicable.
/// </summary>
[Obsolete($"This property was replaced by {nameof(ProviderSettings)} and will be removed in a future version.")]
public dynamic? ProviderOptions
{
get => throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
set => throw new NotSupportedException(SR.GetResourceString(SR.ID0403));
}
/// <summary> /// <summary>
/// Gets or sets the provider settings, if applicable. /// Gets or sets the provider settings, if applicable.
/// </summary> /// </summary>

422
src/OpenIddict.Client/OpenIddictClientService.cs

@ -213,84 +213,6 @@ public sealed class OpenIddictClientService
throw new InvalidOperationException(SR.GetResourceString(SR.ID0140)); throw new InvalidOperationException(SR.GetResourceString(SR.ID0140));
} }
/// <summary>
/// Initiates an interactive user authentication demand.
/// </summary>
/// <param name="issuer">The issuer.</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse AuthorizationResponse, OpenIddictResponse TokenResponse, ClaimsPrincipal Principal)> AuthenticateInteractivelyAsync(
Uri issuer, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (issuer is null)
{
throw new ArgumentNullException(nameof(issuer));
}
var nonce = (await ChallengeInteractivelyAsync(new()
{
AdditionalAuthorizationRequestParameters = parameters,
CancellationToken = cancellationToken,
Issuer = issuer,
Properties = properties!,
Scopes = scopes?.ToList()
})).Nonce;
var result = await AuthenticateInteractivelyAsync(new()
{
CancellationToken = cancellationToken,
Nonce = nonce,
Properties = properties!
});
return (result.AuthorizationResponse, result.TokenResponse, result.Principal);
}
/// <summary>
/// Initiates an interactive user authentication demand.
/// </summary>
/// <param name="provider">The name of the provider (see <see cref="OpenIddictClientRegistration.ProviderName"/>).</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse AuthorizationResponse, OpenIddictResponse TokenResponse, ClaimsPrincipal Principal)> AuthenticateInteractivelyAsync(
string provider, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(provider))
{
throw new ArgumentException(SR.FormatID0366(nameof(provider)), nameof(provider));
}
var nonce = (await ChallengeInteractivelyAsync(new()
{
AdditionalAuthorizationRequestParameters = parameters,
CancellationToken = cancellationToken,
Properties = properties!,
ProviderName = provider,
Scopes = scopes?.ToList()
})).Nonce;
var result = await AuthenticateInteractivelyAsync(new()
{
CancellationToken = cancellationToken,
Nonce = nonce,
Properties = properties!
});
return (result.AuthorizationResponse, result.TokenResponse, result.Principal);
}
/// <summary> /// <summary>
/// Completes the interactive authentication demand corresponding to the specified nonce. /// Completes the interactive authentication demand corresponding to the specified nonce.
/// </summary> /// </summary>
@ -459,70 +381,6 @@ public sealed class OpenIddictClientService
} }
} }
/// <summary>
/// Authenticates using the client credentials grant.
/// </summary>
/// <param name="issuer">The issuer.</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse Response, ClaimsPrincipal Principal)> AuthenticateWithClientCredentialsAsync(
Uri issuer, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (issuer is null)
{
throw new ArgumentNullException(nameof(issuer));
}
var result = await AuthenticateWithClientCredentialsAsync(new()
{
AdditionalTokenRequestParameters = parameters,
CancellationToken = cancellationToken,
Issuer = issuer,
Properties = properties!,
Scopes = scopes?.ToList()
});
return (result.TokenResponse, result.Principal);
}
/// <summary>
/// Authenticates using the client credentials grant.
/// </summary>
/// <param name="provider">The name of the provider (see <see cref="OpenIddictClientRegistration.ProviderName"/>).</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse Response, ClaimsPrincipal Principal)> AuthenticateWithClientCredentialsAsync(
string provider, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(provider))
{
throw new ArgumentException(SR.FormatID0366(nameof(provider)), nameof(provider));
}
var result = await AuthenticateWithClientCredentialsAsync(new()
{
AdditionalTokenRequestParameters = parameters,
CancellationToken = cancellationToken,
Properties = properties!,
ProviderName = provider,
Scopes = scopes?.ToList()
});
return (result.TokenResponse, result.Principal);
}
/// <summary> /// <summary>
/// Authenticates using the client credentials grant. /// Authenticates using the client credentials grant.
/// </summary> /// </summary>
@ -615,76 +473,6 @@ public sealed class OpenIddictClientService
} }
} }
/// <summary>
/// Authenticates using the specified device authorization code.
/// </summary>
/// <param name="issuer">The issuer.</param>
/// <param name="code">The device authorization code returned by the server during the challenge process.</param>
/// <param name="interval">The interval at which the token requests are sent (by default, 5 seconds).</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse TokenResponse, ClaimsPrincipal Principal)> AuthenticateWithDeviceAsync(
Uri issuer, string code, TimeSpan? interval = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (issuer is null)
{
throw new ArgumentNullException(nameof(issuer));
}
var result = await AuthenticateWithDeviceAsync(new()
{
AdditionalTokenRequestParameters = parameters,
CancellationToken = cancellationToken,
DeviceCode = code,
Interval = interval ?? TimeSpan.FromSeconds(5),
Issuer = issuer,
Properties = properties!,
Timeout = TimeSpan.FromMinutes(5)
});
return (result.TokenResponse, result.Principal);
}
/// <summary>
/// Authenticates using the specified device authorization code.
/// </summary>
/// <param name="provider">The name of the provider (see <see cref="OpenIddictClientRegistration.ProviderName"/>).</param>
/// <param name="code">The device authorization code returned by the server during the challenge process.</param>
/// <param name="interval">The interval at which the token requests are sent (by default, 5 seconds).</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse TokenResponse, ClaimsPrincipal Principal)> AuthenticateWithDeviceAsync(
string provider, string code, TimeSpan? interval = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(provider))
{
throw new ArgumentException(SR.FormatID0366(nameof(provider)), nameof(provider));
}
var result = await AuthenticateWithDeviceAsync(new()
{
AdditionalTokenRequestParameters = parameters,
CancellationToken = cancellationToken,
DeviceCode = code,
Interval = interval ?? TimeSpan.FromSeconds(5),
Properties = properties!,
ProviderName = provider,
Timeout = TimeSpan.FromMinutes(5)
});
return (result.TokenResponse, result.Principal);
}
/// <summary> /// <summary>
/// Authenticates using the specified device authorization code. /// Authenticates using the specified device authorization code.
/// </summary> /// </summary>
@ -802,76 +590,6 @@ public sealed class OpenIddictClientService
} }
} }
/// <summary>
/// Initiates a device authorization demand.
/// </summary>
/// <param name="issuer">The issuer.</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The device authorization parameters.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(string DeviceCode, string UserCode, Uri VerificationUri, Uri? VerificationUriComplete, TimeSpan ExpiresIn, TimeSpan Interval)> ChallengeUsingDeviceAsync(
Uri issuer, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (issuer is null)
{
throw new ArgumentNullException(nameof(issuer));
}
var result = await ChallengeUsingDeviceAsync(new()
{
AdditionalDeviceAuthorizationRequestParameters = parameters,
CancellationToken = cancellationToken,
Issuer = issuer,
Properties = properties!,
Scopes = scopes?.ToList()
});
return (
result.DeviceCode, result.UserCode,
result.VerificationUri, result.VerificationUriComplete,
result.ExpiresIn, result.Interval);
}
/// <summary>
/// Initiates a device authorization demand.
/// </summary>
/// <param name="provider">The name of the provider (see <see cref="OpenIddictClientRegistration.ProviderName"/>).</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The device authorization parameters.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(string DeviceCode, string UserCode, Uri VerificationUri, Uri? VerificationUriComplete, TimeSpan ExpiresIn, TimeSpan Interval)> ChallengeUsingDeviceAsync(
string provider, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(provider))
{
throw new ArgumentException(SR.FormatID0366(nameof(provider)), nameof(provider));
}
var result = await ChallengeUsingDeviceAsync(new()
{
AdditionalDeviceAuthorizationRequestParameters = parameters,
CancellationToken = cancellationToken,
Properties = properties!,
ProviderName = provider,
Scopes = scopes?.ToList()
});
return (
result.DeviceCode, result.UserCode,
result.VerificationUri, result.VerificationUriComplete,
result.ExpiresIn, result.Interval);
}
/// <summary> /// <summary>
/// Initiates a device authorization process. /// Initiates a device authorization process.
/// </summary> /// </summary>
@ -962,78 +680,6 @@ public sealed class OpenIddictClientService
} }
} }
/// <summary>
/// Authenticates using the resource owner password credentials grant.
/// </summary>
/// <param name="issuer">The issuer.</param>
/// <param name="username">The username to use.</param>
/// <param name="password">The password to use.</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse Response, ClaimsPrincipal Principal)> AuthenticateWithPasswordAsync(
Uri issuer, string username, string password, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (issuer is null)
{
throw new ArgumentNullException(nameof(issuer));
}
var result = await AuthenticateWithPasswordAsync(new()
{
AdditionalTokenRequestParameters = parameters,
CancellationToken = cancellationToken,
Issuer = issuer,
Password = password,
Properties = properties!,
Scopes = scopes?.ToList(),
Username = username
});
return (result.TokenResponse, result.Principal);
}
/// <summary>
/// Authenticates using the resource owner password credentials grant.
/// </summary>
/// <param name="provider">The name of the provider (see <see cref="OpenIddictClientRegistration.ProviderName"/>).</param>
/// <param name="username">The username to use.</param>
/// <param name="password">The password to use.</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse Response, ClaimsPrincipal Principal)> AuthenticateWithPasswordAsync(
string provider, string username, string password, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(provider))
{
throw new ArgumentException(SR.FormatID0366(nameof(provider)), nameof(provider));
}
var result = await AuthenticateWithPasswordAsync(new()
{
AdditionalTokenRequestParameters = parameters,
CancellationToken = cancellationToken,
Password = password,
Properties = properties!,
ProviderName = provider,
Scopes = scopes?.ToList(),
Username = username
});
return (result.TokenResponse, result.Principal);
}
/// <summary> /// <summary>
/// Authenticates using the resource owner password credentials grant. /// Authenticates using the resource owner password credentials grant.
/// </summary> /// </summary>
@ -1127,74 +773,6 @@ public sealed class OpenIddictClientService
} }
} }
/// <summary>
/// Authenticates using the specified refresh token.
/// </summary>
/// <param name="issuer">The issuer.</param>
/// <param name="token">The refresh token to use.</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse Response, ClaimsPrincipal Principal)> AuthenticateWithRefreshTokenAsync(
Uri issuer, string token, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (issuer is null)
{
throw new ArgumentNullException(nameof(issuer));
}
var result = await AuthenticateWithRefreshTokenAsync(new()
{
AdditionalTokenRequestParameters = parameters,
CancellationToken = cancellationToken,
Issuer = issuer,
Properties = properties!,
RefreshToken = token,
Scopes = scopes?.ToList()
});
return (result.TokenResponse, result.Principal);
}
/// <summary>
/// Authenticates using the specified refresh token.
/// </summary>
/// <param name="provider">The name of the provider (see <see cref="OpenIddictClientRegistration.ProviderName"/>).</param>
/// <param name="token">The refresh token to use.</param>
/// <param name="scopes">The scopes to request to the authorization server.</param>
/// <param name="parameters">The additional parameters to send as part of the token request.</param>
/// <param name="properties">The application-specific properties that will be added to the authentication context.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The response and a merged principal containing the claims extracted from the tokens and userinfo response.</returns>
[Obsolete("This method is obsolete and will be removed in a future version.")]
public async ValueTask<(OpenIddictResponse Response, ClaimsPrincipal Principal)> AuthenticateWithRefreshTokenAsync(
string provider, string token, string[]? scopes = null,
Dictionary<string, OpenIddictParameter>? parameters = null,
Dictionary<string, string>? properties = null, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(provider))
{
throw new ArgumentException(SR.FormatID0366(nameof(provider)), nameof(provider));
}
var result = await AuthenticateWithRefreshTokenAsync(new()
{
AdditionalTokenRequestParameters = parameters,
CancellationToken = cancellationToken,
Properties = properties!,
ProviderName = provider,
RefreshToken = token,
Scopes = scopes?.ToList()
});
return (result.TokenResponse, result.Principal);
}
/// <summary> /// <summary>
/// Authenticates using the specified refresh token. /// Authenticates using the specified refresh token.
/// </summary> /// </summary>

46
src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs

@ -326,9 +326,7 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers
= OpenIddictValidationHandlerDescriptor.CreateBuilder<TContext>() = OpenIddictValidationHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>() .AddFilter<RequireHttpMetadataUri>()
.UseSingletonHandler<AttachHttpParameters<TContext>>() .UseSingletonHandler<AttachHttpParameters<TContext>>()
#pragma warning disable CS0618 .SetOrder(int.MaxValue - 100_000)
.SetOrder(AttachQueryStringParameters<TContext>.Descriptor.Order - 1_000)
#pragma warning restore CS0618
.SetType(OpenIddictValidationHandlerType.BuiltIn) .SetType(OpenIddictValidationHandlerType.BuiltIn)
.Build(); .Build();
@ -376,48 +374,6 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers
} }
} }
/// <summary>
/// Contains the logic responsible for attaching the query string parameters to the HTTP request.
/// </summary>
[Obsolete("This class is obsolete and will be removed in a future version.")]
public sealed class AttachQueryStringParameters<TContext> : IOpenIddictValidationHandler<TContext> where TContext : BaseExternalContext
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictValidationHandlerDescriptor Descriptor { get; }
= OpenIddictValidationHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.UseSingletonHandler<AttachQueryStringParameters<TContext>>()
.SetOrder(AttachFormParameters<TContext>.Descriptor.Order - 1_000)
.SetType(OpenIddictValidationHandlerType.BuiltIn)
.Build();
/// <inheritdoc/>
public ValueTask HandleAsync(TContext context) => default;
}
/// <summary>
/// Contains the logic responsible for attaching the form parameters to the HTTP request.
/// </summary>
[Obsolete("This class is obsolete and will be removed in a future version.")]
public sealed class AttachFormParameters<TContext> : IOpenIddictValidationHandler<TContext> where TContext : BaseExternalContext
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictValidationHandlerDescriptor Descriptor { get; }
= OpenIddictValidationHandlerDescriptor.CreateBuilder<TContext>()
.AddFilter<RequireHttpMetadataUri>()
.UseSingletonHandler<AttachFormParameters<TContext>>()
.SetOrder(int.MaxValue - 100_000)
.SetType(OpenIddictValidationHandlerType.BuiltIn)
.Build();
/// <inheritdoc/>
public ValueTask HandleAsync(TContext context) => default;
}
/// <summary> /// <summary>
/// Contains the logic responsible for sending the HTTP request to the remote server. /// Contains the logic responsible for sending the HTTP request to the remote server.
/// </summary> /// </summary>

Loading…
Cancel
Save