Spring Security 3.0 - 拦截URL - 所有页面都需要身份验证,但需要一个

gav*_*gav 5 spring-security

我希望任何用户都能够将自己的名字提交给志愿者表单,但只有管理员才能查看任何其他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>
Run Code Online (Sandbox Code Playgroud)

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

    <intercept-url pattern="/person/volunteer*" access=""/>
    <intercept-url pattern="/**" access="isAuthenticated()" />
Run Code Online (Sandbox Code Playgroud)

有人可以描述如何使用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" />
Run Code Online (Sandbox Code Playgroud)

要使其工作,请注意第一条规则的不同之处.

dub*_*ube 8

究竟什么不能按预期工作?出了什么问题?

我认为access =""不是你所期望的......使用文档中的格式:

<intercept-url pattern="/login.jsp*" filters="none"/>
Run Code Online (Sandbox Code Playgroud)

如果您不使用默认身份验证(您执行此操作),则需要添加WebExpressionVoter,因为您使用表达式表达式doc