mirror of
https://github.com/cna-bootcamp/lifesub.git
synced 2026-06-13 13:09:10 +00:00
release
This commit is contained in:
@@ -24,9 +24,9 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@SuppressWarnings("unused")
|
||||
@Configuration //Config 레이어의 클래스임을 나타내며 Bean클래스로 등록되어 실행시 자동으로 객체가 생성됨
|
||||
@EnableWebSecurity //인증 처리 라이브러리인 Spring Security를 활성화함
|
||||
@SuppressWarnings("unused") //unused 경고를 표시하지 않게 하는 어노테이션
|
||||
public class SecurityConfig {
|
||||
private final JwtTokenProvider jwtTokenProvider;
|
||||
private final CustomUserDetailsService customUserDetailsService;
|
||||
@@ -44,6 +44,16 @@ public class SecurityConfig {
|
||||
return authConfig.getAuthenticationManager();
|
||||
}
|
||||
|
||||
/*
|
||||
아래와 같은 수행을 함
|
||||
- CORS설정: 접근을 허용할 도메인, 메서드, 헤더값 등을 설정함
|
||||
- csrf : Cross Site Request Forgery(인증된 웹 세션을 사용하여 서버를 공격하는 행위)을 비활성화
|
||||
JWT 방식을 사용하므로 불필요함. 만약 CSRF까지 활성화하면 클라이언트는 CSRF토큰도 요청 헤더에 보내야 함
|
||||
- authorizeHttpRequests: 인증이 필요없는 주소를 지정하고, 나머지는 인증이 안되어 있으면 접근을 금지시킴
|
||||
swagger페이지와 로그인, 회원등록 페이지는 인증 안해도 접근하도록 설정함
|
||||
- sessionManagement: 세션을 로컬에 저장하지 않도록 함
|
||||
- userDetailsService: 사용자 인증을 처리할 class
|
||||
*/
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
|
||||
@@ -13,12 +13,16 @@ import java.util.Set;
|
||||
@Entity
|
||||
@Table(name = "members")
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@NoArgsConstructor //JPA는 인자없는 기본 생성자를 대부분 요구하기 때문에 필요
|
||||
public class MemberEntity extends BaseTimeEntity {
|
||||
@Id
|
||||
@Id ////PK(primary key)필드로 지정
|
||||
@Column(name = "user_id", unique = true, nullable = false) //테이블 스키마 생성 시 필드명, 유일값
|
||||
private String userId;
|
||||
|
||||
|
||||
@Column(nullable = false)
|
||||
private String userName;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String password;
|
||||
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
|
||||
Reference in New Issue
Block a user