Google Apps Marketplace - 适用于Google App Engine Java应用程序的SSO

时间:2010-12-13 17:34:11

标签: google-app-engine openid single-sign-on google-apps-marketplace

点击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>

2 个答案:

答案 0 :(得分:0)

您需要创建一个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设置,用户将自动从Google Apps登录。

答案 1 :(得分:0)

另外。您应该将它添加到application-manifest.xml:

<Edition id="free">
    <Name>Myapp Navlink Name</Name>
    <Extension ref="navLink" />
    <Extension ref="realm" />
</Edition>