Closed mide closed 6 years ago
Hmmm, I have a profile in ~/.aws/config
with the profile
prefix in the name; e.g.
[profile None]
region = ap-southeast-2
output = json
...
It's quite possible that this was due to an intermediate version, but the result is confusing. It breaks with:
(aws-google-auth) cmp@tak.local aws-google-auth $ bin/aws-google-auth
Failed to import U2F libraries, U2F login unavailable. Other methods can still continue.
Google Password:
Invalid parameters.
Traceback (most recent call last):
File "bin/aws-google-auth", line 11, in <module>
load_entry_point('aws-google-auth==0.0.16', 'console_scripts', 'aws-google-auth')()
File "/home/cmp/Build/Cevo/aws-google-auth/lib/python2.7/site-packages/aws_google_auth-0.0.16-py2.7.egg/aws_google_auth/__init__.py", line 52, in main
cli(sys.argv[1:])
File "/home/cmp/Build/Cevo/aws-google-auth/lib/python2.7/site-packages/aws_google_auth-0.0.16-py2.7.egg/aws_google_auth/__init__.py", line 107, in cli
config.raise_if_invalid()
File "/home/cmp/Build/Cevo/aws-google-auth/lib/python2.7/site-packages/aws_google_auth-0.0.16-py2.7.egg/aws_google_auth/configuration.py", line 72, in raise_if_invalid
assert (self.profile.__class__ is str), "Expected profile to be a string. Got {}.".format(self.profile.__class__)
AssertionError: Expected profile to be a string. Got <type 'NoneType'>.
If I edit out the profile
prefix (so it's just [None]
) then all's well.
If I specify a profile on the command-line, eg aws-google-auth -p cevo-dev
then it works too; but not if I just run it without setting a default profile.
$AWS_PROFILE
is unset.
I think it's because config.read(args.profile)
gets a NoneType first, before any sanity checking is done and then, after environment variables are read again, it's overridden by default_if_none
which is passed a NoneType in as the default
Adding default='default'
to line 27 of __init__.py
fixes this but it would be useful to report on which profile is having issues, so the user can adjust/edit their ~/.aws/config
file if needed.
I think my description is confusing, so I'll adjust it.
Missing any default value for the profile
argument results in a NoneType
being used to load, and re-load the profile, instead of using the profile "default"
Hmmm, okay. That's an interesting case. I'll take a look at that in the morning @nonspecialist. (I'm in the US - New York time zone)
@nonspecialist I was able to reproduce the problem and I feel that 2a53e49251c658b760bdeea052bf4bacf147be18 should solve your problem. That being said, I don't think we want the default to be None
and instead be sts
. So now when you don't specify a profile, it should use sts
.
@mide sorry for the slow reply.
Being back in front of the computer again I've just outlined our cross account usage a bit more on https://github.com/cevoaustralia/aws-google-auth/issues/42#issuecomment-358106519 hopefully that makes our current use case a bit clearer.
@SamBarker - I think I'm a little lost, is that just for context, or do you expect changes from that comment?
Just for context! Not expecting anything else at all.
On Wed, 17 Jan 2018 at 10:18, Mark Ide notifications@github.com wrote:
@SamBarker https://github.com/sambarker - I think I'm a little lost, is that just for context, or do you expect changes from that comment?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/cevoaustralia/aws-google-auth/pull/38#issuecomment-358109307, or mute the thread https://github.com/notifications/unsubscribe-auth/ACs8qkgdhcqIP9nf6u8oXi8t3NJYm1oDks5tLRIxgaJpZM4RWd6w .
--
[image: MahiFX]
Sam Barker
Senior Developer
MahiFX
Level 3,
50 Victoria Street,
Christchurch, 8013
Mobile: +64 (0)21 1917157
Skype: sammahifx
[image: MFX Compass]
--
IMPORTANT NOTICE: MahiFX Limited (MahiFX Ltd) and MahiFX (UK) Limited (MahiFX (UK)) are operating subsidiaries within the MahiFX group of companies (collectively, the MahiFX Group). All references to “MahiFX” refer to the MahiFX Group. MahiFX Limited is registered in New Zealand (Company no. 2446590, NZBusNo 9429031595070) and Australia (Australian registered body number ARBN 152-535-085). MahiFX Limited is authorised and regulated under the Australian Securities and Investment Commission (AFSL number 414198) and the New Zealand Financial Markets Authority (FSPR number FSP197465). MahiFX (UK) Limited is registered in the United Kingdom, (registered company number 08107062). MahiFX (UK) Limited is authorised and regulated under the Financial Conduct Authority (reference number 751019).
This email, its attachments and any rights attaching hereto are confidential and intended exclusively for the person to whom the email is addressed. If you are not the intended recipient, do not read, copy, disclose or use the contents in any way. Please notify the sender by return email and destroy the email and attachments immediately. MahiFX does not accept any liability for any changes made to this email or attachments after sending by MahiFX. You must scan this email and attachments for viruses. The opinions expressed are not necessarily those of MahiFX. MahiFX accepts no liability for any loss, damage or consequence, whether caused by our own negligence or not, resulting directly or indirectly from the use of this email and attachments.
For more information about MahiFX Limited see mahifx.com.
Great! Thank you!
Excellent! Works for my bizarre-o ~/.aws/config
with and without specifying a profile. I like the coalesce
cleanup too.
👍
Thanks!
Looks great @mide - I've confirmed that my existing config works well. Lets get this merged and then we can look at updating the remaining open PR's.
@stevemac007 Could we get a new python package please?
@cliveza the travis build should publish a new package automatically, but TravisCI has had some problems over the past 24 hours. I'll check the build and kick it manually if need be
@cliveza pypi and Docker tags have been updated
Breaking Changes
pip
doesn't support 2.6 since fall 2016 https://github.com/pypa/pip/issues/3955pytest
doesn't support 2.6 since fall 2017 https://github.com/pytest-dev/pytest/issues/2812setuptools
doesn't support 2.6 since fall 2017 https://github.com/pypa/setuptools/issues/8782.*
support, but I'm not going that far yet.)Remove persistent (to file) profiles.Previously,(Edit: Per feedback in #38, I will add this back in)aws-google-auth
would write to a user's~/.aws/config
file and read the values when run the next time. I feel this adds a complexity in trying to configure the tool to determine defaults.aws-google-auth
supports command line params, user input, environment variables and adding another may be too much to maintain. Of course, we can add this back if desired.Under-the-hood Changes
__init__.py
into the following files (along with their purproses):google.py
is for all Google related functions. It includes the logic to perform the page scraping and SAML fetching.amazon.py
for AWS related fucntions. This performs the role extraction from the SAML and performs the AWS API call to get the access tokens.configuration.py
- This only maintains user options (anything the user specifies). Breaking this into it's own object allows us to perform much more robust testing and just pass around a single object instead of a handful of options.util.py
for common toolingAdded the following tests
Flake8 Python style testing. This is added into the TravisCI build script (
.travis.yml
).test_configuration.py
:duration
values get rejected.duration
values are accepted.duration
ismax_duration
ask_role
values get rejected.ask_role
values are accepted.ask_role
is an optional setting.idp_id
values get rejected.idp_id
values are accepted.sp_id
values get rejected.username
values are accepted.username
values get rejected.sp_id
values are accepted.profile
issts
profile
values get rejected.profile
values are accepted.region
values get rejected.region
values are accepted.region
isap_southeast_2
role_arn
values get rejected.role_arn_is
is an optional setting.role_arn
values are accepted.u2f_disabled
values get rejected.u2f_disabled
values are accepted.u2f_disabled_is
is an optional setting.test_amazon.py
sts
boto
client properly returns an STS client object.Needed Work
In order to get tests to pass, I had to ignore Flake8 rule E722. We should go back and determine what the correct exceptions are to catch and only catch those.
Note
Please don't feel you need to accept this, but do please let me know. If this breaks Cevo's workflows, I may just end up maintaining my own fork.