有没有一种方法可以使用Stormpath从Servlet请求中获得社交登录用户? [英] is there a way to get Socially signed in user from Servlet request using Stormpath?

查看:131
本文介绍了有没有一种方法可以使用Stormpath从Servlet请求中获得社交登录用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用stormpath Web登录名,一旦对用户进行身份验证,当前登录的用户帐户就可以在后续请求中使用,并且可以通过执行以下(例如,从Servlet内部)进行检索;

Using stormpath web login, once a User has been authenticated, the currently logged in user Account is available on subsequent requests and can be retrieved by doing the following (e.g from within a Servlet) ;

Account account = AccountResolver.INSTANCE.getAccount(request);

其中requestHttpServletRequest

现在,我需要知道的是,为什么不能对社交登录用户(即使用google,facebook,已登录用户登录的用户)执行相同的操作?

Now, what i need to know is, why is it not possible to do the same thing for a socially signed in user (i.e a user that signs in with google, facebook, linked-in)???

我知道 注册/登录 后,可以通过执行以下操作来检索该帐户;

I know that on sign-up/sign-in, the Account can be retrieved by doing the following;

String applicationHref = appHref;
String code = request.getParameter("code");

Application application = client.getResource(appHref, Application.class);
ProviderAccountRequest request = Providers.GOOGLE.account()
            .setCode(code)
            .build();

ProviderAccountResult result = application.getAccount(request);
Account account = result.getAccount();

但是之后,执行Account account = AccountResolver.INSTANCE.getAccount(request);总是返回null.

But afterwards, doing Account account = AccountResolver.INSTANCE.getAccount(request); always returns null.

现在这是一个问题,因为code仅在登录时可用,而对后续请求不可用,因此无法使用上面的代码段.此外,每次必须提取当前登录的帐户时,似乎工作量太大.

Now this is a problem because code is only available on sign in and not for subsequent requests hence using the snippet above is not possible. Besides, it seems like too much work for everytime the currently loggedin Account has to be fetched.

我无休止地浏览了Stormpath文档,没有发现线索...任何想法都会受到赞赏.

I've endlessly browsed the Stormpath documentation and found no leads... Any ideas would be highly appreciated.

谢谢.

推荐答案

Servlet插件尚不支持社交帐户.当您使用Form登录时,Servlet会意识到这一点,并将检索到的帐户放入cookie中以备后用.但是,对于社交登录,该servlet插件尚不知道社交帐户存储.我刚刚创建了此问题,您可以订阅它来得到有关此功能任何进展的通知.

The Servlet plugin has not support for social accounts yet. When you login with the Form then the Servlet is aware of that and puts the retrieved account in a cookie for later use. However, in the case of Social Logins, the servlet plugin is not yet aware of the Social Account Stores. I have just created this issues, you can subscribe to it in order to get notified about any progress of this feature.

需要提及的是, IDSite 确实支持社交帐户商店.在您的Spring/SpringBoot应用中,您只需要执行以下操作即可使用它:

It is relevant to mention that IDSite does actually support Social Account Stores. In your Spring/SpringBoot app you only need to do this in order to use it:

stormpath.web.idSite.enabled = true

启用它后,将使用IDSite的Login/Registration/Forgot/etc页面,而不是本地可用的页面.

When you enable it, you will be using Login/Registration/Forgot/etc pages from IDSite rather than the locally available ones.

这篇关于有没有一种方法可以使用Stormpath从Servlet请求中获得社交登录用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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