[英]Integrating Google Authentication in Existing Application
We have an application designed 3 years back in ASP.Net & SQL Server 2008. 我们有3年前在ASP.Net和SQL Server 2008中设计的应用程序。
We designed our own login DB design and forms authentication for the application with the help of ApplicationUser, Role, Then other transaction tables using UserId for getting the corresponding user records, history records. 我们设计了自己的登录数据库设计,并在ApplicationUser,Role,然后使用UserId的其他事务表的帮助下为应用程序进行身份验证,以获取相应的用户记录,历史记录。
So far no issues with new user registration and bringing and managing existing user records. 到目前为止,新用户注册以及带来和管理现有用户记录都没有问题。
Now our client wants to integrate, Google Account Login for the new customer and even the existing customer can sign in with the Google account.
We are wondering how it is possible. 我们想知道这怎么可能。 If you use Google Account to login, how we manage UserId mapping and other tables. 如果您使用Google帐户登录,我们将如何管理UserId映射和其他表格。
Is it possible to integrate the Google Account Login with the existing Application has designed with its own login implementation? 是否可以将Google帐户登录信息与已设计为具有自己的登录实现的现有应用程序集成在一起?
If yes, what are the things to be followed/considered for implementing this? 如果是,执行此操作要遵循/考虑什么?
I would use Windows Identity Foundation . 我将使用Windows Identity Foundation 。 It uses claims based authentication so all a user needs to access your site is a security token with a claim. 它使用基于声明的身份验证,因此用户访问您的站点所需的全部就是带有声明的安全令牌。 You could set up a separate Security Token Service that authenticates users based on your own database and users could also retrieve tokens by logging in through Google or with any other party you configure your app to trust. 您可以设置一个单独的安全令牌服务,该安全令牌服务根据您自己的数据库对用户进行身份验证,并且用户还可以通过通过Google或与您将应用程序配置为信任的任何其他方登录来检索令牌。
Another suggestion might be to use the nuget package SimpleAuthentication .** 另一个建议是使用nuget包SimpleAuthentication 。**
Out of the box, it has an MVC controller which means all you need to do is implement the code for checking if the user exists in your system, etc. (ie. when you come back to your website from Google). 开箱即用,它具有MVC控制器,这意味着您所需要做的就是实施代码,以检查用户是否存在于系统中,等等(例如,当您从Google返回网站时)。
If you're on webforms (appologies) then you need to do a bit more work by creating your own form call back and then handling the return from Google. 如果您使用的是网络表单(应用程序),则需要做更多的工作,方法是创建自己的表单回调,然后处理Google的回报。
** Disclosure: I'm one of the 2 main contributors for it. **披露:我是它的2个主要贡献者之一。
You may be able to find your answer in this Google+ document regarding adding Google+ authentication to existing Facebook implementations: 您可以在此Google+文档中找到有关在现有的Facebook实现中添加Google+身份验证的答案:
Adding Google+ to your Facebook Integration: Storing authorization 将Google+添加到您的Facebook集成中:存储授权
It talks about migrating from a single User
table to a User
and Identity
table. 它讨论了从单个User
表迁移到User
and Identity
表的问题。
You could implement something like this in two ways: 您可以通过两种方式实现类似的方法:
User
table, and attach a Google authentication provider in the Identity
table only when necessary. 将用户名/密码/电子邮件字段保留在User
表中,并仅在必要时在Identity
表中附加Google身份验证提供程序。 Identity
table which are checked if the provider
is "local"
. 在Identity
表中包括用户名和密码字段,如果provider
是"local"
则将对其进行检查。 You could use DotNetOpenAuth for that. 您可以为此使用DotNetOpenAuth 。
This is a "library that adds support for your site visitors to login with their OpenIDs by just dropping an ASP.NET control onto your page. It's that easy. An AJAX-style OpenID Selector control is also included for a slick, streamlined user experience." 这是一个“库,它通过将ASP.NET控件拖放到您的页面上来增加对网站访问者的支持,以使用OpenID登录。这很容易。还提供了AJAX样式的OpenID Selector控件,以提供流畅,流畅的用户体验“。
This post explains how to work with it for Google account. 这篇文章说明了如何针对Google帐户使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.