小编Mud*_*sir的帖子

preAuthorize注释似乎不起作用

我们正在尝试使用Spring的@preAuthorize标记来提高方法级别的安全性.一切都编译好并且运行良好,但限制不会发生.这是一种仅限管理员的方法,但即使是非管理员也可以访问.以下是我们在上下文中配置它的方式:

<http use-expressions="true" create-session="never"  entry-point-ref="oauthAuthenticationEntryPoint" xmlns="http://www.springframework.org/schema/security" authentication-manager-ref="authManager">
    <intercept-url pattern="/mocks/some-service" access="hasRole('ROLE_OTHER')" />
    <form-login authentication-failure-url="/login.jsp" default-target-url="/login.jsp" login-page="/login.jsp"></form-login>
    <custom-filter ref="resourceServerFilter" after="EXCEPTION_TRANSLATION_FILTER" />

  </http>

<security:global-method-security pre-post-annotations="enabled" />
Run Code Online (Sandbox Code Playgroud)

以下是方法本身:

@PreAuthorize("(hasRole('ROLE_ADMIN'))")
public Some doIt(Some Input) {
            do something;
    return some;
}
Run Code Online (Sandbox Code Playgroud)

但每个人都可以拥有一些东西.我错过了什么?任何帮助将不胜感激.

spring-security spring-aop

2
推荐指数
2
解决办法
3908
查看次数

标签 统计

spring-aop ×1

spring-security ×1