-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/jwt practice #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
931e9f0
a138a59
17542f1
538385e
96aa68b
67c4f8d
41b9ef3
8930568
53d04ac
7e70482
ba45b23
008fb55
b95ba82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
* DTO 생성 * Entity 구조 변경 * Exception 핸들러 및 설정파일 변경 * 메모리DB H2 Console 이용
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## compose 파일 버전 | ||
#version: '3' | ||
#services: | ||
# # 서비스 명 | ||
# db: | ||
# # 사용할 이미지 | ||
# image: mysql | ||
# # 컨테이너 실행 시 재시작 | ||
# restart: always | ||
# # 컨테이너명 설정 | ||
# container_name: mysql-container-by-compose | ||
# # 접근 포트 설정(컨테이너 외부:컨테이너 내부) | ||
# ports: | ||
# | ||
# - 3307:3306 | ||
# # 환경 변수 설정 | ||
# environment: | ||
# MYSQL_ROOT_PASSWORD: root | ||
# # 명령어 설정 | ||
# command: | ||
# - --character-set-server=utf8mb4 | ||
# - --collation-server=utf8mb4_unicode_ci | ||
## volumes: | ||
## - |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.security2.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
import org.springframework.web.filter.CorsFilter; | ||
|
||
@Configuration | ||
public class CorsConfig { | ||
|
||
@Bean | ||
public CorsFilter corsFilter() { | ||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
|
||
CorsConfiguration config = new CorsConfiguration(); | ||
config.setAllowCredentials(true); | ||
config.addAllowedOriginPattern("*"); | ||
config.addAllowedHeader("*"); | ||
config.addAllowedMethod("*"); | ||
|
||
source.registerCorsConfiguration("/rest/api/**", config); | ||
return new CorsFilter(source); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.security2.config; | ||
|
||
import com.example.security2.jwt.JwtFilter; | ||
import com.example.security2.jwt.TokenProvider; | ||
import org.springframework.security.config.annotation.SecurityConfigurerAdapter; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.web.DefaultSecurityFilterChain; | ||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||
|
||
public class JwtSecurityConfig extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> { | ||
|
||
private final TokenProvider tokenProvider; | ||
|
||
public JwtSecurityConfig(TokenProvider tokenProvider) { | ||
this.tokenProvider = tokenProvider; | ||
} | ||
|
||
@Override | ||
public void configure(HttpSecurity http) throws Exception { | ||
// security 로직에 JwtFilter 등록 | ||
http.addFilterBefore( | ||
new JwtFilter(tokenProvider), | ||
UsernamePasswordAuthenticationFilter.class); | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
보통
rest
는 붙이지 않고api/v1
이렇게만 합니당There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정해서 올리겠습니다~!