-
Notifications
You must be signed in to change notification settings - Fork 3
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 #10 from ddimitrioglo/issue_9
#AWSAML Major refactoring (w/ breaking changes)
- Loading branch information
Showing
17 changed files
with
602 additions
and
290 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -18,15 +18,16 @@ Inspired by [AWS CLI Access Using SAML 2.0][1] article. | |
|
||
`aws-saml configure` | ||
|
||
> Or manually edit `~/.aws/.saml.json` which will look like | ||
> Or manually add/edit `~/.aws-saml/config.json` which should look like | ||
```text | ||
{ | ||
"profile": "saml", | ||
"username": "myusername", // or email: [email protected] | ||
"directoryDomain": "https://directory.mycorp.com", | ||
"accountMapping": { | ||
"888999888999": "Account A", | ||
"profile": "saml", # AWS named profile [Required, default: "saml"] | ||
"username": "myusername", # SSO username (login or email) [Required] | ||
"password": false, # SSO password (encrypted with SSH keys) [Optional, default: false] | ||
"directoryDomain": "https://directory.mycorp.com", # Identity provider (aka IdP) [Required] | ||
"aliases": { # AWS accounts aliases [Optional, default: {}] | ||
"888999888999": "workAccount", | ||
... | ||
} | ||
} | ||
|
@@ -35,15 +36,15 @@ Inspired by [AWS CLI Access Using SAML 2.0][1] article. | |
### Usage | ||
|
||
* Run `aws-saml login` | ||
* Enter a password | ||
* Enter a username & password | ||
* Chose an account | ||
* Use your AWS CLI commands by adding `--profile saml` | ||
|
||
> Ex. `aws s3 ls --profile saml` | ||
### Help | ||
|
||
`aws-saml --help` | ||
To get familiar with all the features, just use `aws-saml --help` | ||
|
||
### Improvements | ||
|
||
|
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
'use strict'; | ||
|
||
const rlex = require('../src/extra-readline'); | ||
const Command = require('../src/command'); | ||
|
||
class AliasCommand extends Command { | ||
/** | ||
* @return {Promise} | ||
*/ | ||
run() { | ||
const config = this.getConfig(); | ||
const aliases = this.getConfig('aliases'); | ||
const isDelete = this.getOption('delete', 'd', false); | ||
const accountId = this.getOption('account', 'a', false); | ||
|
||
if (!accountId || accountId.constructor === Boolean) { | ||
return Promise.reject('Account ID is required'); | ||
} | ||
|
||
if (isDelete) { | ||
delete aliases[accountId]; | ||
this.updateConfig(config); | ||
|
||
return Promise.resolve('Done!'); | ||
} | ||
|
||
return rlex.promiseQuestion(`Alias for account ${accountId} (${aliases[accountId] || accountId}): `).then(answer => { | ||
if (answer) { | ||
aliases[accountId] = answer; | ||
} | ||
|
||
return Promise.resolve(); | ||
}).then(() => { | ||
this.updateConfig(config); | ||
|
||
return Promise.resolve('Done!'); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = AliasCommand; |
Oops, something went wrong.