/* * 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.Security.Claims; namespace OpenIddict.Client; public static partial class OpenIddictClientEvents { /// /// Represents an event called for each request to the authorization endpoint to give the user code /// a chance to manually update the authorization request before it is sent to the identity provider. /// public class PrepareAuthorizationRequestContext : BaseValidatingContext { /// /// Creates a new instance of the class. /// public PrepareAuthorizationRequestContext(OpenIddictClientTransaction transaction) : base(transaction) { } /// /// Gets or sets the request. /// public OpenIddictRequest Request { get => Transaction.Request!; set => Transaction.Request = value; } /// /// Gets or sets the principal containing the claims stored in the state object. /// public ClaimsPrincipal StatePrincipal { get; set; } = new ClaimsPrincipal(new ClaimsIdentity()); } /// /// Represents an event called for each request to the authorization endpoint /// to give the user code a chance to manually send the authorization request. /// public class ApplyAuthorizationRequestContext : BaseValidatingContext { /// /// Creates a new instance of the class. /// public ApplyAuthorizationRequestContext(OpenIddictClientTransaction transaction) : base(transaction) { } /// /// Gets or sets the request. /// public OpenIddictRequest Request { get => Transaction.Request!; set => Transaction.Request = value; } public string AuthorizationEndpoint { get; set; } = null!; } /// /// Represents an event called for each request to the redirection endpoint to give the user code /// a chance to manually extract the redirection request from the ambient HTTP context. /// public class ExtractRedirectionRequestContext : BaseValidatingContext { /// /// Creates a new instance of the class. /// public ExtractRedirectionRequestContext(OpenIddictClientTransaction transaction) : base(transaction) { } /// /// Gets or sets the request or if it was extracted yet. /// public OpenIddictRequest? Request { get => Transaction.Request; set => Transaction.Request = value; } } /// /// Represents an event called for each request to the redirection endpoint /// to determine if the request is valid and should continue to be processed. /// public class ValidateRedirectionRequestContext : BaseValidatingContext { /// /// Creates a new instance of the class. /// public ValidateRedirectionRequestContext(OpenIddictClientTransaction transaction) : base(transaction) { } /// /// Gets or sets the request. /// public OpenIddictRequest Request { get => Transaction.Request!; set => Transaction.Request = value; } /// /// Gets or sets the security principal extracted from the identity token, /// if applicable to the current redirection request. If no identity token /// is available at the validation stage, a token request will typically be /// sent to retrieve a complete set of tokens (e.g authorization code flow). /// public ClaimsPrincipal? Principal { get; set; } /// /// Gets or sets the security principal extracted from the state token. /// public ClaimsPrincipal? StateTokenPrincipal { get; set; } } /// /// Represents an event called for each validated redirection request /// to allow the user code to decide how the request should be handled. /// public class HandleRedirectionRequestContext : BaseValidatingTicketContext { /// /// Creates a new instance of the class. /// public HandleRedirectionRequestContext(OpenIddictClientTransaction transaction) : base(transaction) { } /// /// Gets or sets the request. /// public OpenIddictRequest Request { get => Transaction.Request!; set => Transaction.Request = value; } /// /// Gets the additional parameters returned to the client application. /// public Dictionary Parameters { get; private set; } = new(StringComparer.Ordinal); } /// /// Represents an event called before the redirection response is returned to the caller. /// public class ApplyRedirectionResponseContext : BaseRequestContext { /// /// Creates a new instance of the class. /// public ApplyRedirectionResponseContext(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; } } }