代码之家  ›  专栏  ›  技术社区  ›  jeff porter ichak khoury

春安:如何排除某些资源?

  •  38
  • jeff porter ichak khoury  · 技术社区  · 16 年前

    我有以下定义。。。

        <bean id="fsi" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
        <property name="authenticationManager" ref="authenticationManager"/>
        <property name="accessDecisionManager" ref="httpRequestAccessDecisionManager"/>
        <property name="objectDefinitionSource">
          <sec:filter-invocation-definition-source >
                <sec:intercept-url pattern="/secure/css/**"        access="ROLE_TIER0"/>
                <sec:intercept-url pattern="/secure/images/**"     access="ROLE_TIER0"/>
                <sec:intercept-url pattern="/**"                   access="ROLE_TIER0"/>
          </sec:filter-invocation-definition-source>
        </property>
        </bean>
    

    我想要这个网址上的资源。。。

    对所有电话开放,即周围没有保安。

    我试着添加。。。

    <sec:intercept-url pattern="/nonsecure/**" access="permitAll" />
    

    但这会导致Websphere抛出一个错误

    Unsupported configuration attributes: [permitAll] 
    

    有人能告诉我如何从安全性中排除这个URL吗?

    6 回复  |  直到 11 年前
        1
  •  84
  •   Lukas Eder    14 年前

    在springsecurity3.1.x中,filters=“none”的使用是不推荐的。而是使用多个 <http>

    <http pattern="/nonsecure/**" security="none"/>
    

    http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#ns-form-and-basic

        2
  •  24
  •   Lukas Eder    14 年前

    我想你得补充一点 use-expressions 标记到您的 http

    <http auto-config="true" use-expressions="true">
    ...
    ...
    </http>
    

    编辑:

        3
  •  19
  •   Faheem Sohail    12 年前
    <security:http auto-config='true'>
        <security:intercept-url pattern="/getfeed/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
        <security:intercept-url pattern="/**" access="ROLE_USER, ROLE_ADMIN" />
        <security:http-basic />
    </security:http>
    

    是匿名认证的吗 我在下面的链接上找到的 http://syntx.io/adding-http-basic-auth-to-restful-services-in-java-and-spring/

    拦截是自上而下评估的。如果您在/getIntelFeed/**之前写这个/**,那么所有服务都将通过/**并对所有服务应用安全性。在这种情况下/getIntelFeed/**将无效。

        4
  •  17
  •   Lukas Eder    14 年前

    尝试:

    <sec:intercept-url pattern="/nonsecure/**" filters="none" />
    
        6
  •  0
  •   Peter Mularien    15 年前

    您没有指定配置的其余部分,而且因为看起来您有显式bean配置,所以我们很难猜测您是如何配置的。我要说以上答案的一些组合是正确的。

    1. 如果您使用的是SPRSec3,那么如果您想启用SpEL表达式(并且配置了相应的bean来计算它们),Gopi的答案是正确的。如果不使用http名称空间,这可能会很困难。
    2. 如果为未经身份验证(匿名)的用户配置了适当的筛选器以设置SecurityContext,则设置role=“IS\u AUTHENTICATED\u ANONYMOUSLY、IS\u AUTHENTICATED\u FULLY、IS\u AUTHENTICATED\u membered”或其组合应该可以工作。
    3. 真正地 在呈现的页面的底层代码中,不需要任何与Spring安全性相关的东西,否则您可能会发现自己稍后会抓狂。

    推荐文章