-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
Henri Normak edited this page Feb 18, 2016
·
6 revisions
The following page lists the entire public API of lambda-foundation.
Main authentication function, which takes a JWT token (HTTP Authorization header contents also works) and an optional set of requirements that the token has to satisfy. The function returns a promise, which either resolves into a decoded JWT token or rejects with an appropriate error (HTTP codes 401 if invalid token, or 403 if requirements not satisfied).
-
token
- Encoded/Signed JWT token (Bearer
prefix is stripped) -
requirements
- object describing the requirements, currently valid keys to use are:-
rule
- A constant from theRULE
property on the authentication module (ANY
,NONE
,ALL
), signifies which of the scopes the token has to have -
scope
- An array/Single scope that the token has to fulfil based on therule
(authentication exposes constants in theSCOPE
property -TESTER
,CLIENT
,QA
,ADMIN
)
-
Helper function for checking a decoded JWT token against requirements. Returns either true
or false
.
-
token
- Decoded JWT token -
requirements
- object describing the requirements, currently valid keys to use are:-
rule
- A constant from theRULE
property on the authentication module (ANY
,NONE
,ALL
), signifies which of the scopes the token has to have -
scope
- An array/Single scope that the token has to fulfil based on therule
(authentication exposes constants in theSCOPE
property -TESTER
,CLIENT
,QA
,ADMIN
)
-
Helper function for validating the signature of an encoded JWT token and decoding the contents. Returns the decoded JWT token, throws an error if one occurs (for example the signature of the token is invalid).
-
token
- Encoded JWT token