首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Google平台上保护SpringBoot REST端点

在Google平台上保护SpringBoot REST端点
EN

Stack Overflow用户
提问于 2018-01-04 18:56:34
回答 1查看 601关注 0票数 1

我创建了一个带有两个REST端点的SpringBoot应用程序,并将其部署到。一切都很好,我能够到达终点。现在,我想保护这些端点,并且只允许授权为admin的用户能够调用其中一个端点。我尝试使用以下配置向我的项目中添加一个web.xml文件:

代码语言:javascript
复制
<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。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-08 23:41:04

在联系Google支持之后,不可能使用Google应用程序引擎配置文件来保护Spring应用程序。它需要像任何其他Spring应用程序一样完成,但是如果您使用OAUTH (例如,您需要使用Google库进行令牌身份验证)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48101791

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档