I'm in the process of updating an internal app with OIDC and SCIM with the goal of having sign-on and provisioning driven by Azure AD.
Looking at the Azure docs for OIDC and SCIM, there seems to be a discrepancy around how to uniquely identify users. Coming into this project, I presumed the user's ObjectId would be made readily available.
Using a test enterprise app, and navigating to user attribute mapping for provisioning: The default mappings include userPrincipalName
(upn) mapping to userName
with the highest matching precedence. And the inability to modify that mapping.
Also, mailNickname
is mapped to externalId
, without any matching precedence, but this could be changed to map objectId
to externalId
and add matching if desired.
Meanwhile, using another test enterprise app for OIDC, the sub
claim is not the user's Object Id. I think I read the sub
claim is a unique value for the user and the enterprise app (which means it's no good to anyone).
Under Token Configuration, there does not seem to be the option of adding the Object Id as an optional claim at all. There is the option to add the upn
as an optional claim, but the description explicitly states not use the value for keying the user.
An identifier for the user that can be used with the username_hint parameter; not a durable identifier for the user and should not be used to key data
This comment makes sense to me. upn
s can change over time and should not be used to identify users for the same reasons that you shouldn't rely on a user's email not changing.
All that being said; if I want Azure AD to provision users via SCIM and then allow those users to sign in with OIDC, how should I uniquely identify the user record as the service provider?