docs: update MockSAML example (#11337)

# Which Problems Are Solved

Update MockSAML example to work when the `Automatic creation` IDP
setting is enabled.

# How the Problems Are Solved

By setting `IdpId` and `UserId` in `AddHumanUser.IdpLinks` returned in
the `RetrieveIdentityProviderIntentResponse` response.

# Additional Changes
N/A

# Additional Context
- Related to https://github.com/zitadel/zitadel/issues/11078
- Discussion
https://github.com/zitadel/zitadel/pull/11226#discussion_r2657785280
This commit is contained in:
Gayathri Vijayan
2026-01-12 07:06:45 +01:00
committed by GitHub
parent eb22b58756
commit 049622720c
@@ -192,7 +192,6 @@ func manipulateResponse(resp *retrieveIdentityProviderIntentResponseWrapper) err
if len(rawInfo.Attributes.Email) == 0 ||
len(rawInfo.Attributes.FirstName) == 0 ||
len(rawInfo.Attributes.Id) == 0 ||
len(rawInfo.Attributes.LastName) == 0 {
log.Println("missing required attributes in the IDP response")
return nil
@@ -201,7 +200,8 @@ func manipulateResponse(resp *retrieveIdentityProviderIntentResponseWrapper) err
// to create a new user.
if resp.AddHumanUser != nil {
// set the required fields to create a new user in Zitadel based on the information returned by the IDP
resp.IdpInformation.UserName = rawInfo.Attributes.Email[0]
username := rawInfo.Attributes.Email[0]
resp.IdpInformation.UserName = username
resp.AddHumanUser.Profile = &user.SetHumanProfile{
GivenName: rawInfo.Attributes.FirstName[0],
@@ -211,10 +211,12 @@ func manipulateResponse(resp *retrieveIdentityProviderIntentResponseWrapper) err
Email: rawInfo.Attributes.Email[0],
Verification: &user.SetHumanEmail_IsVerified{IsVerified: true},
}
resp.AddHumanUser.Username = gu.Ptr(rawInfo.Attributes.Email[0])
resp.AddHumanUser.Username = gu.Ptr(username)
resp.AddHumanUser.IdpLinks = []*user.IDPLink{
{
UserName: rawInfo.Attributes.Email[0],
UserName: username,
UserId: resp.GetIdpInformation().GetUserId(),
IdpId: resp.GetIdpInformation().GetIdpId(),
},
}
}