Authenticate Helix actions against Fastly
$ npm install @adobe/helix-auth-fastly
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.
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.
$ npm install
$ npm test
$ npm run lint