-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from Cox-Automotive/develop
LTK support
- Loading branch information
Showing
13 changed files
with
1,729 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
process.title = 'ALKS'; | ||
|
||
var program = require('commander'), | ||
_ = require('underscore'), | ||
clc = require('cli-color'), | ||
alks = require('alks-node'), | ||
Iam = require('../lib/iam'), | ||
utils = require('../lib/utils'), | ||
Developer = require('../lib/developer'), | ||
config = require('../package.json'); | ||
|
||
var logger = 'iam-createltk', | ||
nameDesc = 'alphanumeric including @+=._-'; | ||
|
||
program | ||
.version(config.version) | ||
.description('creates a new IAM Longterm Key') | ||
.option('-n, --iamusername [iamUsername]', 'the name of the iam user associated with the LTK, ' + nameDesc) | ||
.option('-a, --account [alksAccount]', 'alks account to use') | ||
.option('-r, --role [alksRole]', 'alks role to use') | ||
.option('-F, --favorites', 'filters favorite accounts') | ||
.option('-v, --verbose', 'be verbose') | ||
.parse(process.argv); | ||
|
||
var NAME_REGEX = /^[a-zA-Z0-9!@+=._-]+$/g, | ||
iamUsername = program.iamusername, | ||
alksAccount = program.account, | ||
alksRole = program.role, | ||
filterFaves = program.favorites || false; | ||
|
||
utils.log(program, logger, 'validating iam user name: ' + iamUsername); | ||
if(_.isEmpty(iamUsername) || !NAME_REGEX.test(iamUsername)){ | ||
utils.errorAndExit('The username provided contains illegal characters. It must be ' + nameDesc); | ||
} | ||
|
||
if(!_.isUndefined(alksAccount) && _.isUndefined(alksRole)){ | ||
utils.log(program, logger, 'trying to extract role from account'); | ||
alksRole = utils.tryToExtractRole(alksAccount); | ||
} | ||
|
||
Iam.getIAMAccount(program, logger, alksAccount, alksRole, filterFaves, function(err, developer, password, alksAccount, alksRole){ | ||
if(err){ | ||
return utils.errorAndExit(err); | ||
} | ||
|
||
// create the LTK | ||
var data = _.extend({}, developer); | ||
data.alksAccount = alksAccount; | ||
data.alksRole = alksRole; | ||
utils.log(program, logger, 'calling api to create ltk: ' + iamUsername); | ||
|
||
alks.createLongTermKey(data, password, iamUsername, { debug: program.verbose, ua: utils.getUA() }, function(err, data){ | ||
if(err){ | ||
return utils.errorAndExit(err); | ||
} | ||
|
||
console.error(clc.white(['LTK created for IAM User: ', iamUsername, ' was created with the ARN: '].join('')) + clc.white.underline(data.iamUserArn)); | ||
console.error(clc.white(['LTK Access Key: '].join('')) + clc.white.underline(data.accessKey)); | ||
console.error(clc.white(['LTK Secret Key: '].join('')) + clc.white.underline(data.secretKey)); | ||
|
||
utils.log(program, logger, 'checking for updates'); | ||
utils.checkForUpdate(); | ||
Developer.trackActivity(logger); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
process.title = 'ALKS'; | ||
|
||
var program = require('commander'), | ||
_ = require('underscore'), | ||
clc = require('cli-color'), | ||
alks = require('alks-node'), | ||
Iam = require('../lib/iam'), | ||
utils = require('../lib/utils'), | ||
Developer = require('../lib/developer'), | ||
config = require('../package.json'); | ||
|
||
var logger = 'iam-deleteltk'; | ||
|
||
program | ||
.version(config.version) | ||
.description('deletes an IAM Longterm Key') | ||
.option('-n, --iamusername [iamUsername]', 'the name of the iam user associated with the LTK') | ||
.option('-a, --account [alksAccount]', 'alks account to use') | ||
.option('-r, --role [alksRole]', 'alks role to use') | ||
.option('-F, --favorites', 'filters favorite accounts') | ||
.option('-v, --verbose', 'be verbose') | ||
.parse(process.argv); | ||
|
||
var iamUsername = program.iamusername, | ||
alksAccount = program.account, | ||
alksRole = program.role, | ||
filterFaves = program.favorites || false; | ||
|
||
utils.log(program, logger, 'validating iam user name: ' + iamUsername); | ||
if(_.isEmpty(iamUsername)){ | ||
utils.errorAndExit('The IAM username is required.'); | ||
} | ||
|
||
if(!_.isUndefined(alksAccount) && _.isUndefined(alksRole)){ | ||
utils.log(program, logger, 'trying to extract role from account'); | ||
alksRole = utils.tryToExtractRole(alksAccount); | ||
} | ||
|
||
Iam.getIAMAccount(program, logger, alksAccount, alksRole, filterFaves, function(err, developer, password, alksAccount, alksRole){ | ||
if(err){ | ||
return utils.errorAndExit(err); | ||
} | ||
|
||
// delete the LTK | ||
var data = _.extend({}, developer); | ||
data.alksAccount = alksAccount; | ||
data.alksRole = alksRole; | ||
utils.log(program, logger, 'calling api to delete ltk: ' + iamUsername); | ||
|
||
alks.deleteLongTermKey(data, password, iamUsername, { debug: program.verbose, ua: utils.getUA() }, function(err, data){ | ||
if(err){ | ||
return utils.errorAndExit(err); | ||
} | ||
|
||
console.error(clc.white(['LTK deleted for IAM User: ', iamUsername].join(''))); | ||
|
||
utils.log(program, logger, 'checking for updates'); | ||
utils.checkForUpdate(); | ||
Developer.trackActivity(logger); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
★ Release Notes: 2017-06-20 ★ | ||
★ Release Notes: 2017-11-14 ★ | ||
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ | ||
|
||
Thanks for upgrading to the latest version of the ALKS CLI! | ||
|
||
→ You can now set favorite accounts: `alks developer favorites` | ||
→ `alks sessions open` now floats your favorites to the top | ||
→ `alks sessions open` now supports `-F` to filter your favorites | ||
→ `alks sessions console` now supports `-F` to filter your favorites | ||
→ `alks iam createrole` now supports `-F` to filter your favorites | ||
→ Adds support for long term keys (ltk) for non-prod and lab accounts | ||
→ You can now create long term keys: `alks iam createltk` | ||
→ You can remove long term keys: `alks iam deleteltk` | ||
→ Sessions now provide the expiration time as: `env.AWS_SESSION_EXPIRES` | ||
→ `alks iam deleterole` now supports `-F` to filter your favorites | ||
→ Have feedback? https://github.com/Cox-Automotive/ALKS-CLI/issues | ||
|
||
☁☁☁☁☁☁ Happy Clouding! ☁☁☁☁☁☁ | ||
☁☁☁☁☁☁ Happy Clouding! ☁☁☁☁☁☁ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.