Skip to content

External IdP integration with ADFS may fail. #16154

Closed as not planned
Closed as not planned

Description

@y-tabata

Before reporting an issue

  • I have searched existing issues
  • 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".

The cause is this PR.
#13757

ADFS's version
OS Name: Microsoft Windows Server 2019 Datacenter
OS Version: 10.0.17763 N/A Build 17763

Version

20.0.1

Expected behavior

External IdP integration with ADFS not fail.

Actual behavior

External IdP integration with ADFS may fail.

How to Reproduce?

Integrate ADFS as an external IdP using the OIDC identity provider.

Anything else?

No response

Activity

  1. added
    kind/bug
    on Dec 22, 2022
  2. ghost added
    area/identity-brokering
    on Dec 22, 2022
  3. added this to the milestone on Apr 4, 2023
  4. mposolda commented on Apr 4, 2023

    @mposolda
    Contributor

    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.
  5. rmartinc commented on Jan 29, 2024

    @rmartinc
    Contributor

    @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?

  6. self-assigned this
    on Jan 29, 2024
  7. y-tabata commented on Feb 2, 2024

    @y-tabata
    ContributorAuthor

    @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.

    fNXBt19wC-6XTQ_Pu8Ny3WJw8UEf19isZTyo_CRoqno.uDZnAGhOXWs.9sfeNnXrSVScx9%2BnmfbFfw
    
  8. rmartinc commented on Feb 2, 2024

    @rmartinc
    Contributor

    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.

  9. y-tabata commented on Feb 6, 2024

    @y-tabata
    ContributorAuthor

    @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.

  10. rmartinc commented on Feb 6, 2024

    @rmartinc
    Contributor

    @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.

  11. y-tabata commented on Feb 7, 2024

    @y-tabata
    ContributorAuthor

    @rmartinc Thanks for checking!

  12. removed this from the milestone on Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/identity-brokeringkind/bugteam/core-iam

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions