Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log user authentication

 
James Daniel
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Spring Security 3.0.4 and would like to log when a user successfully logs in. What is the best way to do this?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Daniel wrote:I am using Spring Security 3.0.4 and would like to log when a user successfully logs in. What is the best way to do this?


Which UserDetailsService are you using. You can always customize it yourself. You can either implement UserDetailsService interface, it just has one method. Or you can extend the UserDetailsService you are using, have the first line of code call super.loadUserByUserName(userName) then the code after logs a message.

Or you can try using Spring AOP and define a pointcut expression that matches loadUserByUserName. and do an AfterSuccessful advice type.

Mark
 
James Daniel
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

Thanks so much for the information. Sounds like either will work out for me. I'll give them a try.

Jim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic