在同一服务器中使用我们自己的 Oauth 授权和社交登录授权 [英] Using our Own Oauth Authoriztion and Social Login Authorization in same server

查看:49
本文介绍了在同一服务器中使用我们自己的 Oauth 授权和社交登录授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望使用我们自己的用户表进行身份验证,使用 OAuth2 的 REST API.此外,我们需要允许社交登录.以下是社交登录流程,

We would like to have REST APIs with OAuth2 using our own user table for Authentication. Also, we need to allow Social Login. Below is the flow for social login,

我们的 OAuth

  1. 客户端为我们的服务器制作身份验证和访问令牌 URL访问令牌
  2. 客户端发送 access_token 以作为承载在标头中进一步调用令牌

社交登录

  1. 客户端向社交登录服务器生成身份验证和访问令牌 URL(对于例如,https://accounts.google.com/) 接收访问令牌
  2. 客户端发送 access_token 以在标头中进一步调用.

我们已经使用 Spring 实现了我们的 OAuth,并且运行良好.我们对社交登录有疑问,

We have implemented our OAuth with Spring and working perfectly. We have questions on social login,

  1. 如何识别我们自己的 Oauth 访问令牌和社交登录访问令牌.我们可能有很多社交登录,我们应该能够识别相应的社交登录.
  2. 如何验证并与 Spring Boot 集成?

推荐答案

如果访问令牌只是随机字符串,您可能无法告诉提供的令牌的颁发者,也无法对其进行验证.

If the access tokens are just random strings, you probably cannot tell the issuer of the provided token and you cannot validate it.

我建议您扩展您的 OAuth2 服务器以接受第三方提供商(Google、Facebook ...)进行身份验证.这种方式将支持本地和社交用户,但在您的应用程序中,您将始终处理自己的令牌.这将使应用程序安全性更容易(这通常意味着更安全),您还可以为访问令牌配置自己的范围.也有现成的解决方案 - 例如Keycloak.

I would suggest you to extend your OAuth2 server to accept third party providers (Google, Facebook ...) for authentication. This way would support both local and social users, but in your application, you would always deal with your own tokens. It would make the application security much easier (which usually means safer) and you could also configure your own scopes for access tokens. There are also ready to use solutions for it - e.g. Keycloak.

这篇关于在同一服务器中使用我们自己的 Oauth 授权和社交登录授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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