Social: Microsoft - Enable single-tenant app registrations#11207
Social: Microsoft - Enable single-tenant app registrations#11207Exordian wants to merge 1 commit into
Conversation
|
Error message on single-tenant app registrations when used with the Microsoft Social provider: |
|
cc @sguilhen ; i hope it's not rude to notify you and ask for a review. Thanks in advance! I'd argue that the change is quite minimal and you have been the latest RedHatter who worked on the microsoft federation plugin. We'd be very glad if we could ditch our custom plugin again and use the upstream code again for the MS federation plugin |
|
@Exordian no problem at all - I didn't reply earlier because I was on PTO until today. I'll try to take a look early next week. |
|
@sguilhen ping ;) |
| @@ -0,0 +1,25 @@ | |||
| package org.keycloak.social.microsoft; | |||
There was a problem hiding this comment.
Please add the copyright header to this new file
|
@ssilvert can you review the admin console changes here? |
|
@sguilhen @Exordian I don't mind accepting these small changes, but we are trying to get away from changing the old admin console. Furthermore, to accept these changes, I need to see equivalent changes in the new console at keycloak/keycloak-admin-ui. |
pedroigor
left a comment
There was a problem hiding this comment.
LGTM, looking at the broker changes.
We also need to run social tests for this one.
|
@Exordian Could you please create an issue and link it here by changing your commit to reference it? Please, see other PRs to check how the commit message should look like. |
|
Started keycloak-build-pipeline/757/. |
|
Running build #759. |
|
thanks for the review. i hope i find some minutes next week in order to test this change with the new admin UI and create an issue with a similar text as mentioned above. |
|
@Exordian can I help move this forward? |
|
Superseded by #20699 |
This change allows the usage of "single-tenant" App Registrations on Azure AD.
Microsoft distinguishes between single-tenant and multi-tenant app registrations.
Usually, enterprise companies would rather like to use so called "single-tenant" app registrations instead of multi-tenant app registrations [1], as they're limited to users in their tenant.
Since 2018, Microsoft disallowed the use of the global "/common/" endpoints for single-tenant applications [2]. The usual answer on the internet has been "use the generic oidc provider". While the generic OIDC provider works fine most of the cases, it doesn't work properly when using the "exchange-token" feature of keycloak.
The generic OIDC connector maps user identities to the OIDC subject field "sub" [3], which differs on the same account for every client on Microsoft [4] (OIDC spec refers to the 'pairwise' mode here [5]). However, the microsoft social connector stores the object id of the account in keycloak for federated users [6].
Therefore, while using the token-exchange feature from external to internal tokens, the different "sub" fields per client for the same account leads to mapping problems [7]. The token-exchange provider fails to find the respective user and tries to create a new user with the same mail address, which fails.
This patch allows to use the Microsoft social provider with single-tenant apps, which
Related, if you think it's worth to discuss, we should open a seperate issue:
I'd argue that it would also be nice to customize the keycloak id of federated users on the generic oidc provider. Microsoft offers "oid" next to "sub" in their access tokens to get the object id of an Azure user.
[1] https://docs.microsoft.com/en-us/azure/active-directory/develop/single-and-multi-tenant-apps
[2] https://keycloak.discourse.group/t/how-to-configure-microsoft-identity-provider-with-single-tenant/11741 https://lists.jboss.org/pipermail/keycloak-user/2019-February/017254.html
[3] https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java#L651
[4] https://stackoverflow.com/questions/52876679/the-sub-claim-value-is-different-between-access-and-id-tokens
[5] https://openid.net/specs/openid-connect-core-1_0.html#SubjectIDTypes
[6] https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/social/microsoft/MicrosoftIdentityProvider.java#L80
[7] https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/protocol/oidc/DefaultTokenExchangeProvider.java#L485