Skip to content

Commit

Permalink
Merge pull request #358 from venth/automatically_update_readme_help
Browse files Browse the repository at this point in the history
Automatically update help messages in README, and run pre-commit hooks in CI
  • Loading branch information
pdecat authored Oct 28, 2022
2 parents 5286dde + 704b435 commit 239f355
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 20 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Build

env:
PYTHON_VERSION: "3.10"
POETRY_VERSION: 1.1.13
POETRY_VERSION: "1.2.2"

on:
push:
Expand All @@ -17,7 +17,7 @@ on:

jobs:
test:
name: Build wheel (${{ matrix.python-version }} on ${{ matrix.os }})
name: Run tests (${{ matrix.python-version }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -45,6 +45,11 @@ jobs:
run: |
poetry install
- name: Run all pre-commit checks
if: matrix.os == 'ubuntu-latest'
run: |
poetry run pre-commit run --all
- name: Test with pytest
run: |
poetry run pytest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fabric.properties
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
Scripts
pyvenv.cfg
.venv
pip-selfcheck.json
Expand Down
13 changes: 11 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/python-jsonschema/check-jsonschema

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.16.0
hooks:
- id: check-github-actions
- id: check-github-workflows

- repo: local
hooks:
- id: update-readme-help
name: Update README help
entry: ./scripts/update-readme-help.sh
language: script
files: ^(README.md|aws_adfs/(commands|list_profiles|login|reset).py)$
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,25 @@ aws-adfs integrates with:
Warning: see [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html) about security considerations to take when sourcing credentials with an external process.
* help, help, help?
<!-- AWS_HELP_START -->
```
$ aws-adfs --help
Usage: aws-adfs [OPTIONS] COMMAND [ARGS]...
Options:
--version Show current tool version
-v, --verbose Enables debug information on stdout. By default log level is
set on ERROR
set on ERROR
--help Show this message and exit.
Commands:
list lists available profiles
login Authenticates an user with active directory credentials
reset removes stored profile
```
<!-- AWS_HELP_END -->
<!-- AWS_LIST_HELP_START -->
```
$ aws-adfs list --help
Usage: aws-adfs list [OPTIONS]
Expand All @@ -205,7 +208,9 @@ aws-adfs integrates with:
Options:
--help Show this message and exit.
```
<!-- AWS_LIST_HELP_END -->
<!-- AWS_LOGIN_HELP_START -->
```
$ aws-adfs login --help
Usage: aws-adfs login [OPTIONS]
Expand Down Expand Up @@ -277,19 +282,21 @@ aws-adfs integrates with:
--duo-factor TEXT Use a specific Duo factor, overriding the
default one configured server side. Known
Duo factors that can be used with aws-adfs
are "Duo Push", "Phone Call", "WebAuthn
Security Key" and "Passcode".
are "Duo Push", "Passcode", "Phone Call" and
"WebAuthn Security Key".
--duo-device TEXT Use a specific Duo device, overriding the
default one configured server side. Depends
heavily on the Duo factor used. Known Duo
devices that can be used with aws-adfs are
"phone1" for "Duo Push" and "Phone Call"
factors. For "WebAuthn Security Key" factor,
it is always "None".
factors. For "Passcode" and "WebAuthn
Security Key" factors, it is always "None".
--enforce-role-arn Only allow the role passed in by --role-arn.
--help Show this message and exit.
```
<!-- AWS_LOGIN_HELP_END -->
<!-- AWS_RESET_HELP_START -->
```
$ aws-adfs reset --help
Usage: aws-adfs reset [OPTIONS]
Expand All @@ -300,6 +307,7 @@ aws-adfs integrates with:
--profile TEXT AWS cli profile that will be removed
--help Show this message and exit.
```
<!-- AWS_RESET_HELP_END -->
## Known issues
Expand Down
2 changes: 1 addition & 1 deletion aws_adfs/_azure_mfa_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def extract(html_response, ssl_verification_enabled, session):
ssl_verification_enabled
)


def _retrieve_roles_page(roles_page_url, context, session, ssl_verification_enabled):
response = session.post(
roles_page_url,
Expand Down
1 change: 0 additions & 1 deletion aws_adfs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,3 @@ def cli(verbose):
cli.add_command(list_profiles.list_profiles)
cli.add_command(login.login)
cli.add_command(reset.reset)

2 changes: 1 addition & 1 deletion aws_adfs/html_roles_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def fetch_html_encoded_roles(
# MozillaCookieJar works because it does not convert the timestamps.
# Duo uses 253402300799 for its cookies which translates into 9999-12-31T23:59:59Z.
# Windows 64bit maximum date is 3000-12-31T23:59:59Z, and 32bit is 2038-01-18T23:59:59Z.
#
#
# using the same cookiejar across multiple ADFS hosts causes issues, so use a unique jar per host
cookiejar_filename = '{}_{}'.format(adfs_cookie_location, hashlib.md5(adfs_host.encode('utf-8')).hexdigest())
session.cookies = cookielib.MozillaCookieJar(filename=cookiejar_filename)
Expand Down
4 changes: 2 additions & 2 deletions aws_adfs/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@
)
@click.option(
"--duo-factor",
help=f'Use a specific Duo factor, overriding the default one configured server side. Known Duo factors that can be used with aws-adfs are "{DUO_UNIVERSAL_PROMPT_FACTOR_DUO_PUSH}", "{DUO_UNIVERSAL_PROMPT_FACTOR_PHONE_CALL}", "{DUO_UNIVERSAL_PROMPT_FACTOR_WEBAUTHN}" and "{DUO_UNIVERSAL_PROMPT_FACTOR_PASSCODE}".',
help=f'Use a specific Duo factor, overriding the default one configured server side. Known Duo factors that can be used with aws-adfs are "{DUO_UNIVERSAL_PROMPT_FACTOR_DUO_PUSH}", "{DUO_UNIVERSAL_PROMPT_FACTOR_PASSCODE}", "{DUO_UNIVERSAL_PROMPT_FACTOR_PHONE_CALL}" and "{DUO_UNIVERSAL_PROMPT_FACTOR_WEBAUTHN}".',
)
@click.option(
"--duo-device",
help=f'Use a specific Duo device, overriding the default one configured server side. Depends heavily on the Duo factor used. Known Duo devices that can be used with aws-adfs are "phone1" for "{DUO_UNIVERSAL_PROMPT_FACTOR_DUO_PUSH}" and "{DUO_UNIVERSAL_PROMPT_FACTOR_PHONE_CALL}" factors. For "{DUO_UNIVERSAL_PROMPT_FACTOR_WEBAUTHN}" factor, it is always "None".',
help=f'Use a specific Duo device, overriding the default one configured server side. Depends heavily on the Duo factor used. Known Duo devices that can be used with aws-adfs are "phone1" for "{DUO_UNIVERSAL_PROMPT_FACTOR_DUO_PUSH}" and "{DUO_UNIVERSAL_PROMPT_FACTOR_PHONE_CALL}" factors. For "{DUO_UNIVERSAL_PROMPT_FACTOR_PASSCODE}" and "{DUO_UNIVERSAL_PROMPT_FACTOR_WEBAUTHN}" factors, it is always "None".',
)
@click.option(
"--enforce-role-arn",
Expand Down
Loading

0 comments on commit 239f355

Please sign in to comment.