Fetch Logged In Username in a webapp secured with Keycloak
问题 I have secured an enterprise application with Keycloak using standard wildfly based Keycloak adapters. Issue that I am facing is that the rest web services when invoked, needs to know the username that is currently logged in. How do I get the logged in user information from Keycloak? I tried using SecurityContext , WebListener etc. But none of them are able to give me the required details. 回答1: You get all user information from the security context. Example: public class Greeter { @Context