在grails中使用外部web服务验证用户 [英] Authenticate user using external webservice in grails

查看:110
本文介绍了在grails中使用外部web服务验证用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



现在我需要将我的应用程序与外部应用程序集成系统在会员编号和密码上工作。



在第二种情况下,我想通过询问用户的会员编号和密码来调用外部Web服务来获取他们的信息电子邮件和身份验证他们在我当前的应用程序。



因此,有效的用户可以直接使用他们的电子邮件地址和密码组合或会员编号和密码组合来认证他们自己。 p>

任何建议我如何实现这一点...在此先感谢: - )

解决方案

请参阅我对 Spring Security和外部申请Authen (Single-sign-on)配置Spring Security 3.x以拥有多个入口点。您需要创建两个令牌(一个可以是默认的 UsernamePasswordAuthenticationToken ,第二个可以是您的自定义 MembershipPasswordAuthenticationToken UsernamePasswordAuthenticationToken 扩展 AbstractAuthenticationToken )。由于一个身份验证提供程序可以支持多个标记,因此可以在您的提供程序中编写逻辑例如,如果传入令牌的类是 MembershipPasswordAuthenticationToken ,则调用webservice来获取电子邮件。


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 :-)

解决方案

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.

这篇关于在grails中使用外部web服务验证用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆