要求用户使用web.xml登录GWT

时间:2011-12-13 08:59:03

标签: google-app-engine gwt authentication login web.xml

我使用GAE和GWT开发了一个应用程序,用户在访问该站点时必须使用他的Google帐户登录。所以我在web.xml文件中定义了以下内容......

<security-constraint>
    <web-resource-collection>
        <url-pattern>/index.html</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>*</role-name>
    </auth-constraint>
</security-constraint>

当我运行本地开发服务器时,我第一次打开应用程序时会得到测试登录屏幕,但是当我部署它时,我直接进入我的应用程序而没有任何身份验证。 首先我想,可能是因为我已经登录到其他Google服务,但我也在其他浏览器和隐身模式下尝试过。

1 个答案:

答案 0 :(得分:1)

我建议尝试使用网址格式*以便您的所有资源都是安全的,其次将web-resource-name 标记添加到“所有”值,如下面的代码段所示。

我假设你已经有servlet映射到服务等

<security-constraint>
<web-resource-collection>
    <web-resource-name>all</web-resource-name>
    <url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
    <role-name>*</role-name>
</auth-constraint>
</security-constraint>