简体   繁体   English

将Google身份验证集成到现有应用程序中

[英]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个主要贡献者之一。

Ages ago I've created small ASP. 以前,我已经创建了小型ASP。 NET MVC and if I remember correctly you can find the solution described here and here . NET MVC,如果我没记错的话,可以在此处此处找到解决方案。

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: 您可以通过两种方式实现类似的方法:

  1. Keep the username/password/email fields on the User table, and attach a Google authentication provider in the Identity table only when necessary. 将用户名/密码/电子邮件字段保留在User表中,并仅在必要时在Identity表中附加Google身份验证提供程序。
  2. Include username and password fields on the 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.

相关问题 将 Umbraco 7 集成到现有的 MVC 4 Web 应用程序中 - Integrating Umbraco 7 into an existing MVC 4 Web application 将 ADFS SSO 集成到现有的 .net Web 应用程序中 - Integrating ADFS SSO into existing .net web application 在Silverlight应用程序中集成现有的wcf项目 - Integrating an existing wcf project in Silverlight application Google桌面应用程序中的身份验证 - Google authentication in Desktop application 使用 Google 进行 WPF 应用程序身份验证 - WPF application authentication with Google 集成Silverlight和现有的asp.net应用程序时会遇到复杂问题吗? - Complications in integrating Silverlight and existing asp.net application? 现有 .net Web 应用程序需要更改身份验证 - Existing .net web application needs to change authentication 控制台应用程序中的Google Oauth2.0身份验证 - Google Oauth2.0 authentication in a console application 需要在我的Web应用程序中集成G​​oogle身份验证 - Need to integrate Google Authentication in my web application 具有针对现有Web应用程序的多因素身份验证的Active Directory - Active Directory with multi factor authentication for an existing web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM