/* * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) * See https://github.com/openiddict/openiddict-core for more information concerning * the license and the contributors participating to this project. */ using System.Diagnostics; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Tokens; namespace OpenIddict.Client; /// /// Contains the properties used to configure a client/server link. /// [DebuggerDisplay("{Issuer,nq}")] public sealed class OpenIddictClientRegistration { /// /// Gets or sets the client identifier assigned by the authorization server. /// public string? ClientId { get; set; } /// /// Gets or sets the client secret assigned by the authorization server, if applicable. /// public string? ClientSecret { get; set; } /// /// Gets or sets the URI of the redirection endpoint that will handle the callback. /// /// /// Note: this value is automatically added to /// . /// public Uri? RedirectUri { get; set; } /// /// Gets or sets the URI of the post-logout redirection endpoint that will handle the callback. /// /// /// Note: this value is automatically added to /// . /// public Uri? PostLogoutRedirectUri { get; set; } /// /// Gets the list of encryption credentials used to create tokens for this client. /// Multiple credentials can be added to support key rollover, but if X.509 keys /// are used, at least one of them must have a valid creation/expiration date. /// public List EncryptionCredentials { get; } = new(); /// /// Gets the list of signing credentials used to create tokens for this client. /// Multiple credentials can be added to support key rollover, but if X.509 keys /// are used, at least one of them must have a valid creation/expiration date. /// public List SigningCredentials { get; } = new(); /// /// Gets the code challenge methods allowed by the client instance. /// If no value is explicitly set, all the methods enabled in the client options can be used. /// /// /// The final code challenge method used in authorization requests is chosen by OpenIddict based /// on the client options, the server configuration and the values registered in this property. /// public HashSet CodeChallengeMethods { get; } = new(StringComparer.Ordinal); /// /// Gets the grant types allowed by the client instance. /// If no value is explicitly set, all the modes enabled in the client options can be used. /// /// /// The final grant type used in authorization requests is chosen by OpenIddict based on /// the client options, the server configuration and the values registered in this property. /// public HashSet GrantTypes { get; } = new(StringComparer.Ordinal); /// /// Gets the response type combinations allowed by the client instance. /// If no value is explicitly set, all the types enabled in the client options can be used. /// /// /// The final response type used in authorization requests is chosen by OpenIddict based on /// the client options, the server configuration and the values registered in this property. /// public HashSet ResponseTypes { get; } = new(StringComparer.Ordinal); /// /// Gets the response modes allowed by the client instance. /// If no value is explicitly set, all the modes enabled in the client options can be used. /// /// /// The final response method used in authorization requests is chosen by OpenIddict based on /// the client options, the server configuration and the values registered in this property. /// public HashSet ResponseModes { get; } = new(StringComparer.Ordinal); /// /// Gets or sets the URI of the authorization server. /// public Uri? Issuer { get; set; } /// /// Gets or sets the provider name, if applicable. /// /// /// If a Web provider integration with the same name was enabled, the /// provider-specific options will be automatically imported and applied. /// public string? ProviderName { get; set; } /// /// Gets or sets the provider options, if applicable. /// public dynamic? ProviderOptions { get; set; } /// /// Gets or sets the static server configuration, if applicable. /// public OpenIddictConfiguration? Configuration { get; set; } /// /// Gets or sets the configuration manager used to retrieve and cache the server configuration. /// public IConfigurationManager ConfigurationManager { get; set; } = default!; /// /// Gets or sets the URI of the configuration endpoint exposed by the server. /// When the URI is relative, must be set and absolute. /// public Uri? ConfigurationEndpoint { get; set; } /// /// Gets or sets the token validation parameters associated with the authorization server. /// public TokenValidationParameters TokenValidationParameters { get; } = new TokenValidationParameters { AuthenticationType = TokenValidationParameters.DefaultAuthenticationType, ClockSkew = TimeSpan.Zero, NameClaimType = Claims.Name, RoleClaimType = Claims.Role, // Note: audience and lifetime are manually validated by OpenIddict itself. ValidateAudience = false, ValidateLifetime = false }; /// /// Gets the list of scopes sent by default as part of authorization requests. /// public HashSet Scopes { get; } = new(StringComparer.Ordinal); /// /// Gets the bag used to store additional provider-specific properties. /// public Dictionary Properties { get; } = new(StringComparer.OrdinalIgnoreCase); }