Trong khi di chuyển một ứng dụng di sản để mùa xuân an ninh tôi đã ngoại lệ sau đây:Làm cách nào để sử dụng vai trò/quyền hạn tùy chỉnh trong Spring Security?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainProxy': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainList': Cannot resolve reference to bean '_filterSecurityInterceptor' while setting bean property 'filters' with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterSecurityInterceptor': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [superadmin]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
Trong ứng dụng cũ có vai trò như "trị cấp cao", "biên tập", "trợ giúp" vv Nhưng trong tất cả các ví dụ Xuân An Tôi chỉ thấy các vai trò như "ROLE_" ("ROLE_ADMIN", v.v ...). Khi tôi đổi tên "superadmin" thành "ROLE_ADMIN" và chỉ sử dụng vai trò này trong cấu hình, mọi thứ hoạt động.
Không làm việc:
<http auto-config="true">
<intercept-url pattern="/restricted/**" access="superadmin"/>
<form-login
authentication-failure-url="/secure/loginAdmin.do?error=true"
login-page="/secure/loginAdmin.do" />
</http>
trình:
<http auto-config="true">
<intercept-url pattern="/restricted/**" access="ROLE_ADMIN"/>
<form-login
authentication-failure-url="/secure/loginAdmin.do?error=true"
login-page="/secure/loginAdmin.do" />
</http>
phải là có thể sử dụng tên vai trò tùy chỉnh?
này [câu hỏi] (http://stackoverflow.com/questions/283870/acegi-security-how-do-i-add -another-grantedauthority-to-authentication-to-anonym) có thể hữu ích. – kgiannakakis