-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 토큰 전체 코드 리팩토링 - 시큐리티 토큰으로 도메인명 변경 - 몇몇 잘못된 설정 변경 Related to: #95
- Loading branch information
1 parent
f44bd5c
commit 5016341
Showing
19 changed files
with
427 additions
and
291 deletions.
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/prgrms2/java/bitta/global/exception/AuthenticationException.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,15 @@ | ||
package com.prgrms2.java.bitta.global.exception; | ||
|
||
public enum AuthenticationException { | ||
CANNOT_ACCESS(403, "해당 API에 대한 액세스 권한이 없습니다."); | ||
|
||
private AuthenticationTaskException authenticationTaskException; | ||
|
||
AuthenticationException(int code, String message) { | ||
authenticationTaskException = new AuthenticationTaskException(code, message); | ||
} | ||
|
||
public AuthenticationTaskException get() { | ||
return authenticationTaskException; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/prgrms2/java/bitta/global/exception/AuthenticationTaskException.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,11 @@ | ||
package com.prgrms2.java.bitta.global.exception; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class AuthenticationTaskException extends RuntimeException { | ||
private int code; | ||
private String message; | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/prgrms2/java/bitta/global/util/AuthenticationProvider.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,31 @@ | ||
package com.prgrms2.java.bitta.global.util; | ||
|
||
import com.prgrms2.java.bitta.member.entity.Role; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.util.StringUtils; | ||
|
||
|
||
public class AuthenticationProvider { | ||
public static String getUsername() { | ||
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
|
||
if (authentication == null || authentication.getName() == null) { | ||
throw new RuntimeException("No authentication information."); | ||
} | ||
|
||
return authentication.getName(); | ||
} | ||
|
||
public static Role getRoles() { | ||
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
|
||
if (authentication == null || authentication.getAuthorities().isEmpty()) { | ||
throw new RuntimeException(""); | ||
} | ||
|
||
String role = authentication.getAuthorities().iterator().next().getAuthority(); | ||
|
||
return Role.valueOf(role); | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
src/main/java/com/prgrms2/java/bitta/member/controller/advice/TokenControllerAdvice.java
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
src/main/java/com/prgrms2/java/bitta/security/JwtAuthenticationFilter.java
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
src/main/java/com/prgrms2/java/bitta/security/JwtToken.java
This file was deleted.
Oops, something went wrong.
145 changes: 0 additions & 145 deletions
145
src/main/java/com/prgrms2/java/bitta/security/JwtTokenProvider.java
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
src/main/java/com/prgrms2/java/bitta/security/dto/RefreshTokenRequestDTO.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/main/java/com/prgrms2/java/bitta/security/exception/GlobalExceptionHandler.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
src/main/java/com/prgrms2/java/bitta/security/exception/InvalidTokenException.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.