Google Apps Marketplace - Google App Engine Java 应用程序的 SSO
当单击 Google Apps 帐户中 Google 通用导航栏的“更多”部分中的 navLink 时,我不会直接登录到我的应用程序,而是显示我的应用程序的登录页面。
我的应用程序市场清单:
<ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009">
<Name>App Name</Name>
<Description>App Description</Description>
<!-- Administrators and users will be sent to this URL for application support -->
<Support>
<Link rel="support" href="http://myappid.appspot.com/help.html" />
</Support>
<!-- Show this link in Google's universal navigation for all users -->
<Extension id="navLink" type="link">
<Name>Myapp Navlink Name</Name>
<Url>http://myappid.appspot.com/ms.jsp?hd=${DOMAIN_NAME}</Url>
</Extension>
<!-- Declare our OpenID realm so our app is white listed -->
<Extension id="realm" type="openIdRealm">
<Url>http://myappid.appspot.com/</Url>
</Extension>
</ApplicationManifest>
我的 web.xml 相关部分:
<servlet>
<servlet-name>loginJsp</servlet-name>
<jsp-file>/login.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>loginJsp</servlet-name>
<url-pattern>/_ah/login_required</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>ms</web-resource-name>
<url-pattern>/ms.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
I don't directly get logged into my app when my navLink in "More" section of Google's universal navigation bar in a Google Apps account is clicked, instead the login page of my application is shown.
My apps marketplace manifest:
<ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009">
<Name>App Name</Name>
<Description>App Description</Description>
<!-- Administrators and users will be sent to this URL for application support -->
<Support>
<Link rel="support" href="http://myappid.appspot.com/help.html" />
</Support>
<!-- Show this link in Google's universal navigation for all users -->
<Extension id="navLink" type="link">
<Name>Myapp Navlink Name</Name>
<Url>http://myappid.appspot.com/ms.jsp?hd=${DOMAIN_NAME}</Url>
</Extension>
<!-- Declare our OpenID realm so our app is white listed -->
<Extension id="realm" type="openIdRealm">
<Url>http://myappid.appspot.com/</Url>
</Extension>
</ApplicationManifest>
My web.xml relevant part:
<servlet>
<servlet-name>loginJsp</servlet-name>
<jsp-file>/login.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>loginJsp</servlet-name>
<url-pattern>/_ah/login_required</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>ms</web-resource-name>
<url-pattern>/ms.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要创建一个 Servlet 来处理
http://myappid.appspot.com/ms.jsp?hd=${DOMAIN_NAME}
。它将获取域名并使用该域作为federatedIdentity
重定向到登录 URL。请参阅:http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/ api/users/UserService.html#createLoginURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.Set%29
使用正确的
federatedIdentity< /code> 设置后,用户将自动从 Google Apps 登录。
You need to create a servlet to handle
http://myappid.appspot.com/ms.jsp?hd=${DOMAIN_NAME}
. It will get the domain name and redirect to a login url using the domain asfederatedIdentity
. See :http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/users/UserService.html#createLoginURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.Set%29
With the proper
federatedIdentity
set, the user will login automatically from Google Apps.还。您应该将其添加到您的 application-manifest.xml 中:
Also. You should add this to your application-manifest.xml: