스프링 웹 시큐리티 설정 추가
@Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .mvcMatchers("/", "/info").permitAll() .mvcMatchers("/admin").hasRole("ADMIN") .anyRequest().authenticated() .and() .formLogin() .and() .httpBasic(); } }
- authorizeRequest() -어떻게 요청들을 인가할지
- formLogin() - 폼 로그인 사용하겠다
- httpBasic() - Basic Authentication 사용
해결되지 않은 문제
- 아직 패스워드가 로그에 남음
- Admin처리가 안됨
'스터디-Spring' 카테고리의 다른 글
[스프링 시큐리티] 스프링 시큐리티 커스터마이징 - JPA 연동 (0) | 2022.01.07 |
---|---|
[스프링 시큐리티] 스프링 시큐리티 커스터마이징 - 인메모리 유저 추가 (0) | 2022.01.07 |
[스프링 시큐리티] 스프링 시큐리티 연동 (0) | 2022.01.07 |
[스프링 핵심 원리 - 기본편] 컴포넌트 스캔과 자동 의존관계 설정 (0) | 2022.01.03 |
[스프링 핵심 원리 - 기본편] 스프링이란? (0) | 2021.12.28 |