-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from nhnacademy-be5-T3Team/feature/jwt
Feature/jwt
- Loading branch information
Showing
92 changed files
with
1,775 additions
and
202 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
2 changes: 0 additions & 2 deletions
2
.idea/sonarlint/issuestore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
4 changes: 0 additions & 4 deletions
4
.idea/sonarlint/issuestore/9/9/99ff850f1b0eb7d304829d82185c5e52f6b6ee84
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file removed
0
.idea/sonarlint/securityhotspotstore/1/f/1f1763f358c257ea3515417352b82b0165647ad1
Empty file.
Empty file removed
0
.idea/sonarlint/securityhotspotstore/3/9/39cad08c773d7ff3afa8cab80e1be505f01dcd62
Empty file.
Empty file removed
0
.idea/sonarlint/securityhotspotstore/4/2/42a0fcc2a3cd24d3b748eb564abf71c4902524fc
Empty file.
Empty file removed
0
.idea/sonarlint/securityhotspotstore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec
Empty file.
Empty file removed
0
.idea/sonarlint/securityhotspotstore/5/d/5d837c4ed85ecaaf932c506e80ff5d7b9f3d590d
Empty file.
Empty file removed
0
.idea/sonarlint/securityhotspotstore/7/e/7e85a541f9d0eed2e9f7a135b9ddde3c8491c114
Empty file.
Empty file removed
0
.idea/sonarlint/securityhotspotstore/9/9/99ff850f1b0eb7d304829d82185c5e52f6b6ee84
Empty file.
Empty file removed
0
.idea/sonarlint/securityhotspotstore/c/7/c709f6995f23dae0da365bff70068f8288fa89e0
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
64 changes: 64 additions & 0 deletions
64
src/main/java/com/t3t/authenticationapi/account/auth/CustomUserDetails.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,64 @@ | ||
package com.t3t.authenticationapi.account.auth; | ||
|
||
import com.t3t.authenticationapi.account.dto.UserEntity; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class CustomUserDetails implements UserDetails { | ||
private final UserEntity userEntity; | ||
|
||
public CustomUserDetails(UserEntity userEntity) { | ||
this.userEntity = userEntity; | ||
} | ||
|
||
@Override | ||
public Collection<? extends GrantedAuthority> getAuthorities() { | ||
Collection<GrantedAuthority> collection = new ArrayList<>(); | ||
|
||
collection.add(new GrantedAuthority() { | ||
@Override | ||
public String getAuthority() { | ||
return userEntity.getRole(); | ||
} | ||
}); | ||
|
||
return collection; | ||
} | ||
|
||
@Override | ||
public String getPassword() { | ||
return userEntity.getPassword(); | ||
} | ||
|
||
@Override | ||
public String getUsername() { | ||
return userEntity.getUsername(); | ||
} | ||
|
||
public String getUserId(){ | ||
return userEntity.getUserId(); | ||
} | ||
|
||
@Override | ||
public boolean isAccountNonExpired() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isAccountNonLocked() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isCredentialsNonExpired() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return true; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/t3t/authenticationapi/account/common/GlobalExceptionHandler.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,34 @@ | ||
package com.t3t.authenticationapi.account.common; | ||
|
||
import com.t3t.authenticationapi.account.exception.CookieNotExistException; | ||
import com.t3t.authenticationapi.account.exception.TokenAlreadyExistsException; | ||
import com.t3t.authenticationapi.account.exception.TokenHasExpiredException; | ||
import com.t3t.authenticationapi.account.exception.TokenNotExistsException; | ||
import com.t3t.authenticationapi.model.response.BaseResponse; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
@ExceptionHandler(TokenNotExistsException.class) | ||
public ResponseEntity<BaseResponse<Void>> handleTokenNotExistsException(TokenNotExistsException tokenNotExistsException){ | ||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new BaseResponse<Void>().message(tokenNotExistsException.getMessage())); | ||
} | ||
|
||
@ExceptionHandler(TokenHasExpiredException.class) | ||
public ResponseEntity<BaseResponse<Void>> handleTokenHasExpiredException(TokenHasExpiredException tokenHasExpiredException){ | ||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new BaseResponse<Void>().message(tokenHasExpiredException.getMessage())); | ||
} | ||
|
||
@ExceptionHandler(TokenAlreadyExistsException.class) | ||
public ResponseEntity<BaseResponse<Void>> handleTokenAlreadyExistsException(TokenAlreadyExistsException tokenAlreadyExistsException){ | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new BaseResponse<Void>().message(tokenAlreadyExistsException.getMessage())); | ||
} | ||
|
||
@ExceptionHandler(CookieNotExistException.class) | ||
public ResponseEntity<BaseResponse<Void>> handleCookieNotExistsException(CookieNotExistException cookieNotExistException){ | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new BaseResponse<Void>().message(cookieNotExistException.getMessage())); | ||
} | ||
} |
Oops, something went wrong.