Fetch Logged In Username in a webapp secured with Keycloak

前端 未结 5 621
轻奢々
轻奢々 2020-12-14 18:11

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, nee

5条回答
  •  借酒劲吻你
    2020-12-14 18:58

    In my case i was taking the preferred user name from the token like this

    keycloakPrincipal.getKeycloakSecurityContext().getToken();
    token.getPreferredUsername();
    

    To work i had to go to keycloak and add on my client template the add builtins if not added preferred username came null.

    Check the username on the built ins, client template -> mappers.

    After that if worked!

提交回复
热议问题