Unosquare
    Show / Hide Table of Contents

    Class BasicAuthenticationModuleBase

    Base class for authentication modules using HTTP basic authentication.

    Inheritance
    Object
    WebModuleBase
    AuthenticationModuleBase
    BasicAuthenticationModuleBase
    BasicAuthenticationModule
    Implements
    IWebModuleImpl
    IWebModule
    Inherited Members
    AuthenticationModuleBase.IsFinalHandler
    AuthenticationModuleBase.OnMissingCredentials
    AuthenticationModuleBase.OnInvalidCredentials
    AuthenticationModuleBase.OnRequestAsync(IHttpContext)
    WebModuleBase.Container
    WebModuleBase.IWebModuleImpl.SetContainer(IWebModuleContainer)
    WebModuleBase.BaseRoute
    WebModuleBase.OnUnhandledException
    WebModuleBase.OnHttpException
    WebModuleBase.LogSource
    WebModuleBase.Start(CancellationToken)
    WebModuleBase.MatchUrlPath(String)
    WebModuleBase.HandleRequestAsync(IHttpContext)
    WebModuleBase.OnStart(CancellationToken)
    WebModuleBase.SetContainer(IWebModuleContainer)
    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

    If realm is null or the empty string, the Realm property will be set equal to BaseRoute.

    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 interface that will be assigned to the HTTP context's User property for use by other modules.

    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 whose result will be as follows:

    If authentication did not take place (for example, in the case of BasicAuthenticationModuleBase, when the request has no Authorization header)An interface, whose Identity property has both its Name and AuthenticationType properties set to the empty string. Returning NoUser is the fastest way in this case.
    If the request contains INVALID credentialsAn interface, whose Identity property has its Name property set to the empty string, and its AuthenticationType property set to a non-empty string. NoUser cannot be returned in this case.
    If the request contains VALID credentialsAn interface, whose Identity property has both its Name and AuthenticationType properties set to non-empty strings.

    Overrides
    AuthenticationModuleBase.AuthenticateAsync(IHttpContext)
    Remarks

    this method will not be called if the property assigned to the User property of context has an Identity with a non-empty AuthenticationType.

    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 use to cancel the operation.

    Returns
    Type Description
    Task<Boolean>

    A whose result will be true if the given credentials are valid, false if they are not.

    Implements

    IWebModuleImpl
    IWebModule

    Comments

    Back to top Copyright © 2017-2019 Unosquare