重新验证从谷歌/ Facebook账户的用户 [英] Reauthenticate user from Google/Facebook accounts

查看:194
本文介绍了重新验证从谷歌/ Facebook账户的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我需要创建一个REST API向iOS应用程序提供的功能。我们允许用户与只是一个普通帐户或注册的的Facebook /谷歌登录

So I need to create a REST API to provide functionality to an IOS app. We allow users to sign up with just a plain account OR with Facebook/Google login.

我一直对OAuth的最近读了,我想我明白我怎么会在我的情况下使用OAuth的过程中(当使用用户的的Facebook /谷歌登录)到我的应用程序注册一个帐号:结果

I have been reading up on OAuth lately and I think I understand the process of how I would use OAuth in my situation (when users using Facebook/Google login) to register an account on my app:


  1. 注册我的各种社会机构(如FB /谷歌)iOS应用。我结束了我在安全后端存储客户端ID /客户端密钥。

  2. 现在,用户单击上的应用程序登录社交按钮,然后这将用户重定向到社会网站登录并授予权限为我的应用程序使用他们的社交帐户。

  3. 社会OAuth的供应商将用户重定向回到我的与授权code服务器。

  4. 一旦我的服务器授权code,我会再使用,客户端ID和秘密(或任何其他特定凭证需要)来检索社会的OAuth提供者的访问令牌。

  5. 现在,我有用户的访问令牌,可以利用自己的社会资源,在一段时间内(耶)。

  6. 有一次,我有自己的社交访问令牌,然后我也发出了应用发出请求到我的REST API时使用(应用程序将只从现在沟通,我的REST API)生成的访问令牌。

我的问题:


  • 是上面过程中好的做法呢?

  • 比方说,用户从应用程序注销(而不是从他们的社交帐户!)。我仍然有自己的社交访问令牌,但我消灭对方令牌的我发给他们使用我的REST API 。现在,用户回来登录到使用社交登录(如FB /谷歌)我的应用程序。我将如何重新验证这些用户?我知道我不需要用户再次提供权限,但我怎么能知道他们是FB /谷歌的合法用户,也有我的服务器端账号?什么会FB /谷歌在成功登录提供回应用程序,这样我可以发送回我的服务器说:是啊这个用户FB /谷歌的一个合法的社会用户。在上面的注册过程,一个社会的OAuth提供商将提供一个授权code。什么会我得到了在此情况下(后续登录)?

  • Is the above process a good practice?
  • Let's say the user logs out from the app (not from their social account!). I still have their social access token but I destroy the other token I issued to them for using my REST api. Now the user comes back to login into my app using a social login (eg. Fb/Google). How will I re-authenticate these users? I know I would not need the user to provide permissions again but how can I know they are legitimate users of Fb/Google and also have an account on my server side? What would Fb/Google provide back to the app upon a successful login so that I can send back to my server saying: "Yep this user is a legit social user of Fb/Google.". In the above registration procedure, a social oauth provider would provide an authorization code. What would I get in in this case (subsequent logins)?

基本上,我需要找到一种方法来重新发出一个访问令牌我的REST API在应用程序的FB /谷歌用户重新记录成功。

推荐答案

要回答你的问题,


  1. 是上述方法一个好的做法呢?

  1. Is the above process a good practice?

是的,这的确是一个很好的做法,你问为什么?你是不是存储在移动终端用户的客户端id /秘密,而你只是重定向到OAuth认证的社会供应商网站,服务器之间的通信发生在服务器,这也被认为是安全的。

Yes, this is indeed a good practice, why you ask?. You are not storing the client Id/Secret in the mobile end, and you are just redirecting to the social provider site of Oauth authentication, and communication happens between server to server, which is also considered secure.

对于第三方供应商的访问令牌,除非你想稍后访问社会提供的资源,你没有存储任何的访问令牌,即一旦通过验证,你可以放心地放弃自己的访问令牌和生成自己的

Regarding the Access Token of third party provider, unless you want to access any resources on social provider later, you don't have to store any of their access token, i.e once you authenticated, you can safely discard their access token and generate your own

对于第二个问题,

您不必担心,即一旦用户注销,你只需要撤销的accessToken由您发出的。

You don't have to worry about it, i.e once the user logout you just have to revoke accessToken issued by you.

对于基于OAuth的认证过程中,你只需要重定向到的OAuth流为社会提供者(而不必担心用户是否登录或不),社会提供商将照顾它,你会得到授权$最终C $ C,你就必须处理它,仿佛是第一次。

Regarding the Oauth process, you just have to redirect to the oauth Flow for social provider (and not worry about whether user is logged in or not), the social provider will take care of it, you will be getting the authorization code in the end, you just have to process it as if its first time.

希望这回答您的问题!

这篇关于重新验证从谷歌/ Facebook账户的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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