【问题标题】:Securing @Controller inconsistency确保@Controller 不一致
【发布时间】:2012-12-20 18:00:09
【问题描述】:

我正在使用 Spring MVC 开发 REST API 并使用 Spring Security 保护它。我有两个 URL,一个是 /company/{id},第二个是 /countriesws 是我的 servlet 映射。

<intercept-url pattern="/ws/*" access="ROLE_ADMIN"/>

已配置,但是当我尝试访问 /company/1 时,它通过了我

11:17:19,751 DEBUG http-bio-8080-exec-10 AntPathRequestMatcher:matches:103 - Checking match of request : '/ws/company/1'; against '/ws/*'
11:17:19,751 DEBUG http-bio-8080-exec-10 FilterSecurityInterceptor:beforeInvocation:184 - Public object - authentication not attempted

使用 /countries 一切正常。我已经阅读了this 问题,并在我的 mvc 相关上下文中使用了全局安全性。不知道是什么问题。

【问题讨论】:

    标签: java spring spring-mvc spring-security


    【解决方案1】:

    尝试使用 ant 样式选择器 ** 映射 /ws/ 下的所有内容,这表示包含指定 URL 中的所有内容,而不仅仅是指定 URL 中的 URL。

    <intercept-url pattern="/ws/**" access="ROLE_ADMIN"/>
    

    【讨论】:

    • @J-unior 很高兴我能帮上忙。这些 ant 风格的路径映射在 Spring 中被大量使用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-13
    • 2010-09-29
    • 2018-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多