reset password
Author Message
dguhath
Posts: 61
Posted 12:09 Feb 27, 2015 |

Hello Dr. Sun,

Can we have both authorities-by-username-query & user-service-ref in our configuration? As we cannot have both jdbc-user-service & user-service-ref together and we declare authorities-by-username-query inside jdbc-user-service.

Thanks.

cysun
Posts: 2935
Posted 13:50 Feb 27, 2015 |

You just answered your own question.

dguhath
Posts: 61
Posted 13:58 Feb 27, 2015 |

Yea I thought so Dr. Sun. But the problem is i need both with the current code I have in my application. The only solution I see here is to use the default Spring authorities/roles configuration(same as CSNS).

But in CSNS we should need the query right? as the authorities table has user_id instead of username?

Thanks Dr. Sun

Last edited by dguhath at 14:06 Feb 27, 2015.
cysun
Posts: 2935
Posted 14:02 Feb 27, 2015 |

I'd think that you either write your own user service or use <jdbc-user-service>. Why do you need both?

dguhath
Posts: 61
Posted 14:09 Feb 27, 2015 |

so to get the User object through getPrincipal() i am implementing UserDetails in User class. So I need the user service. I needed the query as my authorities table doesn't have the default configuration.

Thanks.

cysun
Posts: 2935
Posted 14:16 Feb 27, 2015 |

To get your User object from getPrincipal(), just implementing UserDetails is not enough. You need to do three things as explained in the lectures notes:

  • Implement UserDetails
  • Implement UserDetailsService
  • Use your UserDetailsSerivce implementation in <authentication-provider>

You can't use <jdbc-user-service> because it won't use your UserDetails implementation even if you change the queries.

dguhath
Posts: 61
Posted 14:16 Feb 27, 2015 |

Does the getAuthorities method in the User class provide Spring framework with the authority info?

Thanks.

cysun
Posts: 2935
Posted 14:18 Feb 27, 2015 |
dguhath wrote:

Does the getAuthorities method in the User class provide Spring framework with the authority info?

Thanks.

You need to make sure it does when you create your UserDetails implementation.

dguhath
Posts: 61
Posted 14:31 Feb 27, 2015 |

I had it implemented before. And now I understand why its required.

Thanks Dr. Sun.