This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom credentials in spring security

 
shanthi naidu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Im new to spring security; the applcation im working on uses the default authentication manager which takes
user name and password as credentials.

Now my requirement is that i have to login using user id instead of username;
For this do i need to add my custom authentication manager provider?

In that case what classes i have to create by extending the existing classes (like AuthenticationManager, Authentication)

Please suggest me


Thanks & Regards,
Shanthi Naidu




 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Username, user id, login name, they all mean the same thing to me.

Why do you see it meaning something different?

Which UserDetailsService are you using, JDBC, LDAP, etc?
For JDBC just change the userByUserName property or authoritiesByUserName property to go to the name of the fields in the database that you have that don't match the default built in queries.

Remember the userByUserName property query has to return three fields; username(userID), password, and boolean for enabled.
The authoritiesByUserName query has to return two fields; username(UserID), role
For the role field, make sure it is prefixed with "ROLE_"

Good Luck

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic