admin管理员组文章数量:1356908
In a Quarkus application I'm trying to automate tests with Keycloak dev service integration with these props:
%test.quarkus.oidc.enabled=true
%test.quarkus.keycloak.devservices.enabled=true
%test.quarkus.keycloak.devservices.realm-path=quarkus-realm.json
and these dependencies:
implementation 'io.quarkus:quarkus-oidc'
implementation 'io.quarkus:quarkus-oidc-client'
implementation("io.quarkus:quarkus-keycloak-admin-client")
where the quarkus-realm.json
is this:
{
"realm": "quarkus",
"enabled": true,
"groups": [
{
"name": "AziendaXXX"
},
{
"name": "AziendaYYY"
}
],
"users": [
{
"username": "alice",
"enabled": true,
"emailVerified": true,
"firstName": "Alice",
"lastName": "Wonderland",
"credentials": [
{
"type": "password",
"value": "alice"
}
],
"clientRoles": {
"realm-management": [
"view-clients",
"manage-users",
"view-users"
],
"front-end": [
"ADMIN"
]
},
"groups": [
"/AziendaXXX",
"/AziendaYYY"
],
"attributes": {
"phoneNumber": "1234567890",
"profilePic": "alice-pic-base64",
"authType": "keycloak"
}
},
{
"username": "bob",
"enabled": true,
"emailVerified": true,
"firstName": "Bob",
"lastName": "Builder",
"credentials": [
{
"type": "password",
"value": "bob"
}
],
"clientRoles": {
"realm-management": [
"view-clients",
"manage-users",
"view-users"
],
"front-end": [
"ADMIN"
]
},
"groups": [
"/AziendaXXX"
],
"attributes": {
"phoneNumber": "0987654321",
"profilePic": "bob-pic-base64",
"authType": "keycloak"
}
}
],
"clients": [
{
"clientId": "back-end",
"enabled": true,
"secret": "xxx",
"clientAuthenticatorType": "client-secret",
"redirectUris": [
"*"
],
"webOrigins": [
"*"
],
"publicClient": false,
"protocol": "openid-connect",
"serviceAccountsEnabled": true,
"directAccessGrantsEnabled": true
},
{
"clientId": "front-end",
"enabled": true,
"publicClient": true,
"protocol": "openid-connect",
"redirectUris": [
"*"
],
"webOrigins": [
"*"
],
"directAccessGrantsEnabled": true,
"standardFlowEnabled": true,
"implicitFlowEnabled": false,
"serviceAccountsEnabled": false,
"protocolMappers": [
{
"name": "roles",
"protocol": "openid-connect",
"protocolMapper": "oidc-usermodel-client-role-mapper",
"consentRequired": false,
"config": {
"multivalued": "true",
"userinfo.token.claim": "true",
"id.token.claim": "true",
"access.token.claim": "true",
"claim.name": "roles",
"jsonType.label": "String",
"client.id": "front-end"
}
},
{
"name": "groups-to-aziende",
"protocol": "openid-connect",
"protocolMapper": "oidc-group-membership-mapper",
"consentRequired": false,
"config": {
"claim.name": "aziende",
"full.path": "false",
"id.token.claim": "true",
"access.token.claim": "true",
"userinfo.token.claim": "true"
}
}
]
}
],
"roles": {
"client": {
"front-end": [
{
"name": "ADMIN",
"description": "",
"composite": false,
"clientRole": true
}
]
}
}
}
If I get an existing user (alice or bob) the attributes are correctly showed, but when I try to create a new user and update the attributes with this method:
private void setUserAttributes(String userId, Map<String, List<String>> attributes) {
UserResource userResource = keycloak.realm(realm).users().get(userId);
UserRepresentation user = userResource.toRepresentation();
if (attributes != null && !attributes.isEmpty()) {
user.setAttributes(attributes);
userResource.update(user);
}
}
The attributes of the new user are null.
Like the user.setAttributes(attributes);
and userResource.update(user);
does nothing.
Why?
本文标签: javaWhy quarkuskeycloakadminclient does not add attributes to userStack Overflow
版权声明:本文标题:java - Why quarkus-keycloak-admin-client does not add attributes to user? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744043078a2581023.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论