Repository navigation
|
Hi there! I'm migrating a custom user federation from an obsolete Keycloak version using Wildfly to a newer one using Quarkus. I implemented However, I don't see I also get an error when I try to do any change to a user, for example adding a required action, and it happens even if I do no changes to the user and just click on Save. The error is Following is a screenshot of both, the missing values and the error when trying to save the user without doing 8000 any change: I enabled the debug log level. When this error happens, this is what's being logged: DEBUG [WebApplicationException] (executor-thread-10) Restarting handler chain for exception exception: org.keycloak.services.ErrorResponseException: HTTP 500 Internal Server Error
2025-04-07 15:51:53 at org.keycloak.services.ErrorResponse.errors(ErrorResponse.java:52)
2025-04-07 15:51:53 at org.keycloak.services.ErrorResponse.errors(ErrorResponse.java:47)
2025-04-07 15:51:53 at org.keycloak.services.resources.admin.UserResource.validateUserProfile(UserResource.java:269)
2025-04-07 15:51:53 at org.keycloak.services.resources.admin.UserResource.updateUser(UserResource.java:206)
2025-04-07 15:51:53 at org.keycloak.services.resources.admin.UserResource$quarkusrestinvoker$updateUser_06a139c72250da7941838b1def60a9f82f9ef70d.invoke(Unknown Source)
2025-04-07 15:51:53 at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
2025-04-07 15:51:53 at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
2025-04-07 15:51:53 at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
2025-04-07 15:51:53 at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:582)
2025-04-07 15:51:53 at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
2025-04-07 15:51:53 at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
2025-04-07 15:51:53 at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
2025-04-07 15:51:53 at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
2025-04-07 15:51:53 at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
2025-04-07 15:51:53 at java.base/java.lang.Thread.run(Thread.java:1583)From the network tab on my browser, I see this request being made: HTTP MethodPUT HTTP Error400 Bad Request Endpointhttp://localhost:8000/admin/realms/myrealm/users/f%3Ad31de129-e3b5-4c8c-b901-6de43fa351d4%3Anahuel Request Body{
"id": "f:d31de129-e3b5-4c8c-b901-6de43fa351d4:nahuel",
"username": "nahuel",
"emailVerified": false,
"origin": "d31de129-e3b5-4c8c-b901-6de43fa351d4",
"createdTimestamp": 1744051910700,
"enabled": true,
"totp": false,
"disableableCredentialTypes": [],
"requiredActions": [],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
},
"attributes": {},
"email": "",
"firstName": "",
"lastName": ""
}As you can see, the username is being sent as part of the request body. Response{
"field": "username",
"errorMessage": "error-user-attribute-read-only",
"params": [
"username"
]
}I thought about a missing interface I should implement too related to user updates, but I couldn't find any interface for this, and the Keycloak documentation doesn't mention anything about this. I appreciate any help on this cryptic error. Thanks in advance! |
Replies: 1 comment
|
The fix is basically not storing the username as an attribute in the custom adapter code: // This shouldn't be done (I was doing it as part of the custom adapter's code)
getFederatedStorage().setSingleAttribute(realm, getId(), mapAttribute(UserModel.USERNAME), "my-username"); |
I fixed my issue. I didn't realize that I implemented the wrongUserModelinterface.ImplementingAbstractUserAdapterFederatedStorageinstead ofAbstractUserAdapterand selectingNO_CACHEas cache policy for my custom user federation did the trick.The fix is basically not storing the username as an attribute in the custom adapter code: