Have you set your sessionAuthentificationStrategy ?
@Bean
@Override
protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
return new RegisterSessionAuthenticationStrategy(new
SessionRegistryImpl());
}
Or easier, do you have a sample app for us so that we can reproduce the
issue ?
On Thu, Dec 15, 2016 at 6:21 PM, Ondra Pala <pala.ondra(a)gmail.com> wrote:
Yes, or I try
public String handleAdminRequest(HttpServletResponse, Model model)
but still null.
Odesláno z BlueMail <
http://www.bluemail.me/r>
15. 12. 2016, 17:25, Sebastien Blanc <sblanc(a)redhat.com> napsal/a:
>
> How do you retrieve the principal ?
> Something like this ?
>
> @RequestMapping(value = "/admin", method = RequestMethod.GET)
> public String handleAdminRequest(Principal principal, Model model) {
> model.addAttribute("principal", principal);
> return "admin";
> }
>
>
>
> On Thu, Dec 15, 2016 at 5:17 PM, Ondra Pala <pala.ondra(a)gmail.com>
> wrote:
>
>> This attribute I has set ....
>>
>> 2016-12-15 17:11 GMT+01:00 Sebastien Blanc <sblanc(a)redhat.com>:
>>
>>> Set "principal-attribute":"preferr ed_username" in your
keycloak.json
>>> and you should be able to get your username from the Principal object.
>>>
>>>
>>> On Thu, Dec 15, 2016 at 4:53 PM, Ondra Pala <pala.ondra(a)gmail.com>
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> Why I can´t get username of logged user? I can try get this
>>>> information
>>>> from Principal, HttpServletResponse ... but still null.
>>>>
>>>> Our application use for authentification Keycloak, after successfull
>>>> login,
>>>> user is redirect to another url (on the same server) in Java Spring
>>>> MVC
>>>> application.
>>>>
>>>> Thanks for your answers.
>>>>
>>>> Ondra
>>>> ______________________________ _________________
>>>> keycloak-user mailing list
>>>> keycloak-user(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/keycloak-user
>>>
>>>
>>>
>>
>