【问题标题】:Spring Security 3.0 - Intercept-URL - All pages require authentication but oneSpring Security 3.0 - Intercept-URL - 所有页面都需要身份验证,但只有一个
【发布时间】:2010-05-03 17:44:53
【问题描述】:

我希望任何用户都能够将他们的姓名提交给志愿者表单,但只有管理员才能查看任何其他 URL。不幸的是,我似乎无法做到这一点。我的resources.xml如下;

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
    <http realm = "BumBumTrain Personnel list requires you to login" auto-config="true" use-expressions="true">
        <http-basic/>
        <intercept-url pattern="/person/volunteer*" access=""/>
        <intercept-url pattern="/**" access="isAuthenticated()" />
    </http>

    <authentication-manager alias="authenticationManager">
        <authentication-provider>
            <user-service>
                <user name="admin" password="admin" authorities="ROLE_ADMIN"/>
            </user-service>
        </authentication-provider>
    </authentication-manager>
</beans:beans>

具体来说,我正在尝试实现我描述的访问设置;

    <intercept-url pattern="/person/volunteer*" access=""/>
    <intercept-url pattern="/**" access="isAuthenticated()" />

有人可以描述如何使用intercept-url 来实现我描述的结果吗?

谢谢

Gav


无论出于何种原因,我需要一个 grails 应用程序;

        <intercept-url pattern="/person/volunteer/**" access="" filters="none"/>
    <intercept-url pattern="/images/**" access="" filters="none"/>
    <intercept-url pattern="/css/**" access="" filters="none"/>
    <intercept-url pattern="/js/**" access="" filters="none"/>
    <intercept-url pattern="/**" access="ROLE_ADMIN" />

要让它发挥作用,请注意第一条规则的不同之处。

【问题讨论】:

    标签: spring-security


    【解决方案1】:

    究竟有什么不符合您的预期?出了什么问题?

    我认为 access="" 不符合您的期望...使用文档中的格式:

    <intercept-url pattern="/login.jsp*" filters="none"/>
    

    如果您不使用默认身份验证(您这样做),则需要添加 WebExpressionVoter,因为您使用表达式 expressions doc

    【讨论】:

    • 从 spring 3.1 开始,应该使用&lt;http pattern="/login.jsp*" security="none"/&gt;
    【解决方案2】:

    您好,将 access="" 替换为 access="permitAll" 以获取您希望无需身份验证即可访问的网址。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-17
      • 2012-05-08
      相关资源
      最近更新 更多