Skip to content

API Reference

Henri Normak edited this page Feb 18, 2016 · 6 revisions

API Reference

The following page lists the entire public API of lambda-foundation.

Table of Contents

Authentication

authenticate(token, requirements)

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).

Parameters

  • token - Encoded/Signed JWT token (Bearer prefix is stripped)
  • requirements - object describing the requirements, currently valid keys to use are:
    1. rule - A constant from the RULE property on the authentication module (ANY, NONE, ALL), signifies which of the scopes the token has to have
    2. scope - An array/Single scope that the token has to fulfil based on the rule (authentication exposes constants in the SCOPE property - TESTER, CLIENT, QA, ADMIN)

isAuthorized(token, requirements)

Helper function for checking a decoded JWT token against requirements. Returns either true or false.

Parameters

  • token - Decoded JWT token
  • requirements - object describing the requirements, currently valid keys to use are:
    1. rule - A constant from the RULE property on the authentication module (ANY, NONE, ALL), signifies which of the scopes the token has to have
    2. scope - An array/Single scope that the token has to fulfil based on the rule (authentication exposes constants in the SCOPE property - TESTER, CLIENT, QA, ADMIN)

isValidToken(token)

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).

Parameters

  • token - Encoded JWT token

Configuration

Discovery

Error

Clone this wiki locally