我创建了一个带有两个REST端点的SpringBoot应用程序,并将其部署到。一切都很好,我能够到达终点。现在,我想保护这些端点,并且只允许授权为admin的用户能够调用其中一个端点。我尝试使用以下配置向我的项目中添加一个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标准中还有其他方法来保护SpringBoot端点吗?
忘记提到,当我在本地运行应用程序时,安全配置可以工作,但一旦部署到GAE,就开始获得404。
发布于 2018-04-08 23:41:04
在联系Google支持之后,不可能使用Google应用程序引擎配置文件来保护Spring应用程序。它需要像任何其他Spring应用程序一样完成,但是如果您使用OAUTH (例如,您需要使用Google库进行令牌身份验证)。
https://stackoverflow.com/questions/48101791
复制相似问题