Annotation

@EnableWebSecurity//스프링 시큐리티 필터가 스프링 필터체인에 등록이 됩니다.

@EnableGlobalMethodSecurity(securedEnabled = true)//secured어노테이션 활성화

API

.antMatcher("user/**").authenticated() 유저/~~이리로 갈려면 인증이 필요하다.

.antMatcher("user/**").access("hasRole('ROLE_ADMIN' or hasRole('ROLE_MANAGER"))아래의 권한이 있어야 접근을 허용.
.anyRequest().permitAll();나머지는 그냥 들어갈 수 있다.


!!!!!!!!스프링 시큐리티를 적용하면 시큐리티만의 session을 가지게 되는데, 여기에 들어 갈 수 있는 객체는 정해져 있다.
Authentication 타입 객체

Authentication안에는 User정보가 있어야 된다.
근데 여기서 !!!!!!!!!!!!!User 객체의 타입도 정해져있다. 그건바로
UserDetails 타입 객체

Security Session 영역이 있다.
여기 들어갈 수 있는건 Authentication 객체 이 객체안에 유저정보를 저장할 때, userDetails여야한다.

꺼내쓸 때는 Security Session에서 Authentication꺼내고 여기서 UserDetails 꺼내옴

profile
에라 모르겠다~ i love it~

0개의 댓글