CredentialsPluginProtocol

public protocol CredentialsPluginProtocol

The protocol that defines the API for Credentials plugins for authentication of incoming requests.

  • The name of the plugin.

    Declaration

    Swift

    var name: String { get }
  • User profile cache.

    Declaration

    Swift

    var usersCache: NSCache<NSString, BaseCacheElement>? { get set }
  • An indication as to whether the plugin is redirecting or not. The redirecting scheme is used for web session authentication, where the users, that are not logged in, are redirected to a login page. All other types of authentication are non-redirecting, i.e., unauthorized requests are rejected.

    Declaration

    Swift

    var redirecting: Bool { get }
  • Authenticate an incoming request.

    Declaration

    Swift

    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 (usually an authentication token) in the request.

    inProgress

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

  • userProfileDelegate Default implementation

    A delegate for UserProfile manipulation.

    Default Implementation

    The default (nil) value for UserProfileDelegate.

    Declaration

    Swift

    var userProfileDelegate: UserProfileDelegate? { get }