-
Notifications
You must be signed in to change notification settings - Fork 0
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 #10 from hokkung/hok/refactor-jwt
refactor jwt
- Loading branch information
Showing
14 changed files
with
171 additions
and
73 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
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
package com.leo.user.common.security; | ||
|
||
import org.springframework.security.core.Authentication; | ||
import com.leo.user.domain.user.User; | ||
import com.leo.user.model.auth.JwtToken; | ||
|
||
public interface JwtService { | ||
|
||
// String extractUsername(String token); | ||
// | ||
// boolean IsTokenValid(String token, UserDetails userDetails); | ||
|
||
String generateToken(Authentication authentication); | ||
JwtToken generateToken(String name); | ||
|
||
JwtToken generateToken(User user); | ||
} |
48 changes: 33 additions & 15 deletions
48
src/main/java/com/leo/user/common/security/JwtServiceImpl.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.leo.user.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "jwt") | ||
public record JwtProperties( | ||
long expirationTimeInMinute | ||
) { | ||
public JwtProperties() { | ||
this(1); | ||
} | ||
} |
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
11 changes: 0 additions & 11 deletions
11
src/main/java/com/leo/user/model/auth/AuthenticationResponseDto.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/java/com/leo/user/model/auth/AuthenticationResult.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,12 @@ | ||
package com.leo.user.model.auth; | ||
|
||
import com.leo.user.domain.user.User; | ||
|
||
import java.util.Date; | ||
|
||
public record AuthenticationResult( | ||
User user, | ||
String token, | ||
Date tokenExpirationTime | ||
){ | ||
} |
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,9 @@ | ||
package com.leo.user.model.auth; | ||
|
||
|
||
import java.util.Date; | ||
|
||
public record JwtToken ( | ||
String token, | ||
Date tokenExpirationTime | ||
){} |
15 changes: 8 additions & 7 deletions
15
src/main/java/com/leo/user/model/auth/LoginResponseDto.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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package com.leo.user.model.auth; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
import com.leo.user.model.user.UserDto; | ||
|
||
@Data | ||
@Builder | ||
public class LoginResponseDto { | ||
private String token; | ||
} | ||
import java.util.Date; | ||
|
||
public record LoginResponseDto( | ||
UserDto user, | ||
String token, | ||
Date tokenExpiredTime | ||
) {} |
6 changes: 3 additions & 3 deletions
6
src/main/java/com/leo/user/service/auth/AuthenticationService.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package com.leo.user.service.auth; | ||
|
||
import com.leo.user.domain.user.User; | ||
import com.leo.user.model.auth.AuthenticationResult; | ||
import com.leo.user.model.auth.RegisterRequest; | ||
|
||
public interface AuthenticationService { | ||
User register(RegisterRequest registerRequest); | ||
AuthenticationResult register(RegisterRequest registerRequest); | ||
|
||
String login(RegisterRequest request); | ||
AuthenticationResult login(RegisterRequest request); | ||
} |
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.