Table of Contents

Class AuthenticationHandler

Namespace
Apizr.Authenticating
Assembly
Apizr.dll

The authentication handler implementation refreshing token

public class AuthenticationHandler : AuthenticationHandlerBase, IDisposable, IAuthenticationHandler
Inheritance
AuthenticationHandler
Implements
Inherited Members

Constructors

AuthenticationHandler(IApizrManagerOptionsBase, Func<HttpRequestMessage, string, CancellationToken, Task<string>>)

The authentication handler constructor

public AuthenticationHandler(IApizrManagerOptionsBase apizrOptions, Func<HttpRequestMessage, string, CancellationToken, Task<string>> refreshTokenFactory)

Parameters

apizrOptions IApizrManagerOptionsBase

The Apizr options

refreshTokenFactory Func<HttpRequestMessage, string, CancellationToken, Task<string>>

The refresh token factory

Exceptions

ArgumentNullException

AuthenticationHandler(IApizrManagerOptionsBase, Func<HttpRequestMessage, CancellationToken, Task<string>>)

The authentication handler constructor

public AuthenticationHandler(IApizrManagerOptionsBase apizrOptions, Func<HttpRequestMessage, CancellationToken, Task<string>> getTokenFactory)

Parameters

apizrOptions IApizrManagerOptionsBase

The Apizr options

getTokenFactory Func<HttpRequestMessage, CancellationToken, Task<string>>

The get token factory

Exceptions

ArgumentNullException

AuthenticationHandler(IApizrManagerOptionsBase, Func<HttpRequestMessage, CancellationToken, Task<string>>, Func<HttpRequestMessage, string, CancellationToken, Task>)

The authentication handler constructor

public AuthenticationHandler(IApizrManagerOptionsBase apizrOptions, Func<HttpRequestMessage, CancellationToken, Task<string>> getTokenFactory, Func<HttpRequestMessage, string, CancellationToken, Task> setTokenFactory)

Parameters

apizrOptions IApizrManagerOptionsBase

The Apizr options

getTokenFactory Func<HttpRequestMessage, CancellationToken, Task<string>>

The get token factory

setTokenFactory Func<HttpRequestMessage, string, CancellationToken, Task>

The set token factory

Exceptions

ArgumentNullException

AuthenticationHandler(IApizrManagerOptionsBase, Func<HttpRequestMessage, CancellationToken, Task<string>>, Func<HttpRequestMessage, string, CancellationToken, Task>, Func<HttpRequestMessage, string, CancellationToken, Task<string>>)

The authentication handler constructor

public AuthenticationHandler(IApizrManagerOptionsBase apizrOptions, Func<HttpRequestMessage, CancellationToken, Task<string>> getTokenFactory, Func<HttpRequestMessage, string, CancellationToken, Task> setTokenFactory, Func<HttpRequestMessage, string, CancellationToken, Task<string>> refreshTokenFactory)

Parameters

apizrOptions IApizrManagerOptionsBase

The Apizr options

getTokenFactory Func<HttpRequestMessage, CancellationToken, Task<string>>

The get token factory

setTokenFactory Func<HttpRequestMessage, string, CancellationToken, Task>

The set token factory

refreshTokenFactory Func<HttpRequestMessage, string, CancellationToken, Task<string>>

The refresh token factory

Exceptions

ArgumentNullException

Methods

GetTokenAsync(HttpRequestMessage, CancellationToken)

The method called to get local token

public override Task<string> GetTokenAsync(HttpRequestMessage request, CancellationToken ct = default)

Parameters

request HttpRequestMessage
ct CancellationToken

Returns

Task<string>

The saved token

RefreshTokenAsync(HttpRequestMessage, string, CancellationToken)

The method called to refresh token when rejected or empty

public override Task<string> RefreshTokenAsync(HttpRequestMessage request, string token, CancellationToken ct = default)

Parameters

request HttpRequestMessage

The request to authenticate

token string

The former token

ct CancellationToken

The cancellation token

Returns

Task<string>

The refreshed token

SetTokenAsync(HttpRequestMessage, string, CancellationToken)

The method called to set local token

public override Task SetTokenAsync(HttpRequestMessage request, string token, CancellationToken ct = default)

Parameters

request HttpRequestMessage

The request to authenticate

token string

The token to save

ct CancellationToken

The cancellation token

Returns

Task