node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »

@financial-times/s3o-lambda

S3O in Lambda

This library makes it a lot easier & faster to secure the HTTP endpoints of AWS Lambda-based serverless applications to FT staff only.

Installation

npm install --save @financial-times/s3o-lambda

Usage

The whole thing is streamlined, including the redirection to and the callback from S3O. All you need is the below:

const s3o = require('@financial-times/s3o-lambda');
 
module.exports.handler = (event, context, callback) => {
    s3o(event, callback).then(isSignedIn => {
        if (isSignedIn) {
            // do what you want here
            callback(null, { statusCode: 200, body: 'You are signed in.' });
        }
    });
};

This library will redirect the user to sign in using Google if not signed in, and return the user to this same page when successful.