Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

adobe/helix-auth-fastly

Helix Auth Fastly

Authenticate Helix actions against Fastly

Status

codecov CircleCI GitHub license GitHub issues LGTM Code Quality Grade: JavaScript semantic-release

Installation

$ npm install @adobe/helix-auth-fastly

Usage

As a wrapper

helix-auth-fastly is a wrapper around OpenWhisk actions to that ensures that invocations of the action are only successful if valid Fastly credentials, in the forms of a service ID and token, are provided.

helix-auth-fastly can also be used as a simple single-purpose function to validate a pair of Fastly credentials.

To use the helix-auth-fastly wrapper set up your OpenWhisk action like this:

const { wrap } = require('@adobe/openwhisk-action-utils'};
const { fastlyAuthWrapper } = require('@adobe/helix-auth-fastly'); 

const main = () = {
  // your action code goes here
};

module.exports.main = = wrap(action)
  .with(fastlyAuthWrapper, {token: 'tokenName', service: 'serviceName'});

Invocations of your action that do not provide valid credentials will fail with an HTTP status code of 401 (Unauthorized) and your main function will never be called.

Standalone

To use helix-auth-fastly conditionally; you can also execute:

const { authFastly } = require('@adobe/helix-auth-fastly');

if(await authFastly(token, service)){
    //authentication has succeeded
} else {
    //authentication has failed
}

See the API documentation.

Development

Build

$ npm install

Test

$ npm test

Lint

$ npm run lint