나는 스프링 MVC + 스프링 시큐리티를 사용하여 웹 응용 프로그램을 개발하고있어, 나는 다음과 같은 URL이 :Spring 보안을 사용하여 URL을 보호하는 방법은 무엇입니까?
/*this URL should be accessible by any User, i.e. users should be able to see other users' profiles*/
/users/someUserId/profile
/* all the following URLs should be accessed only by the current authenticated user */
/users/someUserId/profile/edit
/users/someUserId/picture/edit
/users/someUserId/notifications
/users/someUserId/friends
을 나는 이전에 기술로 확보 할 필요가있다. 이처럼 뭔가 달성 할 수 있는지
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**").permitAll()
.regexMatchers("https://stackoverflow.com/users/[\\w]+/profile").authenticated()
.antMatchers("https://stackoverflow.com/users/[\\w]/**").access("principal.name == regexGroupMatch")
.anyRequest().authenticated()
.and()
.jee().mappableRoles("Admin", "User");
}
내가 알고 싶은 : 이렇게
.antMatchers("/heroes/[\\w]/**").access("principal.name == regexGroupMatch")
을, 난 단지 사용자 기꺼이 다음과 같이
내 구성 방법은 간다 user1을 통해 URL에 액세스 할 수 있습니다.
/users/user1/profile/edit
/users/user1/picture/edit
/users/user1/notifications
그래서, 사용자 2는 앞서 언급 한 URL을 액세스 할 수 없습니다 있어야하지만 액세스 할 수 있어야합니다 : /사용자/사용자 1/프로필/편집 /사용자/사용자 1/사진/편집 /사용자/사용자 1/통지
뿐만 아니라 :
/users/user1/profile
/users/user2/profile
/users/user3/profile
etc...
이 그 사용하여 봄 보안을 달성 할 수 있습니까?
설명서를 읽었습니까? – chrylis
예 @chrylis, 설명서 [here] (http://docs.spring.io/spring-security/site/docs/3.2.3.RELEASE/reference/htmlsingle/)를 읽었습니다. '.antMatcher (url)'을 사용하여 그것을 달성 할 수 있다고 믿지만, 현재 사용자 만 자신의 프로파일을 볼 수있게하기 위해 어떤 방법을 사용해야하는지 모르겠습니다. – fvdalcin
Btw, [이 주제] (http://meta.stackoverflow.com/questions/251758/why-is-stack-overflow-so-negative-of-late)를 읽으셨습니까? – fvdalcin