CredentialsHTTPBasic

public class CredentialsHTTPBasic : CredentialsPluginProtocol

Authenticate requests using HTTP Basic authentication. See RFC 7617 for details.

  • The name of the plugin.

    Declaration

    Swift

    public var name: String
  • An indication as to whether the plugin is redirecting or not.

    Declaration

    Swift

    public var redirecting: Bool
  • User profile cache.

    Declaration

    Swift

    public var usersCache: NSCache<NSString, BaseCacheElement>?
  • The authentication realm attribute.

    Declaration

    Swift

    public var realm: String
  • Initialize a CredentialsHTTPBasic instance.

    Declaration

    Swift

    @available(*, deprecated: 2.0, message: "userProfileLoader has been deprecated from Basic Authentication because of security improvements. Please use verifyPassword.")  public init (userProfileLoader: @escaping UserProfileLoader, realm: String?=nil)

    Parameters

    userProfileLoader

    The callback for loading the user profile.

    realm

    The realm attribute.

  • Initialize a CredentialsHTTPBasic instance.

    Declaration

    Swift

    public init (verifyPassword: @escaping VerifyPassword, realm: String?=nil)

    Parameters

    verifyPassword

    The callback for verifying the password of the user.

    realm

    The realm attribute.

  • Authenticate incoming request using HTTP Basic authentication.

    Declaration

    Swift

    public func authenticate (request: RouterRequest, response: RouterResponse,
                              options: [String:Any], onSuccess: @escaping (UserProfile) -> Void,
                              onFailure: @escaping (HTTPStatusCode?, [String:String]?) -> Void,
                              onPass: @escaping (HTTPStatusCode?, [String:String]?) -> Void,
                              inProgress: @escaping () -> Void)

    Parameters

    request

    The RouterRequest object used to get information about the request.

    response

    The RouterResponse object used to respond to the request.

    options

    The dictionary of plugin specific options.

    onSuccess

    The closure to invoke in the case of successful authentication.

    onFailure

    The closure to invoke in the case of an authentication failure.

    onPass

    The closure to invoke when the plugin doesn’t recognize the authentication data in the request.

    inProgress

    The closure to invoke to cause a redirect to the login page in the case of redirecting authentication.