Spring Security UserDetails and username -


in current implementation have user entity implements org.springframework.security.core.userdetails.userdetails interface.

    @entity     @table(name = "users")     public class user extends baseentity implements userdetails {          private static final long serialversionuid = 8884184875433252086l;          @id         @generatedvalue(strategy = generationtype.auto)         private integer id;          private string username;          private string password;     .... 

during oauth2 authorization manually create new user object, populate fields , store in database.

according userdetails contract - userdetails.getusername() method can't return null have no values retrieved social networks can used username.

what value in case should returned in user.getusername() method ?

is okay return ?

@override public string getusername() {     return string.valueof(id); } 

if need save entity before have valid value name think that's problem design. having said user.getusername() used display purposes, doubt matters actual value is, long can matched in authentication.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -