You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
External IdP integration with ADFS may fail. #16154
I have reproduced the issue with the latest release
Area
identity-brokering
Describe the bug
After version up from 18.0.2 to 20.0.1, external IdP integration with ADFS may fail.
The condition is when the state parameter in an authorization request includes "%2B".
In this case, ADFS returns the state parameter in an authorization response that includes "+" instead of "%2B".
Generally thinking, this is an ADFS bug and ADFS should encode "+" to "%2B".
However, ideally, Keycloak should not send a confusing state value that can be read in two ways like "+" and "%2B".
Thanks for the report, but unfortunately due the amount of other reported issues and other priorities, Keycloak team does not have time to properly triage this bug. So preliminary added to Backlog for now.
It will be helpful if:
You can verify if still applicable in latest Keycloak released version. If not, then it is welcome to close this issue.
If you figure that this may not be a valid bug (for example just a mistake in configuration etc), it will be also welcome to close this issue
If still applicable in latest version, it will be welcome to add the comment as well, that this was still reproduced with latest Keycloak version as it is very valuable info. Anyone is welcome to comment with this or add other relevant comments to this issue.
@y-tabata The relayState used by the saml provider is a combination of <state>.<client-id>.<tab-id> and all of them are encode in Base64Url (so normal chars and - and _). So in normal usage I don't see when the + can be added to the relay state. The only option is if the client does not have an UUID id and then the clientId (not encoded is used). Can you paste what is the relay state keycloak is sending to ADFS?
@rmartinc
As I described above, I reported about not the relayState used by the SAML provider, but the state used by the OIDC provider.
The state value in the authorization request from Keycloak is like the following.
So you are configuring ADFS as OIDC provider, right? (I thought it was as a saml provider, ADFS can be both, but it's more or less the same idea.)
The state is <state>.<tab-id>.<client-id> so the + is in the client-id. Looking the code here, the client-id normally is the the base64url of the UUID of the client ID. But probably in your case it's using the clientId because the ID is not and UUID. Can you please check what is the clientId and ID of the client that initiated the login against keycloak? (The initial one, before clicking in the identity provider to go to the ADFS.)
As commented previously, normally the ID of a client is an UUID and this is used encoded in base64url not containing a +sign.
@rmartinc
The ClientID is opscenter. The ID of the client is unknown.
The phenomenon is, as described above, after version up from 18.0.2 to 20.0.1, external IdP integration with ADFS may fail.
The state value in 18.0.2 is: o6vRcdpD14Y40V3diGdKua8pAUvsGsxSo1n9H7NXZok.zX3FrrCD6dk.opscenter.
The state value in 20.0.1 is: kPj7IIA3IvEA-BTqOuXbCZYENoLjiWBbRMEs-NxR51Y.KswxDCWN_hg.JUDHDiqwSZ%2BvXNblUSl5RA.
@y-tabata Checking the history of the file this has been fixed in #15734, so it's fixed in 22.0.2. It was changed to Base64 in #10227 (with + and /, 22.0.0) and and to base64url in #15734 (- and _, 22.0.2). So this is already fixed in keycloak. I'm closing this as duplicate of #15734.
Activity
mposolda commentedon Apr 4, 2023
Thanks for the report, but unfortunately due the amount of other reported issues and other priorities, Keycloak team does not have time to properly triage this bug. So preliminary added to Backlog for now.
It will be helpful if:
rmartinc commentedon Jan 29, 2024
@y-tabata The
relayStateused by the saml provider is a combination of<state>.<client-id>.<tab-id>and all of them are encode in Base64Url (so normal chars and-and_). So in normal usage I don't see when the+can be added to the relay state. The only option is if the client does not have an UUID id and then theclientId(not encoded is used). Can you paste what is the relay state keycloak is sending to ADFS?y-tabata commentedon Feb 2, 2024
@rmartinc
As I described above, I reported about not the
relayStateused by the SAML provider, but thestateused by the OIDC provider.The state value in the authorization request from Keycloak is like the following.
rmartinc commentedon Feb 2, 2024
HI @y-tabata!
So you are configuring ADFS as OIDC provider, right? (I thought it was as a saml provider, ADFS can be both, but it's more or less the same idea.)
The state is
<state>.<tab-id>.<client-id>so the+is in the client-id. Looking the code here, the client-id normally is the the base64url of the UUID of the client ID. But probably in your case it's using the clientId because the ID is not and UUID. Can you please check what is the clientId and ID of the client that initiated the login against keycloak? (The initial one, before clicking in the identity provider to go to the ADFS.)As commented previously, normally the ID of a client is an UUID and this is used encoded in base64url not containing a
+sign.y-tabata commentedon Feb 6, 2024
@rmartinc
The ClientID is
opscenter. The ID of the client is unknown.The phenomenon is, as described above, after version up from 18.0.2 to 20.0.1, external IdP integration with ADFS may fail.
The state value in 18.0.2 is:
o6vRcdpD14Y40V3diGdKua8pAUvsGsxSo1n9H7NXZok.zX3FrrCD6dk.opscenter.The state value in 20.0.1 is:
kPj7IIA3IvEA-BTqOuXbCZYENoLjiWBbRMEs-NxR51Y.KswxDCWN_hg.JUDHDiqwSZ%2BvXNblUSl5RA.rmartinc commentedon Feb 6, 2024
@y-tabata Checking the history of the file this has been fixed in #15734, so it's fixed in 22.0.2. It was changed to Base64 in #10227 (with
+and/, 22.0.0) and and to base64url in #15734 (-and_, 22.0.2). So this is already fixed in keycloak. I'm closing this as duplicate of #15734.y-tabata commentedon Feb 7, 2024
@rmartinc Thanks for checking!