Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aad] Adding support for conditional MFA #684

Merged
merged 2 commits into from
Jul 17, 2021
Merged

[aad] Adding support for conditional MFA #684

merged 2 commits into from
Jul 17, 2021

Conversation

missingcharacter
Copy link
Contributor

@missingcharacter missingcharacter commented Jun 30, 2021

Trying to close #628
I tested locally and works for me (user with conditional MFA) and a co-worker (user without conditional MFA)

The biggest changes are:

  1. Extracted MFA logic into its own function called processAuth.
  2. Now we call processAuth twice, after each time mfa was skipped

@eliasericsson
Copy link

Getting the following error when running:

error authenticating to IdP: error retrieving form: Get "https://account.activedirectory.windowsazure.com/applications/redirecttofederatedapplication.aspx?Operation=LinkedSignIn&applicationId=********-****-****-****-************": dial tcp: lookup account.activedirectory.windowsazure.com on 172.17.160.1:53: read udp 172.17.175.179:57299->172.17.160.1:53: i/o timeout

Not sure if it is relevant, but perhaps you would like to know.

@missingcharacter
Copy link
Contributor Author

missingcharacter commented Jul 6, 2021

@eliasericsson I believe these IPs are private https://www.rfc-editor.org/rfc/rfc1918.txt

  • 172.17.160.1
  • 172.17.175.179
  • 172.17.160.1

Are you behind a proxy?
On a VPN?
Office Network?
or something like that?

I'm asking because the error seems to be coming at the beginning of the Authenticate function
image

@eliasericsson
Copy link

Nope, not on any VPN.

I'm on Ubuntu 20.04.2 LTS through WSL2 (Windows Subsystem for Linux). Could that be an issue?

@missingcharacter
Copy link
Contributor Author

missingcharacter commented Jul 6, 2021

@eliasericsson WSL2 configuration could be the culprit, I see port 53 a couple of times here: 172.17.160.1:53: read udp 172.17.175.179:57299->172.17.160.1:53: i/o timeout could be DNS within WSL2 is not getting a result for account.activedirectory.windowsazure.com

Please try running each of these:

  • nslookup account.activedirectory.windowsazure.com
  • nslookup account.activedirectory.windowsazure.com 8.8.8.8

to see if you get different results

Note: if you don't have nslookup installed you can also use:

  • dig +short account.activedirectory.windowsazure.com
  • dig +short account.activedirectory.windowsazure.com @8.8.8.8

@eliasericsson
Copy link

Looks very similar to me

❯ nslookup account.activedirectory.windowsazure.com
Server:         172.17.160.1
Address:        172.17.160.1#53

Non-authoritative answer:
account.activedirectory.windowsazure.com        canonical name = na.privatelink.msidentity.com.
na.privatelink.msidentity.com   canonical name = prdf.aadg.msidentity.com.
prdf.aadg.msidentity.com        canonical name = www.tm.f.prd.aadg.akadns.net.
Name:   www.tm.f.prd.aadg.akadns.net
Address: 40.126.32.70
Name:   www.tm.f.prd.aadg.akadns.net
Address: 20.190.160.66
Name:   www.tm.f.prd.aadg.akadns.net
Address: 20.190.160.65
Name:   www.tm.f.prd.aadg.akadns.net
Address: 40.126.32.2


❯ nslookup account.activedirectory.windowsazure.com 8.8.8.8
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
account.activedirectory.windowsazure.com        canonical name = na.privatelink.msidentity.com.
na.privatelink.msidentity.com   canonical name = prdf.aadg.msidentity.com.
prdf.aadg.msidentity.com        canonical name = www.tm.f.prd.aadg.akadns.net.
Name:   www.tm.f.prd.aadg.akadns.net
Address: 40.126.32.2
Name:   www.tm.f.prd.aadg.akadns.net
Address: 20.190.160.66
Name:   www.tm.f.prd.aadg.akadns.net
Address: 20.190.160.65
Name:   www.tm.f.prd.aadg.akadns.net
Address: 40.126.32.70

@missingcharacter
Copy link
Contributor Author

@eliasericsson if you try running saml2aws again, do you get the same error?

@eliasericsson
Copy link

First error occurs on line 787 due to SAMLRequestURL == "", but bypassing that by setting it to SAMLRequestURL = "https://*-**********.awsapps.com/start" I still get an error on line 748 due to authSubmitURL == ""

@eliasericsson
Copy link

Different error, yes. Guessing the previous error was intermittent.

@missingcharacter
Copy link
Contributor Author

missingcharacter commented Jul 6, 2021

@eliasericsson that's weird, your SAMLRequestURL should be something like https://login.microsoftonline.com/<Directory (Tenant) ID>/saml2?SAMLRequest=<SAMLRequestValue>

You can see your Directory (tenant) ID in Azure AD -> Enterprise applications -> Amazon Web Services or whatever name you gave to this Azure App
image

@eliasericsson
Copy link

Well, writing out the oidcResponse to a file and grep'ing it shows no "SAMLRequest=" at all.

So I cannot construct the URL above. I know the tenant ID, but not the SAMLRequestValue.

@missingcharacter
Copy link
Contributor Author

@eliasericsson SAMLRequestValue is generated by the identity provider (Azure AD in this case) for this request and it is short lived.

I'm starting to think our problems are different since you are going from Azure AD -> AWS SSO described:

While I am going from Azure AD -> IAM SAML provider https://signin.aws.amazon.com/saml as described here: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml_assertions.html

@eliasericsson
Copy link

Yep, that seems to be it!

@missingcharacter
Copy link
Contributor Author

@missingcharacter
Copy link
Contributor Author

@eliasericsson please, let me know if awscli worked for you

@missingcharacter
Copy link
Contributor Author

@wolfeidau is there something I should add/modify in this PR to facilitate being merged?

@eliasericsson
Copy link

@missingcharacter yes awscli sso worked fine!

@wolfeidau wolfeidau merged commit f24835f into Versent:master Jul 17, 2021
@missingcharacter missingcharacter deleted the aad-conditional-MFA branch July 17, 2021 13:01
JohnPaton added a commit to JohnPaton/saml2aws that referenced this pull request Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AzureAD: unable to locate SAMLRequest URL, error authenticating to IdP
3 participants