org.springframework.security.core.userdetails.User cannot be cast to MyUser

后端 未结 2 1705
你的背包
你的背包 2021-01-13 16:05

This is a spring security question.

I want to be able to retrieve my custom User object object using

SecurityContextHolder.getContext().getAuthentic         


        
2条回答
  •  再見小時候
    2021-01-13 16:34

    Answering my own question -

    The issue was not overriding loadUserByUsername(String username) from JdbcDaoImpl.

    Therefore JdbcDaoImpl's implementation of loadUserByUsername(String username) was being called, which though internally was first calling loadUsersByUsername(String username), was subsequently adding granted authorities to the MyUser object returned above and returning it as a org.springframework.security.core.userdetails.User object.

提交回复
热议问题