【发布时间】:2018-06-14 13:39:02
【问题描述】:
我创建了一个带有几个 REST 端点的 SpringBoot 应用程序,并将其部署到 Google App Engine Standard。一切正常,我能够达到终点。 现在我想保护这些端点,并只允许授权为管理员的用户能够调用其中一个端点。我尝试使用以下配置将 web.xml 文件添加到我的项目中:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<security-constraint>
<web-resource-collection>
<web-resource-name>api</web-resource-name>
<url-pattern>/api/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>status</web-resource-name>
<url-pattern>/api/status</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>ping</web-resource-name>
<url-pattern>/api/ping</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
我可以将它部署到 GAE,但我不能再调用端点。我现在得到的只是一堆未找到的 404,在与以前相同的 URL 上。有没有其他方法可以保护 Google App Engine Standard 中的 SpringBoot 端点?
忘了提到当我在本地运行应用程序时安全配置有效,但一部署到 GAE 就开始出现 404。
【问题讨论】:
标签: rest google-app-engine spring-boot spring-security