ASP.net/MVC 中第三方的自定义身份验证
我正在尝试封装一个自定义身份验证系统,供我在 MVC 中处理的项目内部使用。
我们目前有一个合作伙伴托管具有表单身份验证的外部站点。本网站的某些部分重定向至我们内部网站的部分。与此重定向一起传递的是 id 和会话 id。他们提供了一项 Web 服务,我们可以验证该用户是否在原始站点上经过了身份验证。
有没有办法将其包装到 ASP.net 中的某种自定义提供程序或身份验证属性中?我更愿意创建一些可重用的东西来与在同一环境中工作的其他人共享。
谢谢!
编辑 我不想改变身份验证的方法。我只是在寻找最好的方法来包装它,以便它可以在内部重复使用。我最初考虑的是自定义会员资格提供商,但这并不是真正的用户名/密码类型的情况。
I'm trying to wrap up a custom authentication system for internal use for a project I'm working on in MVC.
We currently have a partner that hosts an external site with forms authentication. Certain sections of this site redirect to a section on our internal site. Passed along with this redirection is an id and a session id. They provide a web service that we can then verify that this user is authenticated on the original site.
Is there a way to wrap this up into some sort of custom provider or authentication attribute in ASP.net? I would prefer to create something reusable to share with others working in my same environment.
Thanks!
EDIT
The method of authentication is not something I'm looking to change. I'm just looking for the best way to wrap this up so it's reusable internally. I was initially thinking a custom membership provider, but it's not really a username/password type situation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
即使没有用户名和密码,您也可以创建自定义会员资格提供商。您只需要实现 MembershipProvider 即可。我实际上只会将代码放入 ValidateUser(string username, string password) 中。使用 uaername 字符串传递用户 ID,使用密码字符串传递会话 ID...进行验证,然后传回 true 或 false。您可以根据需要添加更多功能。
You can do a custom membership provider, even without a username and password. You just need to implement MembershipProvider. I would only actually put code in ValidateUser(string username, string password). Pass the user ID with the uaername string, and the session id with the password string... do the validation, and pass back true or false. You can add more features as you need to.
您可以查看专门为此设计的单点登录 (SSO) 解决方案,尤其是使用 SAML 绑定的解决方案,例如 Shibboleth。
You could look at Single-Sign On (SSO) solutions that are designed for this, more particularly with SAML bindings, for example Shibboleth.