Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for non-public AWS regions (e.g. GovCloud) #156

Merged
merged 3 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ aws-adfs integrates with:
aws --profile=specified-profile s3 ls
```

* login to your adfs host and fetch roles for AWS GovCloud (US)

```
aws-adfs login --adfs-host=your-adfs-hostname --provider-id urn:amazon:webservices:govcloud --region us-gov-west-1
```

and verification

```
aws s3 ls
```

* login to your adfs host within ansible playbook

```
Expand Down Expand Up @@ -363,4 +375,5 @@ aws-adfs integrates with:
* [rheemskerk](https://github.com/rheemskerk) for:
* Fix username and password disclosure
* Fix authentication with cookies on non-windows system.
* Change `AuthMethod` parameter to `FormsAuthentication`
* Change `AuthMethod` parameter to `FormsAuthentication`
* [brodie11](https://github.com/brodie11) and [gregorydulin](https://github.com/gregorydulin) for: Add support for non-public AWS regions
12 changes: 10 additions & 2 deletions aws_adfs/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,19 @@ def login(
try:
session = botocore.session.get_session()
session.set_config_variable('profile', config.profile)
conn = session.create_client('sts', config=client.Config(signature_version=botocore.UNSIGNED))
conn = session.create_client(
'sts',
region_name=region,
config=client.Config(signature_version=botocore.UNSIGNED),
)
except botocore.exceptions.ProfileNotFound:
logging.debug('Profile {} does not exist yet'.format(config.profile))
session = botocore.session.get_session()
conn = session.create_client('sts', config=client.Config(signature_version=botocore.UNSIGNED))
conn = session.create_client(
'sts',
region_name=region,
config=client.Config(signature_version=botocore.UNSIGNED),
)

aws_session_token = conn.assume_role_with_saml(
RoleArn=config.role_arn,
Expand Down