Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- 고등학생 대상
- Database
- Github
- git
- KAKAO
- cloud
- Spring Boot
- rnn
- 국가과제
- Web
- VSCode
- LINUX MASTER
- suricata
- Rocky Linux
- OSS
- ChatGPT
- 코딩도장
- ICT멘토링
- Docker
- GoogleDrive
- Spring
- Resnet
- 인터넷의이해
- Machine Learning
- API
- 크롤링 개발
- Python
- colab
- Powershell
- C언어
Archives
- Today
- Total
코딩두의 포트폴리오
Spring Security 의존성 제거 본문
Spring Security 설정을 통한 비활성화
디렉토리 경로
[ src/main/java/com/nurigo/service/config/SecurityConfig.java ]
package com.nurigo.service.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(authorize -> authorize
.anyRequest().permitAll() // 모든 요청을 허용
)
.formLogin().disable() // 기본 로그인 페이지 비활성화
.csrf(csrf -> csrf.disable()); // CSRF 비활성화 (필요 시 활성화)
return http.build();
}
}
- @Configuration: 이 클래스가 스프링 설정 클래스를 나타냄
- @EnableWebSecurity: Spring Security를 활성화
- SecurityFilterChain: 보안 필터 체인을 구성하는 Bean
- authorizeHttpRequests: 모든 HTTP 요청을 허용
- csrf.disable(): CSRF 보호를 비활성화 (개발 및 테스트 환경에서 주로 사용, 프로덕션에서는 주의 필요)
이 설정을 통해 요청에 대한 인증을 제거하고, CSRF 보호를 비활성화
로그인 화면을 잠시 중단하기 위함
이후 웹 실행 시 오류가 많이 발생하여 그냥 일단은 pom.xml 파일에서 해당 의존성만 제거해놓은 상태..
'2024 Tourism Data Utilization Contest > Spring Boot 2' 카테고리의 다른 글
이클립스 맞춤법 검사 비활성화 (1) | 2024.07.01 |
---|---|
static vs templates (2) | 2024.06.27 |
프로젝트 재생성 (1) | 2024.06.26 |