on
스프링 시큐리티 - 웹 리소스에 대한 권한 허용하기
스프링 시큐리티 - 웹 리소스에 대한 권한 허용하기
728x90
웹 리소스에 대한 권한 허용
js, css, image 등의 파일의 접근 권한을 허용시키자.
SecurityConfig.java
package com.sp.fc.web.config; import lombok.RequiredArgsConstructor; import org.springframework.boot.autoconfigure.security.servlet.PathRequest; import org.springframework.context.annotation.Bean; import org.springframework.security.access.hierarchicalroles.RoleHierarchy; import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.userdetails.User; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; @EnableWebSecurity(debug = true) @RequiredArgsConstructor public class SecurityConfig extends WebSecurityConfigurerAdapter { ... /** * 웹 리소스에 대한 권한 허용 * @param web * @throws Exception */ @Override public void configure(WebSecurity web) throws Exception { web.ignoring() .requestMatchers( // js, css, image 등의 파일 PathRequest.toStaticResources().atCommonLocations() ) ; } }
from http://devfunny.tistory.com/619 by ccl(A) rewrite - 2021-11-21 04:02:17