Skip to content

Commit 52985c2

Browse files
authored
Merge pull request #49 from nathan-v/Update_Feb_2020
February 2020 update; minor bug fixes, documentation update, update/fix requirements, self-update option
2 parents f3d0d1f + a8853d9 commit 52985c2

File tree

9 files changed

+263
-96
lines changed

9 files changed

+263
-96
lines changed

README.md

Lines changed: 42 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
[![Apache](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/nathan-v/aws_okta_keyman/blob/master/LICENSE.txt) [![Python versions](https://img.shields.io/pypi/pyversions/aws-okta-keyman.svg)](https://pypi.python.org/pypi/aws-okta-keyman/) [![PyPI version](https://badge.fury.io/py/aws-okta-keyman.svg)](https://badge.fury.io/py/aws-okta-keyman) ![PyPI - Status](https://img.shields.io/pypi/status/aws_okta_keyman) [![Downloads](http://pepy.tech/badge/aws-okta-keyman)](http://pepy.tech/count/aws-okta-keyman)
2-
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman?ref=badge_shield)
1+
[![Apache](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/nathan-v/aws_okta_keyman/blob/master/LICENSE.txt) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman?ref=badge_shield) [![Python versions](https://img.shields.io/pypi/pyversions/aws-okta-keyman.svg)](https://pypi.python.org/pypi/aws-okta-keyman/) ![PyPI - Implementation](https://img.shields.io/pypi/implementation/aws-okta-keyman) [![Downloads](http://pepy.tech/badge/aws-okta-keyman)](http://pepy.tech/count/aws-okta-keyman)
32

4-
[![CC GPA](https://codeclimate.com/github/nathan-v/aws_okta_keyman/badges/gpa.svg)](https://codeclimate.com/github/nathan-v/aws_okta_keyman) [![CC Issues](https://codeclimate.com/github/nathan-v/aws_okta_keyman/badges/issue_count.svg)](https://codeclimate.com/github/nathan-v/aws_okta_keyman) [![Coverage Status](https://codecov.io/gh/nathan-v/aws_okta_keyman/branch/master/graph/badge.svg)](https://codecov.io/gh/nathan-v/aws_okta_keyman) ![GitHub issues](https://img.shields.io/github/issues-raw/nathan-v/aws_okta_keyman)
3+
[![Requirements Status](https://pyup.io/repos/github/nathan-v/aws_okta_keyman/shield.svg?t=1580777582434)](https://pyup.io/repos/github/nathan-v/aws_okta_keyman/) ![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/nathan-v/aws_okta_keyman) ![Code Climate issues](https://img.shields.io/codeclimate/issues/nathan-v/aws_okta_keyman) ![Code Climate technical debt](https://img.shields.io/codeclimate/tech-debt/nathan-v/aws_okta_keyman) ![Codecov](https://img.shields.io/codecov/c/gh/nathan-v/aws_okta_keyman) ![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/nathan-v/aws_okta_keyman)
54

6-
[![Requirements Status](https://requires.io/github/nathan-v/aws_okta_keyman/requirements.svg?branch=master)](https://requires.io/github/nathan-v/aws_okta_keyman/requirements/?branch=master) [![Known Vulnerabilities](https://snyk.io/test/github/nathan-v/aws_okta_keyman/badge.svg)](https://snyk.io/test/github/nathan-v/aws_okta_keyman)
5+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/nathan-v/aws_okta_keyman) ![GitHub Release Date](https://img.shields.io/github/release-date/nathan-v/aws_okta_keyman) [![PyPI version](https://badge.fury.io/py/aws-okta-keyman.svg)](https://badge.fury.io/py/aws-okta-keyman) ![PyPI - Status](https://img.shields.io/pypi/status/aws_okta_keyman) [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?logo=sourcegraph)](https://sourcegraph.com/github.com/nathan-v/aws_okta_keyman)
76

8-
[![CircleCI](https://img.shields.io/circleci/build/gh/nathan-v/aws_okta_keyman)](https://circleci.com/gh/nathan-v/aws_okta_keyman/tree/master)
7+
![CircleCI](https://img.shields.io/circleci/build/gh/nathan-v/aws_okta_keyman/master?label=master&logo=circleci) ![GitHub last commit](https://img.shields.io/github/last-commit/nathan-v/aws_okta_keyman)
98

109
# AWS Okta Keyman
11-
1210
This is a simple command-line tool for logging into Okta and generating
13-
temporary Amazon AWS Credentials. This tool makes it easy and secure for your
14-
developers to generate short-lived, [logged and user-attributed][tracking]
15-
credentials that can be used for any of the Amazon SDK libraries or CLI tools.
11+
temporary Amazon AWS Credentials. This tool makes it easy and secure to
12+
generate short-lived, [logged and user-attributed][tracking] credentials that can be
13+
used for any of the Amazon SDK libraries or CLI tools.
1614

1715
## Features
18-
19-
We have support for logging into Okta, optionally handling MFA Authentication,
20-
and then generating new SAML authenticated AWS sessions. This tool has a few core
21-
features that help set it apart from other similar tools that are available.
16+
Key features listed here. Keep scrolling for more details.
17+
18+
* MFA support
19+
* Multiple AWS role support
20+
* Automatic reup/refresh mode
21+
* Dynamic AWS/Okta integration list
22+
* Automatic username selection
23+
* Okta password caching
24+
* Command wrapping
25+
* Screen/shell only output
26+
* GovCloud support
27+
* Adjustable key lifetime
28+
* Console login URLs
29+
* Config files
30+
* Interactive config generation
31+
* Installation via pip and Homebrew
32+
* Linux, Windows, and OSX support
33+
34+
Benefits vs other similar tools:
35+
36+
* Runs without external dependencies; no servers or lambdas required
37+
* No API keys required; just your Okta username and password
38+
* No analytics or metrics collection; this tool does _not_ call home in any way
39+
* Open source distributed as source; you can see what you're running
40+
* Wide Python version support; works on Python 2.7.4+ and 3.5.0+.
2241

2342
### Optional MFA Authentication
24-
2543
If you organization or integration requires MFA we will automatically detect that
2644
requirement during authentication and prompt the user to complete the
2745
Multi Factor Authentication.
@@ -40,7 +58,6 @@ but makes this tool work on remote servers or in any other case where you may no
4058
be able to use a browser.
4159

4260
#### Supported MFA Solutions
43-
4461
* Okta Verify
4562
* Duo Auth (push, call, or OTP via CLI)
4663
* Duo Auth (push, call, or OTP via web browser)
@@ -54,25 +71,10 @@ Windows Hello, U2F, email, and physical token (RSA, Symantec) are not supported
5471
at this time.
5572

5673
### Multiple AWS Roles
57-
5874
AWS Okta Keyman supports multiple AWS roles when configured. The user is prompted to
59-
select the role they wish to use before the temporary keys are generated. An example
60-
of this is shown here:
61-
62-
```text
63-
16:48:48 (WARNING) Multiple AWS roles found; please select one
64-
65-
Account Role
66-
[0] example-prod Admin
67-
[1] example-prod Dev
68-
Selection: 0
69-
70-
16:48:51 (INFO) Getting SAML Assertion from example
71-
16:48:51 (INFO) Assuming role: arn:aws:iam::1234567890:role/Admin
72-
```
75+
select the role they wish to use before the temporary keys are generated.
7376

7477
### Re-Up Mode .. Automatic Credential Re-Generation
75-
7678
Amazon IAM defaults to Federated Login sessions that last up to *1 hour*. For
7779
developers, it can be painful to re-authenticate every hour during your work
7880
day. This is made much worse if your organization requires MFA on each login.
@@ -88,24 +90,18 @@ so to complete the MFA again.
8890

8991
See the `--reup` commandline option for help here!
9092

91-
9293
### AWS Accounts from Okta
93-
9494
AWS Okta Keyman can pull the AWS Accounts that have been assigned from Okta
9595
itself which means the app ID value no longer needs to be provided in the
9696
command line or in the config file. A config file can still optionally be used
9797
to ensure account names or order if preferred. This means with no configuration
9898
saved you only need to provide your organization.
9999

100-
101100
### Automatic Username
102-
103101
AWS Okta Keyman will use the current user as the username for Okta
104102
authentication if no username has been provided.
105103

106-
107104
### Keyring Password Cache
108-
109105
AWS Okta Keyman can use your local keyring to store your Okta password to allow you to
110106
run the tool repeatedly without needing to type your password in each time. For details on how this
111107
is accomplished check out [keyring][keyring].
@@ -116,18 +112,15 @@ aws_okta_keyman -R # Reset the cached password in case of mistaken entry or p
116112
```
117113

118114
### Command Wrapping
119-
120115
Command wrapping provides a simple way to execute any command you would like directly from
121116
Keyman where the AWS access key environment variables will be provided when starting the
122117
command. An example of this is provided here:
123118

124119
```text
125120
$ aws_okta_keyman --command "echo \$AWS_ACCESS_KEY_ID"
126-
14:06:48 (INFO) AWS Okta Keyman 🔐 v0.7.5
127121
128122
----snip----
129123
130-
14:07:17 (INFO) Assuming role: arn:aws:iam::1234567890:role/Admin
131124
14:07:17 (INFO) Wrote profile "default" to /home/nathan/.aws/credentials 💾
132125
14:07:17 (INFO) Current time is 2020-01-10 22:07:17.027964
133126
14:07:17 (INFO) Session expires at 2020-01-10 23:07:16+00:00 ⏳
@@ -139,27 +132,22 @@ AXXXXXXXXXXXXXXXXXXX
139132
```
140133

141134
### Screen-only Key Output
142-
143135
Screen-only output for cases were the key needs to be copied
144136
elsewhere for use. This makes using the temporary keys in other apps simpler and easier.
145137
They will not be written out to the AWS credentials file when this option is specified.
146138

147139
```text
148140
$ aws_okta_keyman --screen
149-
14:13:27 (INFO) AWS Okta Keyman 🔐 v0.7.5
150141
151142
----snip----
152143
153-
154144
14:14:04 (INFO) Assuming role: arn:aws:iam::1234567890:role/Admin
155145
14:14:04 (INFO) AWS Credentials:
156146
157-
158147
AWS_ACCESS_KEY_ID = AXXXXXXXXXXXXXXXXXXX
159148
AWS_SECRET_ACCESS_KEY = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
160149
AWS_SESSION_TOKEN = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
161150
162-
163151
14:14:04 (INFO) All done! 👍
164152
```
165153

@@ -179,7 +167,6 @@ The console login link will be output on the screen for you to use. Just provide
179167
parameter when running Keyman.
180168

181169
### Config file .. predefined settings for you or your org
182-
183170
The config file, which defaults to `~/.config/aws_okta_keyman.yml`, allows you to
184171
pre-set things like your username, Okta organization name (subdomain), and AWS accounts
185172
and App IDs to make this script simpler to use. This also supports username assumption
@@ -195,31 +182,16 @@ Example config file:
195182
username: automatic-username@example.com
196183
org: example
197184
accounts:
198-
- name: Test
199-
appid: exampleAppIDFromOkta/123
200185
- name: Dev
201186
appid: exampleAppIDFromOkta/234
202187
- name: Prod
203188
appid: exampleAppIDFromOkta/345
204189
```
205190
206191
When used you'll get a similar interface to AWS Role selection but for your AWS
207-
accounts:
208-
209-
```text
210-
16:48:41 (WARNING) No app ID provided; select from available AWS accounts
211-
212-
Account
213-
[0] Test
214-
[1] Dev
215-
[2] Prod
216-
Selection: 2
217-
218-
16:48:47 (INFO) Using account: Prod / exampleAppIDFromOkta/123
219-
```
192+
accounts.
220193
221194
### Interactive Configuration
222-
223195
For interactive configuration and creation of the config file you can start the tool with just config as a parameter and you will be propted to provide the basic information needed to get started. An example of this is shown here:
224196
225197
```text
@@ -260,18 +232,14 @@ App ID:
260232
```
261233

262234
## Python Versions
263-
264235
Python 2.7.4+ and Python 3.5.0+ are supported.
265236

266237
Support for older Python versions will be maintained as long as is reasonable.
267238
Before support is removed a reminder/warning will be provided.
268239

269240
## Usage
270-
271241
### Client Setup
272-
273-
#### Mac OS Installation with Homebrew
274-
242+
#### Mac OS Installation
275243
`brew tap nathan-v/aws-okta-keyman` and then `brew install aws_okta_keyman`.
276244

277245
Or install via URL (which will not receive updates):
@@ -280,15 +248,13 @@ Or install via URL (which will not receive updates):
280248
brew install https://raw.githubusercontent.com/nathan-v/homebrew-aws-okta-keyman/master/Formula/aws_okta_keyman.rb
281249
```
282250

283-
#### Typical Linux or Windows Installation
284-
251+
#### Linux or Windows Installation
285252
Before you can install this tool you need to have a working Python installation with pip.
286253
If you're not sure if you have this a good place to start would be the [Python Beginner's Guide](pythonbeginner) .
287254

288255
Once your Python environment is configured simply run `pip install aws-okta-keyman` to install the tool.
289256

290257
### Running AWS Okta Keyman
291-
292258
For detailed usage instructions, see the `--help` commandline argument.
293259

294260
Typical usage:
@@ -297,13 +263,6 @@ Typical usage:
297263
$ aws_okta_keyman
298264
16:48:22 (INFO) AWS Okta Keyman 🔐 v0.7.0
299265
Password:
300-
16:48:28 (WARNING) No Duo Auth factor specified; please select one:
301-
302-
Duo Factor
303-
[0] 📲 Duo Push
304-
[1] 📟 OTP Passcode
305-
[2] 📞 Phone call
306-
Selection: 0
307266
308267
16:48:31 (INFO) Using factor: 📲 Duo Push
309268
16:48:33 (WARNING) Duo required; check your phone... 📱
@@ -336,6 +295,8 @@ Selection: 0
336295
16:48:52 (INFO) All done! 👍
337296
```
338297

298+
### Troubleshooting
299+
Troubleshooting information is available on the project Github [wiki].
339300

340301
## Okta Setup
341302
Before you can use this tool, your Okta administrator needs to set up
@@ -352,12 +313,10 @@ The original code is heavily based on the previous work done by
352313
Credentials][aws_role_credentials] tools.
353314

354315
## Developer Info
355-
356316
See CONTRIBUTING.md for more information on contributing to this project.
357317

358318
## License
359-
360-
Copyright 2019 Nathan V
319+
Copyright 2020 Nathan V
361320

362321
Copyright 2018 Nextdoor.com, Inc
363322

@@ -368,6 +327,8 @@ Some code in `aws_okta_keyman/okta.py`, `aws_okta_keyman/aws.py`,
368327
distributed under MIT license. See the source files for details. A copy of the
369328
license is in the LICENSE_MIT.txt file.
370329

330+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman?ref=badge_large)
331+
371332
[nd_okta_auth]: https://github.com/Nextdoor/nd_okta_auth
372333
[nextdoorinc]: https://github.com/Nextdoor
373334
[oktaauth]: https://github.com/ThoughtWorksInc/oktaauth
@@ -381,6 +342,4 @@ license is in the LICENSE_MIT.txt file.
381342
[aws_saml]: http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithSAML.html
382343
[duo_auth]: https://duo.com/
383344
[keyring]: https://github.com/jaraco/keyring
384-
385-
386-
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman?ref=badge_large)
345+
[wiki]: https://github.com/nathan-v/aws_okta_keyman/wiki#faq--troubleshooting

aws_okta_keyman/aws.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self,
132132

133133
self.profile = profile
134134
self.region = region
135+
boto3.setup_default_session(profile_name=profile)
135136
self.sts = boto3.client('sts', region_name=self.region)
136137
self.assertion = SamlAssertion(assertion)
137138
self.writer = Credentials(cred_file)

aws_okta_keyman/config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(self, argv):
5353
self.region = None
5454
self.duration = None
5555
self.console = None
56+
self.update = None
5657

5758
if len(argv) > 1:
5859
if argv[1] == 'config':
@@ -287,6 +288,13 @@ def optional_args(optional_args):
287288
'selected role..'
288289
),
289290
default=False)
291+
optional_args.add_argument('-U', '--update',
292+
action='store_true', help=(
293+
'Check installed Keyman version '
294+
'against latest version in pip and '
295+
'update if the pip version is newer.'
296+
),
297+
default=False)
290298

291299
@staticmethod
292300
def read_yaml(filename, raise_on_error=False):
@@ -346,7 +354,7 @@ def write_config(self):
346354
def clean_config_for_write(config):
347355
"""Remove args we don't want to save to a config file."""
348356
ignore = ['name', 'appid', 'argv', 'writepath', 'config', 'debug',
349-
'oktapreview', 'password_reset', 'command']
357+
'oktapreview', 'password_reset', 'command', 'update']
350358
for var in ignore:
351359
del config[var]
352360

0 commit comments

Comments
 (0)