C# Class WebApiDoodle.Web.MessageHandlers.BasicAuthenticationHandler

HTTP Basic Authentication abstraction message handler
Inheritance: System.Net.Http.DelegatingHandler
ファイルを表示 Open project: tugberkugurlu/WebAPIDoodle

Public Methods

Method Description
BasicAuthenticationHandler ( ) : System

Parameterless constructor. Sets the SuppressIfAlreadyAuthenticated to false.

BasicAuthenticationHandler ( bool suppressIfAlreadyAuthenticated ) : System

Constructor to supply the SuppressIfAlreadyAuthenticated value.

Protected Methods

Method Description
AuthenticateUserAsync ( HttpRequestMessage request, string username, string password, CancellationToken cancellationToken ) : Task

The method which is responsable for authenticating the user based on the provided credentials.

HandleUnauthenticatedRequest ( UnauthenticatedRequestContext context ) : void

Called when the request is unauthenticated.

SendAsync ( HttpRequestMessage request, CancellationToken cancellationToken ) : Task

Private Methods

Method Description
EnsureRequestMessageExistence ( HttpResponseMessage response, HttpRequestMessage request ) : void
HandleUnauthenticatedRequestImpl ( HttpRequestMessage request, CancellationToken cancellationToken ) : Task
TryExtractBasicAuthCredentialsFromHeader ( string authorizationHeader, string &username, string &password ) : bool

Method Details

AuthenticateUserAsync() protected abstract method

The method which is responsable for authenticating the user based on the provided credentials.
protected abstract AuthenticateUserAsync ( HttpRequestMessage request, string username, string password, CancellationToken cancellationToken ) : Task
request System.Net.Http.HttpRequestMessage
username string The username value extracted from BasicAuth header.
password string The password value extracted from BasicAuth header.
cancellationToken System.Threading.CancellationToken A cancellation token to cancel operation.
return Task

BasicAuthenticationHandler() public method

Parameterless constructor. Sets the SuppressIfAlreadyAuthenticated to false.
public BasicAuthenticationHandler ( ) : System
return System

BasicAuthenticationHandler() public method

Constructor to supply the SuppressIfAlreadyAuthenticated value.
public BasicAuthenticationHandler ( bool suppressIfAlreadyAuthenticated ) : System
suppressIfAlreadyAuthenticated bool Indicates whether the authentication should be suppressed if the request is already authenticated.
return System

HandleUnauthenticatedRequest() protected method

Called when the request is unauthenticated.
protected HandleUnauthenticatedRequest ( UnauthenticatedRequestContext context ) : void
context UnauthenticatedRequestContext Context object which carries the HTTP request message to send to the server and the empty HTTP response property.
return void

SendAsync() protected method

protected SendAsync ( HttpRequestMessage request, CancellationToken cancellationToken ) : Task
request System.Net.Http.HttpRequestMessage
cancellationToken System.Threading.CancellationToken
return Task