Skip to main content

PasswordGrantHandler Class

Abblix.Oidc.Server

Abblix.Oidc.Server.Endpoints.Token.Grants

PasswordGrantHandler Class

Handles the authorization process for the password grant type within the OAuth 2.0 framework. This handler validates the user's credentials and processes token requests based on the password grant type. The password grant type allows clients to directly exchange a user's credentials (username and password) for an access token, typically for trusted clients.

public class PasswordGrantHandler : Abblix.Oidc.Server.Endpoints.Token.Grants.IAuthorizationGrantHandler, Abblix.Oidc.Server.Common.Interfaces.IGrantTypeInformer

Inheritance System.Object → PasswordGrantHandler

Implements IAuthorizationGrantHandler, IGrantTypeInformer

Constructors

PasswordGrantHandler(IUserCredentialsAuthenticator) Constructor

Handles the authorization process for the password grant type within the OAuth 2.0 framework. This handler validates the user's credentials and processes token requests based on the password grant type. The password grant type allows clients to directly exchange a user's credentials (username and password) for an access token, typically for trusted clients.

public PasswordGrantHandler(Abblix.Oidc.Server.Common.Interfaces.IUserCredentialsAuthenticator userCredentialsAuthenticator);

Parameters

userCredentialsAuthenticator IUserCredentialsAuthenticator

A service for authenticating the user's credentials.

Properties

PasswordGrantHandler.GrantTypesSupported Property

Specifies the grant type that this handler supports, which is the "password" grant type. This ensures that this handler is only invoked when processing requests with the password grant type.

public System.Collections.Generic.IEnumerable<string> GrantTypesSupported { get; }

Implements GrantTypesSupported

Property Value

System.Collections.Generic.IEnumerable<System.String>

Methods

PasswordGrantHandler.AuthorizeAsync(TokenRequest, ClientInfo) Method

Asynchronously processes the token request using the password grant type. The handler ensures the request contains the necessary parameters, validates the user's credentials, and then proceeds to authorize the request if the credentials are valid. It delegates credential validation to the user credentials authenticator, which handles the security checks related to user authentication.

public System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Endpoints.Token.Interfaces.AuthorizedGrant,Abblix.Oidc.Server.Common.OidcError>> AuthorizeAsync(Abblix.Oidc.Server.Model.TokenRequest request, Abblix.Oidc.Server.Features.ClientInformation.ClientInfo clientInfo);

Parameters

request TokenRequest

The token request containing the user's credentials and other parameters.

clientInfo ClientInfo

Information about the client making the request, used for validation and context.

Implements AuthorizeAsync(TokenRequest, ClientInfo)

Returns

System.Threading.Tasks.Task<Abblix.Utils.Result<AuthorizedGrant,OidcError>>
A task that completes with the authorization result, which could be an error or successful grant.