Hello! I developed a custom User Storage for Keycloak, which validates users by communicating with a servlet, so the users are not stored in Keycloak, and it works without issues during testing.
Now, in a second phase, I am configuring an app on WildFly 26.0.1 with Elytron OIDC (configuring it from within the app with oidc.json and web.xml).
When I try to access the protected resource, it redirects me to Keycloak, I log in, and it redirects me back to the protected resource where I want to call user.getName() from the Principal of the request, but it comes back as null.
This is the configuration of my oidc.json:
{
“client-id”: “client”,
“provider-url”: “http://localhost:8180/realms/master”,
“public-client”: false,
“credentials”: {
“secret”: “client_Secret”
},
“principal-attribute”: “preferred_username”,
“ssl-required”: “EXTERNAL”,
“confidential-port”: 0,
“use-resource-role-mappings”: false
}
As you can see, in the principal-attribute I use preferred_username (which I understand should be the username of the UserModel from my custom provider). I tried changing that property to, for example, “name” and it gives me the correct information for that property. Unfortunately, I need the username.
One interesting thing is that if I create a user via the admin console for my realm and use that user to log in, user.getName() gives me the username. Knowing that, I believe it may be some configuration issue in my custom provider.
i read many guides, stackoverflow question, but i didnt found anithing usefull, because most examples create the user in keycloak and thats not my case.