In spring security, UserDetails uses username as an identifier of user. My user model have multiple types of identifications and have multiple ways of authentication (via email, phone number, facebook, etc).
I am using AuthorizationServerEndpointsConfigurer
to configure my oauth2 endpoints. JdbcTokenStore
stores user_name
in database, and what I need to store is userId
. I already changed the JdbcTokenStore
to fill my needs, but I am not understanding why spring framework makes the assumption that the username is the unique identifier, my app does not even use usernames.
For example, in TokenStore
inferface findTokensByClientIdAndUserName
is based in username, why not findTokensByClientIdAndUserId
? If I authenticate the user with email or phone number, how can I get all tokens for that user?
My user model example: id
, email
, phone number
, facebook_id
, name
. Email, phone number and facebook id are optional, only one of them are required. In this case what is the best candidate for username? Should I use user id as an username in spring way of abstraction?