Skip to content

Commit

Permalink
Pomcho555 add browser autofill (#136)
Browse files Browse the repository at this point in the history
* Add -browser-autofill option

* Increment minor version and add CHANGELOG.md
  • Loading branch information
pomcho555 authored Jan 17, 2025
1 parent fc3164c commit 6823b5e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Change Log
All notable changes to this project will be documented in this file.

1.1.0 - 2024-12-21
==================
- Supported new option `--browser-autofill|-b` to enable browser-autofill in saml2aws

1.0.1 - 2024-05-21
==================
- Test with Python 3.12.
- No longer test with Python 3.8 and Python 3.9.


1.0.0 - 2023-02-15
==================
- Replaced `PyInquirer` with [InquirerPy](https://github.com/kazhala/InquirerPy) - https://github.com/kyhau/saml2aws-multi/issues/20
Expand Down Expand Up @@ -34,4 +37,4 @@ All notable changes to this project will be documented in this file.

0.1.0 - 2019-09-30
==================
- Initial version of saml2awsmulti.
- Initial version of saml2awsmulti.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Options:
multi/aws_login_roles.csv. [default: False]
-t, --session-duration TEXT Set the session duration in seconds,
-b, --browser-autofill Enable browser-autofill.
-d, --debug Enable debug mode. [default: False]
--help Show this message and exit.
Expand Down
5 changes: 3 additions & 2 deletions saml2awsmulti/aws_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ def pre_select_options(profile_rolearn_dict, keywords):
@click.option("--refresh-cached-roles", "-r", is_flag=True, show_default=True,
help=f"Re-retrieve the roles associated to the username and password you provided and save the roles into {ALL_ROLES_FILE}.")
@click.option("--session-duration", "-t", help="Set the session duration in seconds.")
@click.option("--browser-autofill", "-b", is_flag=True, show_default=True, help="Enable browser-autofill.")
@click.option("--debug", "-d", is_flag=True, show_default=True, help="Enable debug mode.")
@click.pass_context
def main_cli(ctx, shortlisted, pre_select, profile_name_format, refresh_cached_roles, session_duration, debug):
def main_cli(ctx, shortlisted, pre_select, profile_name_format, refresh_cached_roles, session_duration, browser_autofill, debug):
if debug:
logging.getLogger().setLevel(logging.DEBUG)

if ctx.invoked_subcommand is None:
try:
saml2aws_helper = Saml2AwsHelper(SAML2AWS_CONFIG_FILE, session_duration)
saml2aws_helper = Saml2AwsHelper(SAML2AWS_CONFIG_FILE, session_duration, browser_autofill)

profile_rolearn_dict = create_profile_rolearn_dict(
saml2aws_helper,
Expand Down
6 changes: 5 additions & 1 deletion saml2awsmulti/saml2aws_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@


class Saml2AwsHelper:
def __init__(self, configfile, session_duration):
def __init__(self, configfile, session_duration, browser_autofill):
self._configfile = configfile
self._session_duration = session_duration
self._browser_autofill = browser_autofill
self._uname = None
self._upass = None

Expand Down Expand Up @@ -70,6 +71,9 @@ def run_saml2aws_login(self, role_arn, profile_name):
if self._session_duration:
cmd = f"{cmd} --session-duration={self._session_duration}"

if self._browser_autofill:
cmd = f"{cmd} --browser-autofill"

p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
logging.debug(line.decode("utf-8").rstrip("\r|\n"))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import find_packages, setup

__title__ = "saml2awsmulti"
__version__ = "1.0.1"
__version__ = "1.1.0"
__author__ = "kyhau"
__email__ = "[email protected]"
__uri__ = "https://github.com/kyhau/saml2aws-multi"
Expand Down

0 comments on commit 6823b5e

Please sign in to comment.