/*
* 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.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Extensions.Logging;
namespace OpenIddict.Client;
public static partial class OpenIddictClientEvents
{
///
/// Represents an abstract base class used for certain event contexts.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class BaseContext
{
///
/// Creates a new instance of the class.
///
protected BaseContext(OpenIddictClientTransaction transaction)
=> Transaction = transaction ?? throw new ArgumentNullException(nameof(transaction));
///
/// Gets the environment associated with the current request being processed.
///
public OpenIddictClientTransaction Transaction { get; }
///
/// Gets or sets the cancellation token that will be
/// used to determine if the operation was aborted.
///
///
/// Note: for security reasons, this property shouldn't be used by event
/// handlers to abort security-sensitive operations. As such, it is
/// recommended to use this property only for user-dependent operations.
///
public CancellationToken CancellationToken
{
get => Transaction.CancellationToken;
set => Transaction.CancellationToken = value;
}
///
/// Gets or sets the endpoint type that handled the request, if applicable.
///
public OpenIddictClientEndpointType EndpointType
{
get => Transaction.EndpointType;
set => Transaction.EndpointType = value;
}
///
/// Gets or sets the request of the current transaction, if available.
///
public Uri? RequestUri
{
get => Transaction.RequestUri;
set => Transaction.RequestUri = value;
}
///
/// Gets or sets the base of the host, if available.
///
public Uri? BaseUri
{
get => Transaction.BaseUri;
set => Transaction.BaseUri = value;
}
///
/// Gets the logger responsible for logging processed operations.
///
public ILogger Logger => Transaction.Logger;
///
/// Gets the OpenIddict client options.
///
public OpenIddictClientOptions Options => Transaction.Options;
///
/// Gets or sets the server configuration used for the current request.
///
public OpenIddictConfiguration Configuration
{
get => Transaction.Configuration;
set => Transaction.Configuration = value;
}
///
/// Gets or sets the client registration used for the current request.
///
public OpenIddictClientRegistration Registration
{
get => Transaction.Registration;
set => Transaction.Registration = value;
}
}
///
/// Represents an abstract base class used for certain event contexts.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class BaseRequestContext : BaseContext
{
///
/// Creates a new instance of the class.
///
protected BaseRequestContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets a boolean indicating whether the request was fully handled.
///
public bool IsRequestHandled { get; private set; }
///
/// Gets a boolean indicating whether the request processing was skipped.
///
public bool IsRequestSkipped { get; private set; }
///
/// Marks the request as fully handled. Once declared handled,
/// a request shouldn't be processed further by the underlying host.
///
public void HandleRequest() => IsRequestHandled = true;
///
/// Marks the request as skipped. Once declared skipped, a request
/// shouldn't be processed further by OpenIddict but should be allowed
/// to go through the next components in the processing pipeline
/// (if this pattern is supported by the underlying host).
///
public void SkipRequest() => IsRequestSkipped = true;
}
///
/// Represents an abstract base class used for certain event contexts.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class BaseExternalContext : BaseValidatingContext
{
///
/// Creates a new instance of the class.
///
protected BaseExternalContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the URI of the external endpoint to communicate with.
///
public Uri? RemoteUri { get; set; }
///
/// Gets or sets the client authentication method used
/// when communicating with the external endpoint, if applicable.
///
public string? ClientAuthenticationMethod { get; set; }
///
/// Gets or sets the X.509 client certificate that will be used to authenticate
/// this peer when communicating with the external endpoint, if applicable.
///
public X509Certificate2? LocalCertificate { get; set; }
}
///
/// Represents an abstract base class used for certain event contexts.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class BaseValidatingContext : BaseRequestContext
{
///
/// Creates a new instance of the class.
///
protected BaseValidatingContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets a boolean indicating whether the request will be rejected.
///
public bool IsRejected { get; protected set; }
///
/// Gets or sets the "error" parameter returned to the client application.
///
public string? Error { get; private set; }
///
/// Gets or sets the "error_description" parameter returned to the client application.
///
public string? ErrorDescription { get; private set; }
///
/// Gets or sets the "error_uri" parameter returned to the client application.
///
public string? ErrorUri { get; private set; }
///
/// Rejects the request.
///
/// The "error" parameter returned to the client application.
/// The "error_description" parameter returned to the client application.
/// The "error_uri" parameter returned to the client application.
public virtual void Reject(string? error = null, string? description = null, string? uri = null)
{
Error = error;
ErrorDescription = description;
ErrorUri = uri;
IsRejected = true;
}
}
///
/// Represents an abstract base class used for certain event contexts.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class BaseValidatingTicketContext : BaseValidatingContext
{
///
/// Creates a new instance of the class.
///
protected BaseValidatingTicketContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the security principal.
///
public ClaimsPrincipal? Principal { get; set; }
}
///
/// Represents an event called when processing an incoming request.
///
public sealed class ProcessRequestContext : BaseValidatingContext
{
///
/// Creates a new instance of the class.
///
public ProcessRequestContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
}
///
/// Represents an event called when processing an errored response.
///
public sealed class ProcessErrorContext : BaseRequestContext
{
///
/// Creates a new instance of the class.
///
public ProcessErrorContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request, or if it couldn't be extracted.
///
public OpenIddictRequest? Request
{
get => Transaction.Request;
set => Transaction.Request = value;
}
///
/// Gets or sets the response.
///
public OpenIddictResponse Response
{
get => Transaction.Response!;
set => Transaction.Response = value;
}
///
/// Gets or sets the error returned to the caller.
///
public string? Error { get; set; }
///
/// Gets or sets the error description returned to the caller.
///
public string? ErrorDescription { get; set; }
///
/// Gets or sets the error URI returned to the caller.
///
public string? ErrorUri { get; set; }
///
/// Gets the additional parameters returned to the caller.
///
public Dictionary Parameters { get; } = new(StringComparer.Ordinal);
}
///
/// Represents an event called when processing an authentication operation.
///
public sealed class ProcessAuthenticationContext : BaseValidatingContext
{
///
/// Creates a new instance of the class.
///
public ProcessAuthenticationContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
///
/// Gets the user-defined authentication properties, if available.
///
public Dictionary Properties { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets the nonce used to identify the authentication demand, if applicable.
///
public string? Nonce { get; set; }
///
/// Gets or sets the identifier that will be used to resolve the client registration, if applicable.
///
public string? RegistrationId { get; set; }
///
/// Gets or sets the issuer URI of the provider that will be
/// used to resolve the client registration, if applicable.
///
public Uri? Issuer { get; set; }
///
/// Gets or sets the name of the provider that will be
/// used to resolve the client registration, if applicable.
///
public string? ProviderName { get; set; }
///
/// Gets or sets the grant type used for the authentication demand, if applicable.
///
public string? GrantType { get; set; }
///
/// Gets or sets the response type used for the authentication demand, if applicable.
///
public string? ResponseType { get; set; }
///
/// Gets or sets the request forgery protection resolved from the user session, if applicable.
///
public string? RequestForgeryProtection { get; set; }
///
/// Gets the audiences that will be sent to the authorization server, if applicable.
///
public HashSet Audiences { get; } = new(StringComparer.Ordinal);
///
/// Gets the resources that will be sent to the authorization server, if applicable.
///
public HashSet Resources { get; } = new(StringComparer.Ordinal);
///
/// Gets the scopes that will be sent to the authorization server, if applicable.
///
public HashSet Scopes { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets the URI of the token endpoint, if applicable.
///
public Uri? TokenEndpoint { get; set; }
///
/// Gets or sets the client authentication method used
/// when communicating with the token endpoint, if applicable.
///
public string? TokenEndpointClientAuthenticationMethod { get; set; }
///
/// Gets or sets the X.509 client certificate used when
/// communicating with the token endpoint, if applicable.
///
public X509Certificate2? TokenEndpointClientCertificate { get; set; }
///
/// Gets or sets the token binding method used when
/// communicating with the token endpoint, if applicable.
///
public string? TokenEndpointTokenBindingMethod { get; set; }
///
/// Gets or sets the URI of the userinfo endpoint, if applicable.
///
public Uri? UserInfoEndpoint { get; set; }
///
/// Gets or sets the token binding method used when
/// communicating with the userinfo endpoint, if applicable.
///
public string? UserInfoEndpointTokenBindingMethod { get; set; }
///
/// Gets or sets the X.509 client certificate used when
/// communicating with the userinfo endpoint, if applicable.
///
public X509Certificate2? UserInfoEndpointClientCertificate { get; set; }
///
/// Gets or sets a boolean indicating whether the token entry associated
/// with the state token should be marked as redeemed in the database.
///
public bool DisableStateTokenRedeeming { get; set; }
///
/// Gets or sets a boolean indicating whether a token request should be sent.
///
public bool SendTokenRequest { get; set; }
///
/// Gets or sets a boolean indicating whether a token request should be sent.
///
public bool SendUserInfoRequest { get; set; }
///
/// Gets or sets a boolean indicating whether an authorization
/// code should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractAuthorizationCode { get; set; }
///
/// Gets or sets a boolean indicating whether a backchannel
/// access token should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractBackchannelAccessToken { get; set; }
///
/// Gets or sets a boolean indicating whether a backchannel
/// identity token should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractBackchannelIdentityToken { get; set; }
///
/// Gets or sets a boolean indicating whether a frontchannel
/// access token should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractFrontchannelAccessToken { get; set; }
///
/// Gets or sets a boolean indicating whether a frontchannel
/// identity token should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractFrontchannelIdentityToken { get; set; }
///
/// Gets or sets a boolean indicating whether an issued
/// token should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractIssuedToken { get; set; }
///
/// Gets or sets a boolean indicating whether a refresh
/// token should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractRefreshToken { get; set; }
///
/// Gets or sets a boolean indicating whether a state
/// token should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractStateToken { get; set; }
///
/// Gets or sets a boolean indicating whether a userinfo
/// token should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractUserInfoToken { get; set; }
///
/// Gets or sets a boolean indicating whether an authorization
/// code must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireAuthorizationCode { get; set; }
///
/// Gets or sets a boolean indicating whether a backchannel access
/// token must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireBackchannelAccessToken { get; set; }
///
/// Gets or sets a boolean indicating whether a backchannel identity
/// token must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireBackchannelIdentityToken { get; set; }
///
/// Gets or sets a boolean indicating whether a frontchannel identity
/// token must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireFrontchannelAccessToken { get; set; }
///
/// Gets or sets a boolean indicating whether a frontchannel identity
/// token must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireFrontchannelIdentityToken { get; set; }
///
/// Gets or sets a boolean indicating whether an issued token
/// must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireIssuedToken { get; set; }
///
/// Gets or sets a boolean indicating whether a refresh token
/// must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireRefreshToken { get; set; }
///
/// Gets or sets a boolean indicating whether a state token
/// must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireStateToken { get; set; }
///
/// Gets or sets a boolean indicating whether a userinfo token
/// must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireUserInfoToken { get; set; }
///
/// Gets or sets a boolean indicating whether the authorization
/// code extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateAuthorizationCode { get; set; }
///
/// Gets or sets a boolean indicating whether the backchannel access
/// token extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateBackchannelAccessToken { get; set; }
///
/// Gets or sets a boolean indicating whether the backchannel identity
/// token extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateBackchannelIdentityToken { get; set; }
///
/// Gets or sets a boolean indicating whether the frontchannel access
/// token extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateFrontchannelAccessToken { get; set; }
///
/// Gets or sets a boolean indicating whether the frontchannel identity
/// token extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateFrontchannelIdentityToken { get; set; }
///
/// Gets or sets a boolean indicating whether the issued token
/// extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateIssuedToken { get; set; }
///
/// Gets or sets a boolean indicating whether the refresh token
/// extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateRefreshToken { get; set; }
///
/// Gets or sets a boolean indicating whether the state token
/// extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateStateToken { get; set; }
///
/// Gets or sets a boolean indicating whether the userinfo token
/// extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateUserInfoToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid authorization code
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectAuthorizationCode { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid backchannel access token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectBackchannelAccessToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid backchannel identity token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectBackchannelIdentityToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid frontchannel access token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectFrontchannelAccessToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid frontchannel identity token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectFrontchannelIdentityToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid issued token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectIssuedToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid refresh token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectRefreshToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid state token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectStateToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid userinfo token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectUserInfoToken { get; set; }
///
/// Gets or sets the actor token to send to the server, if applicable.
///
public string? ActorToken { get; set; }
///
/// Gets or sets the type of the actor token, if applicable.
///
public string? ActorTokenType { get; set; }
///
/// Gets or sets the authorization code to validate, if applicable.
///
public string? AuthorizationCode { get; set; }
///
/// Gets or sets the backchannel access token to validate, if applicable.
///
public string? BackchannelAccessToken { get; set; }
///
/// Gets or sets the expiration date of the backchannel access token, if applicable.
///
public DateTimeOffset? BackchannelAccessTokenExpirationDate { get; set; }
///
/// Gets or sets the backchannel identity token to validate, if applicable.
///
public string? BackchannelIdentityToken { get; set; }
///
/// Gets or sets the device code to validate, if applicable.
///
public string? DeviceCode { get; set; }
///
/// Gets or sets the frontchannel access token to validate, if applicable.
///
public string? FrontchannelAccessToken { get; set; }
///
/// Gets or sets the expiration date of the frontchannel access token, if applicable.
///
public DateTimeOffset? FrontchannelAccessTokenExpirationDate { get; set; }
///
/// Gets or sets the frontchannel identity token to validate, if applicable.
///
public string? FrontchannelIdentityToken { get; set; }
///
/// Gets or sets the issued token to validate, if applicable.
///
public string? IssuedToken { get; set; }
///
/// Gets or sets the expiration date of the issued token, if applicable.
///
public DateTimeOffset? IssuedTokenExpirationDate { get; set; }
///
/// Gets or sets the type of the issued token, if applicable.
///
public string? IssuedTokenType { get; set; }
///
/// Gets or sets the refresh token to validate, if applicable.
///
public string? RefreshToken { get; set; }
///
/// Gets or sets the username to send to the server, if applicable.
///
public string? Username { get; set; }
///
/// Gets or sets the password to send to the server, if applicable.
///
public string? Password { get; set; }
///
/// Gets or sets the type of the requested token to send to the server, if applicable.
///
public string? RequestedTokenType { get; set; }
///
/// Gets or sets the frontchannel state token to validate, if applicable.
///
public string? StateToken { get; set; }
///
/// Gets or sets the subject token to send to the server, if applicable.
///
public string? SubjectToken { get; set; }
///
/// Gets or sets the type of the subject token, if applicable.
///
public string? SubjectTokenType { get; set; }
///
/// Gets or sets the userinfo token to validate, if applicable.
///
public string? UserInfoToken { get; set; }
///
/// Gets or sets the principal extracted from the authorization code, if applicable.
///
public ClaimsPrincipal? AuthorizationCodePrincipal { get; set; }
///
/// Gets or sets the principal extracted from the backchannel access token, if applicable.
///
public ClaimsPrincipal? BackchannelAccessTokenPrincipal { get; set; }
///
/// Gets or sets the principal extracted from the backchannel identity token, if applicable.
///
public ClaimsPrincipal? BackchannelIdentityTokenPrincipal { get; set; }
///
/// Gets or sets the principal extracted from the frontchannel access token, if applicable.
///
public ClaimsPrincipal? FrontchannelAccessTokenPrincipal { get; set; }
///
/// Gets or sets the principal extracted from the frontchannel identity token, if applicable.
///
public ClaimsPrincipal? FrontchannelIdentityTokenPrincipal { get; set; }
///
/// Gets or sets the principal extracted from the issued token, if applicable.
///
public ClaimsPrincipal? IssuedTokenPrincipal { get; set; }
///
/// Gets or sets the merged principal containing the claims of the other principals.
///
public ClaimsPrincipal MergedPrincipal { get; set; } = new ClaimsPrincipal(new ClaimsIdentity());
///
/// Gets or sets the principal extracted from the refresh token, if applicable.
///
public ClaimsPrincipal? RefreshTokenPrincipal { get; set; }
///
/// Gets or sets the principal extracted from the state token, if applicable.
///
public ClaimsPrincipal? StateTokenPrincipal { get; set; }
///
/// Gets or sets the principal extracted from the userinfo token, if applicable.
///
public ClaimsPrincipal? UserInfoTokenPrincipal { get; set; }
///
/// Gets or sets the request sent to the token endpoint, if applicable.
///
public OpenIddictRequest? TokenRequest { get; set; }
///
/// Gets or sets the response returned by the token endpoint, if applicable.
///
public OpenIddictResponse? TokenResponse { get; set; }
///
/// Gets or sets the request sent to the userinfo endpoint, if applicable.
///
public OpenIddictRequest? UserInfoRequest { get; set; }
///
/// Gets or sets the response returned by the userinfo endpoint, if applicable.
///
public OpenIddictResponse? UserInfoResponse { get; set; }
///
/// Gets or sets a boolean indicating whether a client assertion
/// token should be generated (and optionally included in the request).
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool GenerateClientAssertion { get; set; }
///
/// Gets or sets a boolean indicating whether the generated client
/// assertion should be included as part of the request.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool IncludeClientAssertion { get; set; }
///
/// Gets or sets the generated client assertion, if applicable.
/// The client assertion will only be returned if
/// is set to .
///
public string? ClientAssertion { get; set; }
///
/// Gets or sets type of the generated client assertion, if applicable.
/// The client assertion type will only be returned if
/// is set to .
///
public string? ClientAssertionType { get; set; }
///
/// Gets or sets the principal containing the claims that will be
/// used to create the client assertion, if applicable.
///
public ClaimsPrincipal? ClientAssertionPrincipal { get; set; }
///
/// Gets or sets a boolean indicating whether backchannel
/// identity token nonce validation should be disabled.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool DisableBackchannelIdentityTokenNonceValidation { get; set; }
///
/// Gets or sets a boolean indicating whether frontchannel
/// identity token nonce validation should be disabled.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool DisableFrontchannelIdentityTokenNonceValidation { get; set; }
///
/// Gets or sets a boolean indicating whether issuer parameter validation should be disabled.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool DisableIssuerParameterValidation { get; set; }
///
/// Gets or sets a boolean indicating whether userinfo retrieval should be disabled.
///
public bool DisableUserInfoRetrieval { get; set; }
///
/// Gets or sets a boolean indicating whether userinfo validation should be disabled.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool DisableUserInfoValidation { get; set; }
}
///
/// Represents an event called when processing a challenge operation.
///
public sealed class ProcessChallengeContext : BaseValidatingTicketContext
{
///
/// Creates a new instance of the class.
///
public ProcessChallengeContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
///
/// Gets or sets the response.
///
public OpenIddictResponse Response
{
get => Transaction.Response!;
set => Transaction.Response = value;
}
///
/// Gets the user-defined authentication properties, if available.
///
public Dictionary Properties { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets the identifier that will be used to resolve the client registration, if applicable.
///
public string? RegistrationId { get; set; }
///
/// Gets or sets the issuer URI of the provider that will be
/// used to resolve the client registration, if applicable.
///
public Uri? Issuer { get; set; }
///
/// Gets or sets the name of the provider that will be
/// used to resolve the client registration, if applicable.
///
public string? ProviderName { get; set; }
///
/// Gets or sets the URI of the authorization endpoint, if applicable.
///
public Uri? AuthorizationEndpoint { get; set; }
///
/// Gets the additional parameters returned to the caller.
///
public Dictionary Parameters { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets the client identifier that will be used for the challenge demand.
///
public string? ClientId { get; set; }
///
/// Gets or sets the grant type that will be used for the challenge demand.
///
public string? GrantType { get; set; }
///
/// Gets or sets the response mode that will be
/// used for the challenge demand, if applicable.
///
public string? ResponseMode { get; set; }
///
/// Gets or sets the response type that will be
/// used for the challenge demand, if applicable.
///
public string? ResponseType { get; set; }
///
/// Gets or sets the redirection endpoint that will
/// be used for the challenge demand, if applicable.
///
[StringSyntax(StringSyntaxAttribute.Uri)]
public string? RedirectUri { get; set; }
///
/// Gets or sets the code challenge that will
/// be used for the challenge demand, if applicable.
///
public string? CodeChallenge { get; set; }
///
/// Gets or sets the code challenge method that will
/// be used for the challenge demand, if applicable.
///
public string? CodeChallengeMethod { get; set; }
///
/// Gets or sets the code verifier that will be stored in the state token, if applicable.
///
public string? CodeVerifier { get; set; }
///
/// Gets or sets the nonce that will be used for the challenge demand, if applicable.
/// Note: this value MUST NOT be user-defined or extracted from any request and MUST be random
/// (generated by a random number generator suitable for cryptographic operations).
///
public string? Nonce { get; set; }
///
/// Gets or sets the request forgery protection that will be stored in the state token, if applicable.
/// Note: this value MUST NOT be user-defined or extracted from any request and MUST be random
/// (generated by a random number generator suitable for cryptographic operations).
///
public string? RequestForgeryProtection { get; set; }
///
/// Gets or sets the optional target link URI that will be stored in the state token, if applicable.
///
[StringSyntax(StringSyntaxAttribute.Uri)]
public string? TargetLinkUri { get; set; }
///
/// Gets or sets the optional identity token hint that will
/// be sent to the authorization server, if applicable.
///
public string? IdentityTokenHint { get; set; }
///
/// Gets or sets the optional login hint that will be sent to the authorization server, if applicable.
///
public string? LoginHint { get; set; }
///
/// Gets the set of audiences that will be requested to the authorization server.
///
public HashSet Audiences { get; } = new(StringComparer.Ordinal);
///
/// Gets the set of resources that will be requested to the authorization server.
///
public HashSet Resources { get; } = new(StringComparer.Ordinal);
///
/// Gets the set of scopes that will be requested to the authorization server.
///
public HashSet Scopes { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets the URI of the device authorization endpoint, if applicable.
///
public Uri? DeviceAuthorizationEndpoint { get; set; }
///
/// Gets or sets the client authentication method used when
/// communicating with the device authorization endpoint, if applicable.
///
public string? DeviceAuthorizationEndpointClientAuthenticationMethod { get; set; }
///
/// Gets or sets the X.509 client certificate used when communicating
/// with the device authorization endpoint, if applicable.
///
public X509Certificate2? DeviceAuthorizationEndpointClientCertificate { get; set; }
///
/// Gets or sets the URI of the pushed authorization endpoint, if applicable.
///
public Uri? PushedAuthorizationEndpoint { get; set; }
///
/// Gets or sets the client authentication method used when communicating
/// with the pushed authorization endpoint, if applicable.
///
public string? PushedAuthorizationEndpointClientAuthenticationMethod { get; set; }
///
/// Gets or sets the X.509 client certificate used when communicating
/// with the pushed authorization endpoint, if applicable.
///
public X509Certificate2? PushedAuthorizationEndpointClientCertificate { get; set; }
///
/// Gets or sets a boolean indicating whether a state token
/// should be generated (and optionally included in the request).
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool GenerateStateToken { get; set; }
///
/// Gets or sets a boolean indicating whether the generated
/// state token should be included as part of the request.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool IncludeStateToken { get; set; }
///
/// Gets or sets the generated state token, if applicable.
/// The state token will only be returned if
/// is set to .
///
public string? StateToken { get; set; }
///
/// Gets or sets a boolean indicating whether a device authorization request should be sent.
///
public bool SendDeviceAuthorizationRequest { get; set; }
///
/// Gets or sets a boolean indicating whether a pushed authorization request should be sent.
///
public bool SendPushedAuthorizationRequest { get; set; }
///
/// Gets or sets a boolean indicating whether a client assertion
/// token should be generated (and optionally included in the request).
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool GenerateClientAssertion { get; set; }
///
/// Gets or sets a boolean indicating whether the generated client
/// assertion should be included as part of the request.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool IncludeClientAssertion { get; set; }
///
/// Gets or sets the generated client assertion, if applicable.
/// The client assertion will only be returned if
/// is set to .
///
public string? ClientAssertion { get; set; }
///
/// Gets or sets type of the generated client assertion, if applicable.
/// The client assertion type will only be returned if
/// is set to .
///
public string? ClientAssertionType { get; set; }
///
/// Gets or sets the principal containing the claims that will be
/// used to create the client assertion, if applicable.
///
public ClaimsPrincipal? ClientAssertionPrincipal { get; set; }
///
/// Gets or sets the principal containing the claims that
/// will be used to create the state token, if applicable.
///
public ClaimsPrincipal? StateTokenPrincipal { get; set; }
///
/// Gets or sets the request sent to the device authorization endpoint, if applicable.
///
public OpenIddictRequest? DeviceAuthorizationRequest { get; set; }
///
/// Gets or sets the response returned by the device authorization endpoint, if applicable.
///
public OpenIddictResponse? DeviceAuthorizationResponse { get; set; }
///
/// Gets or sets the request sent to the pushed authorization endpoint, if applicable.
///
public OpenIddictRequest? PushedAuthorizationRequest { get; set; }
///
/// Gets or sets the response returned by the pushed authorization endpoint, if applicable.
///
public OpenIddictResponse? PushedAuthorizationResponse { get; set; }
///
/// Gets or sets a boolean indicating whether a device
/// code should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractDeviceCode { get; set; }
///
/// Gets or sets a boolean indicating whether a request token
/// should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractRequestToken { get; set; }
///
/// Gets or sets a boolean indicating whether a user
/// code should be extracted from the current context.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ExtractUserCode { get; set; }
///
/// Gets or sets a boolean indicating whether a device code must
/// be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireDeviceCode { get; set; }
///
/// Gets or sets a boolean indicating whether a request token
/// must be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireRequestToken { get; set; }
///
/// Gets or sets a boolean indicating whether a user code must
/// be resolved for the authentication to be considered valid.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RequireUserCode { get; set; }
///
/// Gets or sets a boolean indicating whether the device code
/// extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateDeviceCode { get; set; }
///
/// Gets or sets a boolean indicating whether the request token
/// extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateRequestToken { get; set; }
///
/// Gets or sets a boolean indicating whether the user code
/// extracted from the current context should be validated.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool ValidateUserCode { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid device code will
/// cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectDeviceCode { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid request token
/// will cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectRequestToken { get; set; }
///
/// Gets or sets a boolean indicating whether an invalid user code will
/// cause the authentication demand to be rejected or will be ignored.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool RejectUserCode { get; set; }
///
/// Gets or sets the device code to validate, if applicable.
///
public string? DeviceCode { get; set; }
///
/// Gets or sets the request token to validate, if applicable.
///
public string? RequestToken { get; set; }
///
/// Gets or sets the user code to validate, if applicable.
///
public string? UserCode { get; set; }
}
///
/// Represents an event called when processing an introspection operation.
///
public sealed class ProcessIntrospectionContext : BaseValidatingTicketContext
{
///
/// Creates a new instance of the class.
///
public ProcessIntrospectionContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
///
/// Gets or sets the response.
///
public OpenIddictResponse Response
{
get => Transaction.Response!;
set => Transaction.Response = value;
}
///
/// Gets or sets the token to introspect.
///
public string? Token { get; set; }
///
/// Gets or sets the token type of the token to introspect, used as a hint by the remote server.
///
public string? TokenTypeHint { get; set; }
///
/// Gets the user-defined authentication properties, if available.
///
public Dictionary Properties { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets the identifier that will be used to resolve the client registration, if applicable.
///
public string? RegistrationId { get; set; }
///
/// Gets or sets the issuer URI of the provider that will be
/// used to resolve the client registration, if applicable.
///
public Uri? Issuer { get; set; }
///
/// Gets or sets the name of the provider that will be
/// used to resolve the client registration, if applicable.
///
public string? ProviderName { get; set; }
///
/// Gets or sets the URI of the introspection endpoint, if applicable.
///
public Uri? IntrospectionEndpoint { get; set; }
///
/// Gets or sets the client authentication method used when
/// communicating with the introspection endpoint, if applicable.
///
public string? IntrospectionEndpointClientAuthenticationMethod { get; set; }
///
/// Gets or sets the X.509 client certificate used when
/// communicating with the introspection endpoint, if applicable.
///
public X509Certificate2? IntrospectionEndpointClientCertificate { get; set; }
///
/// Gets or sets the client identifier that will be used for the introspection demand.
///
public string? ClientId { get; set; }
///
/// Gets or sets a boolean indicating whether an introspection request should be sent.
///
public bool SendIntrospectionRequest { get; set; }
///
/// Gets or sets a boolean indicating whether a client assertion
/// token should be generated (and optionally included in the request).
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool GenerateClientAssertion { get; set; }
///
/// Gets or sets a boolean indicating whether the generated client
/// assertion should be included as part of the request.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool IncludeClientAssertion { get; set; }
///
/// Gets or sets the generated client assertion, if applicable.
/// The client assertion will only be returned if
/// is set to .
///
public string? ClientAssertion { get; set; }
///
/// Gets or sets type of the generated client assertion, if applicable.
/// The client assertion type will only be returned if
/// is set to .
///
public string? ClientAssertionType { get; set; }
///
/// Gets or sets the principal containing the claims that will be
/// used to create the client assertion, if applicable.
///
public ClaimsPrincipal? ClientAssertionPrincipal { get; set; }
///
/// Gets or sets the request sent to the introspection endpoint, if applicable.
///
public OpenIddictRequest? IntrospectionRequest { get; set; }
///
/// Gets or sets the response returned by the introspection endpoint, if applicable.
///
public OpenIddictResponse? IntrospectionResponse { get; set; }
}
///
/// Represents an event called when processing an revocation operation.
///
public sealed class ProcessRevocationContext : BaseValidatingContext
{
///
/// Creates a new instance of the class.
///
public ProcessRevocationContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
///
/// Gets or sets the response.
///
public OpenIddictResponse Response
{
get => Transaction.Response!;
set => Transaction.Response = value;
}
///
/// Gets or sets the token to introspect.
///
public string? Token { get; set; }
///
/// Gets or sets the token type of the token to introspect, used as a hint by the remote server.
///
public string? TokenTypeHint { get; set; }
///
/// Gets the user-defined authentication properties, if available.
///
public Dictionary Properties { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets the identifier that will be used to resolve the client registration, if applicable.
///
public string? RegistrationId { get; set; }
///
/// Gets or sets the issuer URI of the provider that will be
/// used to resolve the client registration, if applicable.
///
public Uri? Issuer { get; set; }
///
/// Gets or sets the name of the provider that will be
/// used to resolve the client registration, if applicable.
///
public string? ProviderName { get; set; }
///
/// Gets or sets the URI of the revocation endpoint, if applicable.
///
public Uri? RevocationEndpoint { get; set; }
///
/// Gets or sets the client authentication method used when
/// communicating with the revocation endpoint, if applicable.
///
public string? RevocationEndpointClientAuthenticationMethod { get; set; }
///
/// Gets or sets the X.509 client certificate used when
/// communicating with the revocation endpoint, if applicable.
///
public X509Certificate2? RevocationEndpointClientCertificate { get; set; }
///
/// Gets or sets the client identifier that will be used for the revocation demand.
///
public string? ClientId { get; set; }
///
/// Gets or sets a boolean indicating whether an revocation request should be sent.
///
public bool SendRevocationRequest { get; set; }
///
/// Gets or sets a boolean indicating whether a client assertion
/// token should be generated (and optionally included in the request).
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool GenerateClientAssertion { get; set; }
///
/// Gets or sets a boolean indicating whether the generated client
/// assertion should be included as part of the request.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool IncludeClientAssertion { get; set; }
///
/// Gets or sets the generated client assertion, if applicable.
/// The client assertion will only be returned if
/// is set to .
///
public string? ClientAssertion { get; set; }
///
/// Gets or sets type of the generated client assertion, if applicable.
/// The client assertion type will only be returned if
/// is set to .
///
public string? ClientAssertionType { get; set; }
///
/// Gets or sets the principal containing the claims that will be
/// used to create the client assertion, if applicable.
///
public ClaimsPrincipal? ClientAssertionPrincipal { get; set; }
///
/// Gets or sets the request sent to the revocation endpoint, if applicable.
///
public OpenIddictRequest? RevocationRequest { get; set; }
///
/// Gets or sets the response returned by the revocation endpoint, if applicable.
///
public OpenIddictResponse? RevocationResponse { get; set; }
}
///
/// Represents an event called when processing a sign-out response.
///
public sealed class ProcessSignOutContext : BaseValidatingTicketContext
{
///
/// Creates a new instance of the class.
///
public ProcessSignOutContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
///
/// Gets or sets the response.
///
public OpenIddictResponse Response
{
get => Transaction.Response!;
set => Transaction.Response = value;
}
///
/// Gets the user-defined authentication properties, if available.
///
public Dictionary Properties { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets the identifier that will be used to resolve the client registration, if applicable.
///
public string? RegistrationId { get; set; }
///
/// Gets or sets the issuer URI of the provider that will be
/// used to resolve the client registration, if applicable.
///
public Uri? Issuer { get; set; }
///
/// Gets or sets the name of the provider that will be
/// used to resolve the client registration, if applicable.
///
public string? ProviderName { get; set; }
///
/// Gets or sets the URI of the end session endpoint, if applicable.
///
public Uri? EndSessionEndpoint { get; set; }
///
/// Gets or sets the client identifier that will be used for the sign-out demand.
///
public string? ClientId { get; set; }
///
/// Gets or sets the post-logout redirection endpoint that
/// will be used for the sign-out demand, if applicable.
///
[StringSyntax(StringSyntaxAttribute.Uri)]
public string? PostLogoutRedirectUri { get; set; }
///
/// Gets or sets the optional identity token hint that will
/// be sent to the authorization server, if applicable.
///
public string? IdentityTokenHint { get; set; }
///
/// Gets or sets the optional login hint that will be sent to the authorization server, if applicable.
///
public string? LoginHint { get; set; }
///
/// Gets or sets the optional target link URI that will be stored in the state token, if applicable.
///
public string? TargetLinkUri { get; set; }
///
/// Gets or sets the nonce that will be used for the sign-out demand, if applicable.
/// Note: this value MUST NOT be user-defined or extracted from any request and MUST be random
/// (generated by a random number generator suitable for cryptographic operations).
///
public string? Nonce { get; set; }
///
/// Gets or sets the request forgery protection that will be stored in the state token, if applicable.
/// Note: this value MUST NOT be user-defined or extracted from any request and MUST be random
/// (generated by a random number generator suitable for cryptographic operations).
///
public string? RequestForgeryProtection { get; set; }
///
/// Gets the additional parameters returned to the caller.
///
public Dictionary Parameters { get; } = new(StringComparer.Ordinal);
///
/// Gets or sets a boolean indicating whether a state token
/// should be generated (and optionally included in the request).
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool GenerateStateToken { get; set; }
///
/// Gets or sets a boolean indicating whether the generated
/// state token should be included as part of the request.
///
///
/// Note: overriding the value of this property is generally not recommended.
///
public bool IncludeStateToken { get; set; }
///
/// Gets or sets the generated state token, if applicable.
/// The state token will only be returned if
/// is set to .
///
public string? StateToken { get; set; }
///
/// Gets or sets the principal containing the claims that
/// will be used to create the state token, if applicable.
///
public ClaimsPrincipal? StateTokenPrincipal { get; set; }
}
}