Class BasicAuthenticationModuleBase
Base class for authentication modules using HTTP basic authentication.
Inheritance
Inherited Members
Namespace: EmbedIO.Authentication
Syntax
public abstract class BasicAuthenticationModuleBase : AuthenticationModuleBase, IWebModuleImpl, IWebModule
Constructors
BasicAuthenticationModuleBase(String, String)
Initializes a new instance of the BasicAuthenticationModuleBase class.
Declaration
protected BasicAuthenticationModuleBase(string baseRoute, string realm)
Parameters
Type | Name | Description |
---|---|---|
String | baseRoute | The base URL path. |
String | realm | The authentication realm. |
Remarks
Fields
AuthenticationType
The authentication type used by this module.
Declaration
public const string AuthenticationType = "Basic"
Field Value
Type | Description |
---|---|
String |
Properties
Realm
Gets the authentication realm.
Declaration
public string Realm { get; }
Property Value
Type | Description |
---|---|
String |
Methods
AuthenticateAsync(IHttpContext)
Asynchronously authenticates a user, based on a request's contents,
yielding an
Declaration
protected override sealed Task<IPrincipal> AuthenticateAsync(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The HTTP context of the request. |
Returns
Type | Description | ||||||
---|---|---|---|---|---|---|---|
Task<IPrincipal> | A
|
Overrides
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.
VerifyCredentialsAsync(String, String, String, IList<String>, CancellationToken)
Verifies the credentials given in the Authentication
request header.
Declaration
protected abstract Task<bool> VerifyCredentialsAsync(string path, string userName, string password, IList<string> roles, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
String | path | The URL path requested by the client. Note that this is relative to the module's BaseRoute. |
String | userName | The user name. |
String | password | The password, or the empty string if none has been given. |
IList<String> | roles | A list to which the user's roles can be added. |
CancellationToken | cancellationToken | A |
Returns
Type | Description |
---|---|
Task<Boolean> | A |