这是我的 spring-security.xml 文件。我不明白如何定义访问属性。默认有“ROLE_USER”和“ROLE_ANONYMOUS”,但我如何定义我的自定义访问属性?例如“admin”值是从数据库返回的,我怎样才能改变这个访问权限来设置管理员。
<intercept-url pattern="/**" access="admin" />
上面的代码给出错误。
<http auto-config="true">
<intercept-url pattern="/pages/login.xhtml*" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern="/**" access="" />
<form-login login-page='/pages/login.xhtml' default-target-url="/**"
authentication-failure-url="/pages/login.xhtml"/>
<logout logout-success-url="/pages/logout.xhtml" />
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select username,password
from app_user where username=?"
authorities-by-username-query="
select u.username, ur.role from app_user u, role ur
where u.role = ur.uuid and u.username =? "
/>
</authentication-provider>
</authentication-manager>