Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Authenticator

An authentication handler that processes authentication requests from the server.

Instances can be registered with the server using the AuthenticationControl feature.

The server calls an authentication handler when a client application creates a session, or changes the principal associated with a session, allowing the handler to veto individual requests.

Authentication handlers are configured in precedence order. Authentication will succeed if a handler responds by calling allow() or allow(map) and handlers with higher precedence respond by calling abstain().

Authentication will fail if a handler responds by calling deny() and all higher precedence handlers respond by calling abstain().

If all authentication handlers respond by calling abstain(), the request will be denied. Once the outcome is known, the server may choose not to call any remaining authentication handlers.

since

6.3

Hierarchy

  • Authenticator

Index

Methods

authenticate

  • Processes an authentication request.

    This method will be called to authenticate new sessions, and when a session requests that the session principal is changed (for example, using changePrincipal).

    For each call to authenticate, the handler should respond by calling one of the methods of the provided callback. The handler may return immediately and process the authentication request asynchronously. The authentication will not proceed until a callback method is called.

    The content of the sessionProperties parameter depends upon whether the authentication handler is being called on initial authentication of a session or as a result of a session re-authenticating using changePrincipal, as shown below:

    Initial Authentication changePrincipal
    Fixed Properties A full set of fixed session properties as defined in Session.

    $Principal will be the same as the supplied principal.

    $Roles will contain the configured default roles for the principal.

    A full set of fixed session properties as defined in Session.

    $Principal will be the principal from the previously authenticated session which may differ from the supplied principal.

    $Roles will contain the configured default roles for the new principal.

    User-defined Properties None Existing user-defined properties

    On initial authentication the proposedProperties parameter will provide any user-defined properties that the client supplied when opening the client session, but on re-authentication it will be empty

    The handler can choose to call allow() to accept the authentication request with default behavior or allow(map) to accept the authentication request with modifications to the session properties. Alternatively it may call deny() to deny the request or abstain() to abstain from authentication, in which case the request will be passed on to the next configured authentication handler.

    If the handler calls allow() then the resulting session properties for the session will be as follows:

    Initial Authentication changePrincipal
    Fixed Properties As supplied plus those assigned by the server on connection. As supplied but with $Principal replaced by the supplied principal.
    User-defined Properties None None

    If the handler calls allow(map) then the map may contain values for any fixed properties that can be changed/supplied (see below) and/or all user-defined properties to assign to the session. The user-defined properties may be those proposed by the client or they can be any set of user-defined properties that the handler chooses.

    Permitted fixed property adjustments

    An authentication handler can set values for any of the following fixed properties to allow(map):

    An authentication handler can only set values of these fixed properties. Other fixed properties provided by the handler will be ignored. If the handler does not set a fixed property, the value will be as supplied, or as assigned by the server.

    Handling the $Roles property

    The $Roles property is formatted as a quoted list of strings. To make the handling of this property value easier there are methods in the global diffusion namespace. Using these methods an authenticator can adjust roles as follows:

    const roles = diffusion.stringToRoles(
        sessionProperties.get(diffusion.clients.PropertyKeys.ROLES));
    
    ... changes roles are required ...
    
    sessionProperties.put(diffusion.clients.PropertyKeys.ROLES,
                          diffusion.rolesToString(roles));
    callback.allow(sessionProperties);

    Parameters

    • principal: string

      the name of the proposed principal, or ANONYMOUS if none was supplied

    • credentials: Credentials

      authenticating the principal; for example, a password

    • sessionProperties: SessionProperties

      supplies the currently known session properties for the client. On initial authentication this will be the known fixed property values. If the session is re-authenticating using changePrincipal, this will be the full set of fixed property values plus any user-defined properties from the existing session.

    • proposedProperties: SessionProperties

      provides any user-defined properties proposed by the client. The handler may choose to pass on these properties as they are, veto some properties, or add more properties before passing them to the result. The client can provide arbitrary keys and values. Supplied properties should be checked and filtered/constrained to ensure they do not affect the integrity of the application. Authentication handlers should not blindly pass proposed properties to allow.

    • callback: AuthenticatorCallback

      single use callback

    Returns void

onClose

  • onClose(): void
  • Notification that the authenticator was closed normally.

    No further calls to this authenticator will be made.

    Returns void

onError

  • onError(error: any): void
  • Notification of an error

    No further calls to this authenticator will be made.

    Parameters

    • error: any

      the error that occurred

    Returns void