【问题标题】:Spring security with google cloud endpoints使用谷歌云端点的 Spring 安全性
【发布时间】:2015-05-10 04:27:11
【问题描述】:

我们有一个使用谷歌应用引擎(我们也使用云端点)托管的项目(包含一个网络后端和一个移动 API 后端)。

我们为 web 应用程序、mvc 和安全性使用 spring 框架。

现在的问题是,一旦我在 security.xml 中启用 <csrf/>,云端点项目也将因为此设置需要令牌。

<http auto-config="true">
        <intercept-url pattern="/" access="ROLE_USER" />
        <form-login 
            login-page="/login" 
            default-target-url="/welcome" 
            authentication-failure-url="/login?error" 
            username-parameter="email"
            password-parameter="password" />
        <logout logout-success-url="/login?logout" />
        <!-- enable csrf protection -->
        <!-- <csrf/> -->
    </http>

是否可以仅配置某些文件夹或某些控制器需要此&lt;csrf/&gt; 保护?因为我只是想要这个csrf 设置来保护我的网络后端。

【问题讨论】:

    标签: google-app-engine spring-security google-cloud-endpoints


    【解决方案1】:

    为移动 api 提供单独的 URI 结构,例如“api/mob/getPostsByUserId”,并在 spring-security 配置文件中创建一个新的 http 标记

     <http auto-config="false" pattern="/mob/**">
       //.. your other settings
     </http>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-09
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      • 1970-01-01
      • 2015-10-27
      相关资源
      最近更新 更多