diff --git a/README.md b/README.md index 64eb310..e34876b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Build Status](https://travis-ci.org/Cox-Automotive/alks-node.svg?branch=master)](https://travis-ci.org/Cox-Automotive/alks-node) ## About -Node client for interfacting with the [ALKS](https://github.com/Cox-Automotive/ALKS) services. +Node client for interfacting with ALKS services. ## Usage @@ -23,17 +23,9 @@ Returns array of valid session durations. alks.getDurations(); ``` -### getAccountSelectorDelimiter() - -Returns string dilimeter used for account/role seperation. - -```js -alks.getAccountSelectorDelimiter(); -``` - ## Methods -### createKey(account, password, duration, callback) +### createKey(account, password, duration, options, callback) Creates a new session key with the provided information. Returns a JSON document. @@ -55,16 +47,16 @@ alks.createKey(data, 'password', 2, function(err, key){ ### getAccounts(server, userid, password, options, callback) -Returns a collection of accounts. Options filter allows you to switch between IAM and non-IAM accounts. +Returns a collection of accounts. ```js -alks.getAccounts('server', 'username', 'password', {filters: { iamOnly: false }}, function(err, accounts){ +alks.getAccounts('server', 'username', 'password', {}, function(err, accounts){ if(err) console.error(err); else console.log(JSON.stringify(accounts)); }); ``` -### generateConsoleUrl(key, callback) +### generateConsoleUrl(key, options, callback) Returns a AWS console URL for a given key. The URL is good for 15 minutes. @@ -75,14 +67,14 @@ alks.generateConsoleUrl(alksKey, function(err, url){ }); ``` -### getIamRoleTypes(server, userid, password, callback) +### getIamRoleTypes(server, userid, password, options, callback) Returns a list of current IAM role types. -### createIamKey(account, password, callback) +### createIamKey(account, password, options, callback) Generates a new session for use in creating IAM roles and console sessions. -### createIamRole(account, password, roleName, roleType, includeDefaultPolicies, callback) +### createIamRole(account, password, roleName, roleType, includeDefaultPolicies, options, callback) Creates a new IAM role, provided account must contain valid ALKS IAM session. \ No newline at end of file diff --git a/lib/alks-api.js b/lib/alks-api.js index 321d08e..66aab19 100644 --- a/lib/alks-api.js +++ b/lib/alks-api.js @@ -8,7 +8,6 @@ var _ = require('underscore'), var exports = module.exports = {}; var ALKS_DURATIONS = [ 2, 6, 12, 18 ], // reducing due to EB not honoring long sessions: , 24, 36 ], - ACCOUNT_SELECTION_DELIMITER = ' :: ', AWS_SIGNIN_URL = 'https://signin.aws.amazon.com/federation', AWS_CONSOLE_URL = 'https://console.aws.amazon.com/', SANITIZE_FIELDS = [ 'password' ], @@ -18,10 +17,6 @@ exports.getDurations = function(){ return ALKS_DURATIONS; }; -exports.getAccountSelectorDelimiter = function(){ - return ACCOUNT_SELECTION_DELIMITER; -}; - var getMessageFromBadResponse = function(results){ if(results.body){ if(results.body.statusMessage){ @@ -178,7 +173,6 @@ exports.createIamRole = function(account, password, roleName, roleType, includeD exports.getAccounts = function(server, userid, password, opts, callback){ var payload = { userid: userid, password: password }, options = _.extend({ - filters: {}, debug: false, ua: DEFAULT_UA }, opts), @@ -206,28 +200,28 @@ exports.getAccounts = function(server, userid, password, opts, callback){ // new API style to support IAM if(results.body.accountListRole){ - var accountRolesFitlered = {}; - _.each(results.body.accountListRole, function(role, acct){ - if((options.filters.iamOnly && !role[0].iamKeyActive) - || (!options.filters.iamOnly && role[0].iamKeyActive)){ - return; - } - accountRolesFitlered[acct] = role; - }); - var accounts = []; - _.each(accountRolesFitlered, function(role, acct){ - accounts.push([acct, role[0].role].join(ACCOUNT_SELECTION_DELIMITER)); + + _.each(results.body.accountListRole, function(role, acct){ + accounts.push({ + account: acct, + role: role[0].role, + iam: role[0].iamKeyActive + }); }); } // v1 API style without IAM else{ _.each(results.body.accountRoles, function(role, acct){ - accounts.push([acct, role[0]].join(ACCOUNT_SELECTION_DELIMITER)); + accounts.push({ + account: acct, + role: role[0], + iam: false + }); }); } - accounts = _.sortBy(accounts, function(account){ return account; }); + accounts = _.sortBy(accounts, function(account){ return account.account; }); callback(null, accounts); }); diff --git a/package.json b/package.json index c298444..f74fa51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alks-node", - "version": "0.3.1", + "version": "0.4.0", "description": "Node client for ALKS", "main": "lib/alks-api.js", "scripts": {