Class: BearerAuthenticator

x2node-ws. BearerAuthenticator

Base abstract class for authenticators that use "Bearer" token in the "Authorization" HTTP request header (see RFC 6750).

<abstract> new BearerAuthenticator()

Implements:

Methods


addResponseHeaders(call, response)

If present on the authenticator, called before sending HTTP response to give the authenticator a chance to add any authenticator-specific headers to the response.
Parameters:
Name Type Description
call module:x2node-ws~ServiceCall The call.
response module:x2node-ws~ServiceResponse The response.
Implements:

authenticate(call)

Authenticate the call.
Parameters:
Name Type Description
call module:x2node-ws~ServiceCall The call.
Implements:
Returns:
Authenticated actor, null if could not authenticate, or a Promise of the above.
Type
module:x2node-common.Actor | Promise.<module:x2node-common.Actor>

<abstract> validateToken(token, call)

Validate Bearer token and convert it to the actor. This method must be overridden and implemented in the subclass.
Parameters:
Name Type Description
token string Bearer token from the "Auithorization" header.
call module:x2node-ws~ServiceCall The call.
Returns:
Authenticated actor, null if could not authenticate, or a Promise of the above.
Type
module:x2node-common.Actor | Promise.<module:x2node-common.Actor>