0

In my grails application I'm using spring security plugin to handle authentication using email and password of a user.

Now I need to integrate my application with an external system which works on membership number and password.

In 2nd scenario I want to authenticate user by asking them their membership number and password call an external web-service fetch their information like email and authenticate them in my current application.

So effectively user can either use directly their email address and password combination or membership number and password combination to authenticate them selves.

Any suggestion how I can achieve this ... thanks in advance :-)

Hussain Fakhruddin
  • 3,202
  • 4
  • 25
  • 36

2 Answers2

1

Please see my answers to Spring Security and External Application for Authentication (Single-sign-on) and Configuring Spring Security 3.x to have multiple entry points. You need to create two tokens (one can be the default UsernamePasswordAuthenticationToken and second could be your custom MembershipPasswordAuthenticationToken (basically a duplicate of UsernamePasswordAuthenticationToken extending AbstractAuthenticationToken). Since one authentication provider can support more than one token, you can write logic in your provider to check class of token and do appropriate authentication. For example, if incoming token is of class MembershipPasswordAuthenticationToken then call webservice to get email.

Community
  • 1
  • 1
Ritesh
  • 7,472
  • 2
  • 39
  • 43
1

Never done that, but I think You should look into AuthenticationProvider interface (link) and make your own implementation which could authenticate user in a standard manner or with some callback information which is returned from external application. Here are some information about how to integrate custom provider into application.

jjczopek
  • 3,319
  • 2
  • 32
  • 72