cevoaustralia / aws-google-auth

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

Fix google captcha #185

Closed brunodasilvalenga closed 4 years ago

brunodasilvalenga commented 4 years ago

After facing some problems in authenticating new users on my team, I decided to try to solve the captcha problem. After seeing the discussion of issues on that thread:

I saw that the user @ramnes (Thanks mate) created a pull request resolving the conflict in captcha request but still continue to receive authentication errors, after a few hours of debugging I discovered that you cannot send the password together with the captcha, first you need to pass the captcha and after that it redirect you (301) to the password authentication page. I changed the code to include this new request and everything worked again.

Please feel free to ask any question :)

Zlender commented 4 years ago

I'm still getting denied with

(venv) ➜  aws-google-auth git:(fix-google-captcha) ✗ aws-google-auth -p saml
Google Password:
ERROR:root:'NoneType' object has no attribute 'get'
Traceback (most recent call last):
  File "/Users/rok.zlender/git/aws-google-auth/aws_google_auth/__init__.py", line 78, in cli
    process_auth(args, config)
  File "/Users/rok.zlender/git/aws-google-auth/aws_google_auth/__init__.py", line 242, in process_auth
    google_client.do_login()
  File "/Users/rok.zlender/git/aws-google-auth/aws_google_auth/google.py", line 235, in do_login
    passwd_challenge_url = 'https://accounts.google.com' + form.get('action')
AttributeError: 'NoneType' object has no attribute 'get'

challenge_page has text

"Google AccountsCouldn't sign you inThe browser you're using doesn't support JavaScript, or has JavaScript turned off.To keep your Google Account secure, try signing in on a browser that has JavaScript turned on. Learn moreGooglePrivacyTerms\u202aAfrikaans\u202c\u202aazərbaycan\u202c\u202acatalà\u202c\u202aČeština\u202c\u202aDansk\u202c\u202aDeutsch\u202c\u202aeesti\u202c\u202aEnglish (United Kingdom)\u202c\u202aEnglish (United States)\u202c\u202aEspañol (España)\u202c\u202aEspañol (Latinoamérica)\u202c\u202aeuskara\u202c\u202aFilipino\u202c\u202aFrançais (Canada)\u202c\u202aFrançais (France)\u202c\u202agalego\u202c\u202aHrvatski\u202c\u202aIndonesia\u202c\u202aisiZulu\u202c\u202aíslenska\u202c\u202aItaliano\u202c\u202aKiswahili\u202c\u202alatviešu\u202c\u202alietuvių\u202c\u202amagyar\u202c\u202aMelayu\u202c\u202aNederlands\u202c\u202anorsk\u202c\u202apolski\u202c\u202aPortuguês (Brasil)\u202c\u202aPortuguês (Portugal)\u202c\u202aromână\u202c\u202aSlovenčina\u202c\u202aslovenščina\u202c\u202aSuomi\u202c\u202aSvenska\u202c\u202aTiếng Việt\u202c\u202aTürkçe\u202c\u202aΕλληνικά\u202c\u202aбългарски\u202c\u202aмонгол\u202c\u202aРусский\u202c\u202aсрпски\u202c\u202aУкраїнська\u202c\u202aქართული\u202c\u202aհայերեն\u202c\u202bעברית\u202c\u200e\u202bاردو\u202c\u200e\u202bالعربية\u202c\u200e\u202bفارسی\u202c\u200e\u202aአማርኛ\u202c\u202aनेपाली\u202c\u202aमराठी\u202c\u202aहिन्दी\u202c\u202aবাংলা\u202c\u202aગુજરાતી\u202c\u202aதமிழ்\u202c\u202aతెలుగు\u202c\u202aಕನ್ನಡ\u202c\u202aമലയാളം\u202c\u202aසිංහල\u202c\u202aไทย\u202c\u202aລາວ\u202c\u202aမြန်မာ\u202c\u202aខ្មែរ\u202c\u202a한국어\u202c\u202a中文(香港)\u202c\u202a日本語\u202c\u202a简体中文\u202c\u202a繁體中文\u202c"

I'm not sure if this problem is what you were trying to solve with this patch though.

brunodasilvalenga commented 4 years ago

Hey @Zlender. I don't reckon that problem that you're having is the same that I solved :(( What you can try is to print the response page inside of the python code. Copy the response and paste into a html file and open it in a browser so you will see the error that is returning to you and maybe this step is not cover by the package yet. It's happen because google does changes every time and I was wondering some of could but just a test A/B because that is not everyone is getting the same issue with you.

Zlender commented 4 years ago

@brunodasilvalenga yeah I think you're right. Basically response for the post in https://github.com/cevoaustralia/aws-google-auth/blob/master/aws_google_auth/google.py#L220 is

The browser you\'re using doesn\'t support JavaScript, or has JavaScript turned off.

To keep your Google Account secure, try signing in on a browser that has JavaScript turned on. Learn more
SantiMunoz commented 4 years ago

Thanks a lot @brunodasilvalenga, it worked for me. Is there a plan to merge this fix into master?

mancej commented 4 years ago

@brunodasilvalenga yeah I think you're right. Basically response for the post in https://github.com/cevoaustralia/aws-google-auth/blob/master/aws_google_auth/google.py#L220 is

The browser you\'re using doesn\'t support JavaScript, or has JavaScript turned off.

To keep your Google Account secure, try signing in on a browser that has JavaScript turned on. Learn more

Did you ever find a fix for this? I am also experiencing this issue.

Spenser309 commented 4 years ago

This fix is working for a couple of my users. It would be great to make this part of the official release.

brunodasilvalenga commented 4 years ago

@brunodasilvalenga yeah I think you're right. Basically response for the post in https://github.com/cevoaustralia/aws-google-auth/blob/master/aws_google_auth/google.py#L220 is

The browser you\'re using doesn\'t support JavaScript, or has JavaScript turned off.

To keep your Google Account secure, try signing in on a browser that has JavaScript turned on. Learn more

Did you ever find a fix for this? I am also experiencing this issue.

Hey mate, Sorry I didn't have time yet to see this issue. I'll have a look on that next month. I still waiting for some answer from the developers to merge this PR first.

riccardofreixo commented 4 years ago

Thanks a lot @brunodasilvalenga, this also solved our problem, would be great to see this merged upstream.

dvf commented 4 years ago

Can confirm this solved #183 for me!

stevemac007 commented 4 years ago

Hey all - thanks for the contribution - will get this merged and released into a new build.