Class AuthenticationModuleBase
Base class for authentication modules.
Inherited Members
Namespace: EmbedIO.Authentication
Syntax
public abstract class AuthenticationModuleBase : WebModuleBase, IWebModuleImpl, IWebModule
Constructors
AuthenticationModuleBase(String)
Initializes a new instance of the AuthenticationModuleBase class.
Declaration
protected AuthenticationModuleBase(string baseRoute)
Parameters
Type | Name | Description |
---|---|---|
String | baseRoute | The base route served by this module. |
Properties
IsFinalHandler
Gets a value indicating whether processing of a request should stop after a module has handled it.
Declaration
public override sealed bool IsFinalHandler { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
Remarks
Authentication modules, i.e. modules derived from AuthenticationModuleBase, always have this property set to false.
See Also
OnInvalidCredentials
Gets or sets an AuthenticationHandlerCallback that is called if a request contains invalid credentials.
The default is Unauthorized(IHttpContext, AuthenticationModuleBase).
Declaration
public AuthenticationHandlerCallback OnInvalidCredentials { get; set; }
Property Value
Type | Description |
---|---|
AuthenticationHandlerCallback |
See Also
OnMissingCredentials
Gets or sets an AuthenticationHandlerCallback that is called if
authentication could not take place. For example, BasicAuthenticationModuleBase
calls this handler if the request has no Authorization
header.
The default is Unauthorized(IHttpContext, AuthenticationModuleBase).
Declaration
public AuthenticationHandlerCallback OnMissingCredentials { get; set; }
Property Value
Type | Description |
---|---|
AuthenticationHandlerCallback |
See Also
Methods
AuthenticateAsync(IHttpContext)
Asynchronously authenticates a user, based on a request's contents,
yielding an
Declaration
protected abstract Task<IPrincipal> AuthenticateAsync(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The HTTP context of the request. |
Returns
Type | Description | ||||||
---|---|---|---|---|---|---|---|
Task<IPrincipal> | A
|
Remarks
this method will not be called if the context
has an
This way, two or more authentication modules may be added to a WebServer. The first one that succeeds in retrieving user credentials from the request, whether valid or not, will cause subsequent authentication modules to skip processing the HTTP context completely.
OnRequestAsync(IHttpContext)
Called to handle a request from a client.
Declaration
protected override sealed Task OnRequestAsync(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The context of the request being handled. |
Returns
Type | Description |
---|---|
Task | A |