-
Notifications
You must be signed in to change notification settings - Fork 20
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
With KeyCloak, After supplying credentials, it just hangs #47
Comments
Thank you for writing up this issue Jens. Is your Keycloak server configured to require MFA, or is simply using the username and password sufficient? Also, do you know which version of the Keycloak server you are using? After that last line of output, the code is starting to reach out over the network to your Keycloak server. There are a few things which could be happening here -- The first thing it does is send an HTTP HEAD request to your Since saml2aws appears to be working for you, it should be safe to assume that all of the networking would be in place to allow you to talk to Keycloak. The only thing that aws-runas could be doing which is different from saml2aws is that HTTP HEAD request to the url. |
As I was researching this, I noticed there were some changes released in Keycloak 8 which I needed to make changes in aws-runas for. The fix only applies to situations where you need to use MFA during authentication to Keycloak, and you are using Keycloak 8 or higher. If that is your setup, please test if aws-runas 2.0.1 addresses your issue, otherwise I can keep investigating if you can provide more details. |
Hello, we don't use MFA, and I don't know which version of KeyCloak we are using. We have a login portal which is used for multiple services, and that redirects accordingly. With the new version, it goes one step further:
After that, it hangs. I will point people in charge to this conversation. |
hi there, we use currently KeyCloak 8.0.1 and prepare to rollout 9.0. |
Thank you for the info, and that extra debug data! The update I made for Keycloak 8 really only affects MFA, and the debug statements look like it isn't getting that far down the path in the 1st place. That final message is at the point where it does the HTTP HEAD request to the
and see what happens (using your actual endpoint, of course). A bit more details about the process here. aws-runas uses IDP-initiated authentication to do the SAML stuff, and the way I found to do that with Keycloak is to have the
is the URL I've configured on my local machine to test Keycloak 8. Looking at the saml2aws example at the end of the Configuring IDP Accounts section, it appears they do the same. |
Looking at the saml2aws code, it seems that they require you to explicitly specify the IDP you are using in the configuration. It may be worth adding similar logic to aws-runas so people have the ability to skip this auto-detection logic if it isn't working for them. |
I may have been able to get some insight in to this, as I saw something similar with my setup (it doesn't use Keycloak, but my hunch is that the issue is not IDP-specific). The CDN that sits in front of the IDP used at my employer was having some kind of issue, causing the auto-detection to timeout and fail sporadically. To get around this I implemented a feature similar to what is used with saml2aws, where you can explicitly set a provider in your configuration to bypass the auto-detection logic. If you get aws-runas 2.0.2 and add the following line with the rest of your saml configuration, it may address your issue:
|
This goes one step further before crashing:
|
First, I want to thank you for your patience and help working through this, it's very helpful for me to see ways others are using this tool outside of my limited testing ability for the various SAML implementations. Second, this error is 100% my fault, going back over the code where this is failing, it's doing some URL parsing which isn't even used as part of the SAML or authentication process. I should hopefully have a fix (to remove the dead code paths) ready before you start your day again. |
Please try 2.0.3 when you have the time, it should get past this error as that release no longer parses the auth url (since the parsed results were never used anywhere) |
I double-checked that login URI and password are both correct. I also deleted the |
It's progress, but not the result I was hoping for. I'm trying to compare what my code is doing differently then saml2aws when doing the Keycloak authentication. The only obvious thing is that there's a hidden field which saml2aws is passing, which I wasn't including. In my local setup, that hidden field didn't matter, the authentication still succeeded if it wasn't included in the POST for the authentication, but all I'm doing is running a keycloak docker container (versions 6.0.1, 8.0.1, 8.0.2, and 9.0.2), creating a user, and configuring an AWS SAML client. In a more "production-ready" setup, that field may be important. My hope is that including these hidden fields from the login form will get the authentication working. Please try version 2.0.4 when you have the chance. Thanks! |
A new test with 2.0.5 get the following results:
From the documentation, it's not quite clear where to place the password for SSO/SAML scenario. |
Some good news about that error, the authentication with Keycloak was successful, and aws-runas should have retrieved the SAMLResponse document from Keycloak, and is attempting to do the AssumeRoleWithSaml API call. The term "credentials" with that error message is probably a bit mis-leading, it's referencing the AWS role credentials at this point, and not your personal Keycloak credentials. To find the bit of information the error message is complaining about, it applies a regex to the SAMLResponse document to find the elements which list the roles you have access to, and the associated saml-provider ARN used to integrate the AWS authentication with Keycloak. If you're fluent in regular expressions, it's doing this:
and is using the role_arn from your configuration to find a match for that first bit in parenthesis, and set the PrincipalArn value from that second part in parenthesis, if a match is found. It appears that the matching failed, but I need to figure out why. It could be the case that I need to adjust the regular expression, it assume the data lives on a single line, and with the testing I've done so far, that has held true, although maybe this is the case where that makes that assumption fail? I've also seen configuration errors in either the role ARN in someone's local configuration, or Keycloak SAML setup cause this. The next part of the investigation to narrow that down requires that you decode the SAMLResponse data that's output by the DEBUG log level, and see what Keycloak is handing to AWS for the SAML authentication. The information we're looking for is contained under the XML tag |
To answer the actual question you asked about your personal SAML credentials, the tool will accept your SAML password as an environment variable |
hi @mmmorris1975, thank you for providing fast responses! Please provide instructions how I should debug the output/SAML response to share the information you need to fix the problem. Another question, does the tool integrate with the feature "credential_process" of AWS cli? |
Sorry about that, I should have included some guidance on how to go about that. In the debug output from the command, copy the block of text following the line On my Mac, I save the SAMLResponse info directly from the aws-runas output in a text file (I'll call it my_file in examples) and from the command line, run
(That last "-" is important!) which will provide the XML payload of the SAMLResponse in a format that makes it easier to look at. Linux has similar commands, and the only difference I found is that the Once you have the XML document, near the bottom you will see the AWS ARNs of the roles you have access to, and the SAML integration ARN (PrincipalArn) in the It won't give you the full information that the steps above do, but since it seems we're getting a SAMLResponse from Keycloak at this point, you should be able to use the aws-runas -l command, and it will print the role ARNs that it is finding in the data (it doesn't include that PrincipalArn information). At the very least you can use that to double check your local configuration of the role ARN against what Keycloak is providing to AWS. |
aws-runas doesn't explicitly process any Using aws-runas as the command for the |
I just had time to revisit this, and with the latest version, I still get:
but when running it with the
So, it finds the roles but somehow doesn't like them. My
|
That particular error has something to do with the SAML assertion coming back from KC. The SAML doc has the role and IAM principal ARN (used for the SSO integration), wrapped up in the values in the Role attribute. There's a chance it's a data condition I'm not handling here, if you're able to provide some details about the SAML response from KC, that could be helpful. The latest version of aws-runas will parse and display the interesting bits for this after the base64 encoded saml document. It will look something like:
You could also open up the encoded saml document and find the values in the |
I had someone in my company ask about that same validation error. In their case, it was a typo/misconfiguration in the role ARN in their local config, which caused aws-runas to not match the role when it was examining the SAML assertion, resulting in an empty Principal ARN being used for the STS calls. I'll work on making that more robust (or at least a less cryptic error message), but thought I would pass along that information, in case it's helpful in tracking down the source of the issue. |
I followed the guide, and specified the necessary information. Here is my config:
Then I did:
aws-runas password
and entered the password.When I now do
aws-runas -v
I get output like this:After that, it hangs.
I tried
saml2aws
which works fine but doesn't supportcredential_process
.We are using KeyCloak in our company.
What am I missing?
The text was updated successfully, but these errors were encountered: