1.1.6 • Published 5 years ago

sling-auth v1.1.6

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Sling Authentication

Sling AWS STS authentication module

This module is used to turn credentials from the news AWS root account (311417952909) into usable credentials for a sling role.

Examples

Below examples of Sling Authentication API:

Get roles shortnames (#SlingAuth.getRoleShortnames({environment: 'environment'}))

This method returns an array of valid role shortnames for a environment. The shortname is required by other methods.

Example:

const SlingAuth = require('sling-auth');
SlingAuth.getRoleShortnames({environment: 'live'}); // Static method (SlingAuth isn't initalised)

Output:

=> ['neareast', 'news', 'southasia']

Get role credentials (#getRoleCredentials(options))

This method returns a Promise which is resolved with the role credentials. These credentials can then be used with Sling to upload, modify and delete files from S3, in locations that the role is permitted.

Example:

const SlingAuth = require('sling-auth');
const slingAuth = new SlingAuth();

const roleOptions = {
    environment: 'live',
    roleShortname: 'news',
    accessKeyId: 'AAAAAAA000AA111AAA',
    secretAccessKey: 'XxX3XXasdDss12/zzZzzZz1aaAaaaAAa'
};
slingAuth.getRoleCredentials().then((credentials) => {
    console.log(credentials);
}).catch((error) => {
    console.log(`Error: ${error}`);
});

Output:

{
	'AccessKeyId': 'roleKey',
	'SecretAccessKey': 'roleSecret',
	'SessionToken': 'roleSession',
	'Expiration': '2020-01-01T00:00:00.000Z'
}