cevoaustralia / aws-google-auth

Provides AWS STS credentials based on Google Apps SAML SSO auth (what a jumble!)
MIT License
538 stars 180 forks source link

Turn U2F off by default and remove error message #49

Closed max-rocket-internet closed 5 years ago

max-rocket-internet commented 6 years ago

Currently in version 0.0.19 both with and without the --disable-u2f you get an error message:

$ aws-google-auth --disable-u2f
Failed to import U2F libraries, U2F login unavailable. Other methods can still continue.
Google Password:
$ aws-google-auth
Failed to import U2F libraries, U2F login unavailable. Other methods can still continue.
Google Password:

Given how uncommon U2F is, could we disable it by default and not print the Failed to import U2F libraries error unless --enable-u2f is passed?

nonspecialist commented 6 years ago

Seems reasonable

afosterw commented 6 years ago

Here is a workaround for this that I used:

import contextlib
@contextlib.contextmanager
def capture():
    import sys
    from cStringIO import StringIO
    oldout,olderr = sys.stdout, sys.stderr
    try:
        out=[StringIO(), StringIO()]
        sys.stdout,sys.stderr = out
        yield out
    finally:
        sys.stdout,sys.stderr = oldout, olderr
        out[0] = out[0].getvalue()
        out[1] = out[1].getvalue()

# A hack to suppress stdout statements in aws_google_auth during import
with capture() as out:
    from aws_google_auth import _version, configuration, util, google, amazon
for line in out:
    logger.info(line)
stevemac007 commented 6 years ago

This could be a good starting point on this project @wcharaka

wcharaka commented 5 years ago

@mide I m trying get this issue fixed, realised that initial commits were from you. Just wanted to know the reasoning behind making the u2f optional. The quick fix is to add the python-u2flib-host to the requirements so that the error wont throw any more.

mide commented 5 years ago

If it's a negligible change to workflow, I think we could just collapse all the versions into one that has all the requirements. I can't think of a reason to keep them separate now, but as a disclosure I use U2F.

Looking back, it looks like I based my changes off https://github.com/cevoaustralia/aws-google-auth/pull/25, and that had the U2F break-apart there.

Support optionally installed with pip install -e aws-google-auth[u2f], to avoid requiring dependency on python-u2flib-host.

max-rocket-internet commented 5 years ago

I see in the latest version this is resolved 🎉 Thanks 💙