GWT和AppEngine用户服务 [英] GWT and AppEngine User Service

查看:93
本文介绍了GWT和AppEngine用户服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GAE用户服务来验证我的GWT应用程序。
根据用户是否登录,用户会看到LoginPage / Dashboard。


$ b

GWT应用程序调用Auth Servlet(Window.Location.assign( / googleauth);导致应用程序卸载,然后将控制权转移到Google身份验证页,在身份验证后我们被重定向到CallBack servlet。



我可以检查用户是否登录成功地在回调Servlet中,但是如果我简单地重定向到我的应用程序,会话登录会丢失。



应用程序从头开始加载。



如果我设置了一个cookie - >


HttpSession session =
request.getSession();
String sessionid = session.getId(); //从$ b $获得sessionID $ b服务器对您登录的响应
请求
Cookie cookie = new Cookie(sid,sessionid);
response.addCookie(cookie);
response.sendRedirect(AppURL.getApplic ationBaseURL());

在我的客户端代码中检查 - >


String sessionID =
Cookies.getCookie(sid);
if(sessionID!= null){//显示
dashboard}

安全?

解决方案

您说:

 我只是重定向到我的应用程序会话登录丢失。 

这不应该发生。一旦你登录会话应该在那里,直到你注销或会话超时(你可以在GAE设置中设置它)。



你可以简单地将一个GWT-RPC调用到服务器并检查用户是否已登录: UserServiceFactory.getUserService()。isUserLoggedIn()


$ b 注意:如果你正在寻找会话cookie,AppEngine在生产和开发服务器中使用不同的cookie名称。它在生产中使用 ACSID cookie, dev_appserver_login


I am using GAE User Service to Authrnicate my GWT Application. Depending on whether the User is logged in the User is presented with LoginPage/Dashboard.

The GWT Application calls a Auth Servlet (Window.Location.assign("/googleauth"); causing application to unload which then transfers control to Google Authentication Page, after authentication we are redirected to CallBack servlet.

I can check whether user is loggedin successfully in Callback Servlet. However if I simply redirect back to my application the session login is lost.

The Application loads from scratch.

If I set up a cookie-->

HttpSession session = request.getSession(); String sessionid = session.getId(); //Get sessionID from server's response to your login request Cookie cookie=new Cookie("sid",sessionid); response.addCookie(cookie); response.sendRedirect(AppURL.getApplicationBaseURL());

In my client code check -->

String sessionID = Cookies.getCookie("sid"); if(sessionID!=null) { //show dashboard }

Is the way I am using secure? How long are the cookies valid for?

解决方案

You said:

I simply redirect back to my application the session login is lost.

This should not happen. Once you login the session should be there until you logout or session timeouts (you can set this in GAE settings).

You can simply make a GWT-RPC call to server and check if user is logged in: UserServiceFactory.getUserService().isUserLoggedIn().

Note: if you are looking for session cookies, AppEngine uses different cookie names in production and development servers. It uses ACSID cookie in production and dev_appserver_login.

这篇关于GWT和AppEngine用户服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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