-
Notifications
You must be signed in to change notification settings - Fork 74
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
7주차 과제 - Spring Security 인가(Authorization) 구현하기 #74
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
3d1e47f
Spring Security 추가
jdalma 48a38f6
SpringSecurity Filter 추가로 인해 주석 처리
jdalma 1d029ac
advice에서 InvalidTokenException 예외 주석 처리
jdalma aeb3fb1
TODO 추가
jdalma 6d7e5b8
상품 삭제 시 토큰 없는 경우 테스트 코드 추가
jdalma 79e26d0
SpringSecurity 인증 및 인가 추가
jdalma 7d0ffd6
단일 import문으로 변경
jdalma 4f9695f
User Password 암호화 , bcrypt 사용
jdalma 2ae9974
Formatter 추가
jdalma f8f1731
authenticate() 테스트 코드 수정
jdalma b89ad93
User update() 테스트 코드 작성 중
jdalma 43ef954
주석 삭제
jdalma 0cb6ec0
try 수정
jdalma 4587c85
사용자 테스트 코드 수정
jdalma 9d7538d
DozerMapper 제거
jdalma 05fc813
테스트 코드 DisplayName 수정
jdalma 80d8717
DozerMapper 제거
jdalma f4614c9
ProductData toProduct() maker 필드 추가
jdalma bf1ef94
AuthenticationFilter filterWithPathAndMethod() 수정
jdalma 15e299c
ProductController 테스트 코드 content 부분 수정
jdalma d803878
JwtAuthenticationFilter JavaDoc 작성
jdalma e5e9e6c
JwtUtil.encode() 수정
jdalma ef37c86
UserController create() 테스트 코드 추가
jdalma 9e54f15
사용자별 권한 작업 중
jdalma 3fd2645
JwtAuthenticationFilter 주석 수정
jdalma 0d5abc2
user 자신의 정보만 수정 가능
jdalma edc9fcf
UserController 기존 테스트 통과하도록 수정
jdalma 6c44e40
jwt secret 수정
jdalma 63ea12a
DTO 기본 생성자 추가
jdalma e69315f
User 삭제는 관리자만 가능하게 수정
jdalma c585ae8
ddl-auto: update 수정
jdalma 9079fd1
과제 풀이 - 권한 적용
jdalma File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/codesoom/assignment/config/SecurityJavaConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.codesoom.assignment.config; | ||
|
||
import com.codesoom.assignment.application.AuthenticationService; | ||
import com.codesoom.assignment.filters.AuthenticationErrorFilter; | ||
import com.codesoom.assignment.filters.JwtAuthenticationFilter; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpStatus; | ||
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.configuration.WebSecurityConfigurerAdapter; | ||
import org.springframework.security.config.http.SessionCreationPolicy; | ||
import org.springframework.security.web.authentication.HttpStatusEntryPoint; | ||
|
||
import javax.servlet.Filter; | ||
|
||
@Configuration | ||
@EnableGlobalMethodSecurity(prePostEnabled = true) | ||
public class SecurityJavaConfig extends WebSecurityConfigurerAdapter { | ||
|
||
private final AuthenticationService authenticationService; | ||
|
||
public SecurityJavaConfig(AuthenticationService authenticationService) { | ||
this.authenticationService = authenticationService; | ||
} | ||
|
||
@Override | ||
public void configure(HttpSecurity http) throws Exception { | ||
Filter authenticationFilter = new JwtAuthenticationFilter(authenticationManager(), authenticationService); | ||
Filter authenticationErrorFilter = new AuthenticationErrorFilter(); | ||
http.csrf() | ||
.disable() | ||
.headers() | ||
.frameOptions() | ||
.disable() | ||
.and() | ||
.addFilter(authenticationFilter) | ||
.addFilterBefore(authenticationErrorFilter , JwtAuthenticationFilter.class) | ||
.exceptionHandling() | ||
.authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
만약 여러 나라의 언어로 서비스를 한다면 어떻게 대응하면 좋을지에 대해서 생각해 보세요.