使用SSO处理用户身份验证

时间:2019-08-23 12:56:09

标签: java authentication oauth-2.0 openid dropwizard

我很难通过Web应用程序与SSO集成。

我有一个示例dropwizard应用程序。 我尝试将google和facebook集成为open connect。

I thought of 2 approaches for integration
1. fetch the token from frontend js once the user is authenticated using open id, pass that token to the dropwizard server as cookie.
2. fetch the token from the dropwizard server itself and store the set token in cookie while responding to the frontend.

我不确定上述2种方法中哪一种最好,还是有任何建议的方法与dropwizard中的open connect集成?

1 个答案:

答案 0 :(得分:0)

我喜欢将SSO委派给特定于该工作的知名应用程序/库。 Keycloak是我熟悉的应用程序。但是我认为以下几点与应用程序无关。这个部分答案是解决方案的可能方向,但我认为这不是推荐的方法,如果有的话。有些人会讨厌这种方法。

前端负责身份验证。但是,由于它位于用户空间中,因此不能信任它未经修改。因此,应验证对后端的调用的有效性和授权(无论如何,这应该是后端任务)。

Keycloak具有用于知名的前端和后端实现的库,这些库允许轻松集成。我已经在Angular和Dropwizard中成功使用了它。 与各种身份提供者的集成可以合并。因此,对于预期身份验证需求发生变化的情况,这可能是一个非常安全的选择。不过,这需要一些时间来适应额外的层,因此您的里程可能会有所不同。

一些链接: