chg: [keycloak mapper] also pushes default mappings if they don't exist

cli-modification-summary
iglocska 2022-10-31 13:36:53 +01:00
parent ce6575cfb6
commit 5ec0471cce
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 16 additions and 0 deletions

View File

@ -427,6 +427,22 @@ class AuthKeycloakBehavior extends Behavior
]
];
}
foreach ($defaultMappers as $defaultMapper => $enabled) {
if (!$enabled) {
$payload[] = [
'protocol' => 'openid-connect',
'name' => $defaultMapper,
'protocolMapper' => 'oidc-usermodel-attribute-mapper',
'config' => [
'id.token.claim' => true,
'access.token.claim' => true,
'userinfo.token.claim' => true,
'user.attribute' => $defaultMapper,
'claim.name' => $defaultMapper
]
];
}
}
if (!empty($payload)) {
$response = $this->restApiRequest('%s/admin/realms/%s/clients/' . $clientId . '/protocol-mappers/add-models', $payload, 'post');
if (!$response->isOk()) {