chore(keycloak): code cleanup
This commit is contained in:
@@ -35,12 +35,10 @@ async function main() {
|
||||
clientId: "admin-cli",
|
||||
});
|
||||
|
||||
// Set realm to work with
|
||||
kcAdminClient.setConfig({
|
||||
realmName,
|
||||
});
|
||||
|
||||
// Find the client
|
||||
const clients = await kcAdminClient.clients.find({ clientId });
|
||||
if (clients.length === 0) {
|
||||
throw new Error(`Client '${clientId}' not found in realm '${realmName}'`);
|
||||
@@ -49,7 +47,6 @@ async function main() {
|
||||
const client = clients[0];
|
||||
const clientInternalId = client.id!;
|
||||
|
||||
// Find existing mapper
|
||||
const mappers = await kcAdminClient.clients.listProtocolMappers({ id: clientInternalId });
|
||||
const existingMapper = mappers.find((mapper) => mapper.name === mapperName);
|
||||
|
||||
@@ -61,7 +58,6 @@ async function main() {
|
||||
});
|
||||
}
|
||||
|
||||
// Create updated client roles protocol mapper
|
||||
await kcAdminClient.clients.addProtocolMapper(
|
||||
{ id: clientInternalId },
|
||||
{
|
||||
@@ -74,13 +70,15 @@ async function main() {
|
||||
"access.token.claim": "true",
|
||||
"claim.name": claimName,
|
||||
"jsonType.label": "String",
|
||||
"multivalued": "true",
|
||||
multivalued: "true",
|
||||
"usermodel.clientRoleMapping.clientId": clientId,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
console.log(`✓ Client roles mapper '${mapperName}' updated for client '${clientId}' in realm '${realmName}'`);
|
||||
console.log(
|
||||
`✓ Client roles mapper '${mapperName}' updated for client '${clientId}' in realm '${realmName}'`
|
||||
);
|
||||
console.log(` Claim name: ${claimName}`);
|
||||
console.log(` User Info: enabled`);
|
||||
console.log(` Access Token: enabled`);
|
||||
@@ -91,4 +89,4 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch(console.error);
|
||||
|
||||
Reference in New Issue
Block a user