-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1103652
commit 7c1ef11
Showing
59 changed files
with
490 additions
and
82 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
bootJar.enabled = false | ||
jar.enabled = true | ||
|
||
dependencies { | ||
implementation project(":app:domain:user-domain") | ||
|
||
// spring-security | ||
implementation 'org.springframework.boot:spring-boot-starter-security' | ||
|
||
// jwt | ||
implementation 'io.jsonwebtoken:jjwt-api:0.12.5' | ||
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.5' | ||
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.5' | ||
} |
13 changes: 13 additions & 0 deletions
13
app/api/common-api/src/main/java/org/example/config/CommonApiConfig.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,13 @@ | ||
package org.example.config; | ||
|
||
import org.example.property.TokenProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(TokenProperty.class) | ||
@ComponentScan(basePackages = "org.example") | ||
public class CommonApiConfig { | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
app/api/common-api/src/main/java/org/example/repository/TokenRepository.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,14 @@ | ||
package org.example.repository; | ||
|
||
import java.util.Optional; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public interface TokenRepository { | ||
|
||
void save(String userId, String refreshToken); | ||
|
||
Optional<String> getExistRefreshToken(String userId); | ||
|
||
Boolean existAccessToken(String userId); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
app/api/common-api/src/main/java/org/example/security/token/RefreshTokenProcessor.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,30 @@ | ||
package org.example.security.token; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import java.util.Date; | ||
import lombok.RequiredArgsConstructor; | ||
import org.example.exception.BusinessException; | ||
import org.example.security.dto.TokenParam; | ||
import org.example.security.dto.UserParam; | ||
import org.example.security.vo.TokenError; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class RefreshTokenProcessor { | ||
|
||
private final JWTHandler jwtHandler; | ||
private final JWTGenerator jwtGenerator; | ||
|
||
public TokenParam reissueToken(HttpServletRequest request) { | ||
String refreshToken = jwtHandler.extractRefreshToken(request); | ||
UserParam userParam = jwtHandler.extractUserFrom(refreshToken); | ||
|
||
String oldRefreshToken = jwtGenerator.getExistRefreshToken(userParam); | ||
if (!refreshToken.equals(oldRefreshToken)) { | ||
throw new BusinessException(TokenError.INVALID_TOKEN); | ||
} | ||
|
||
return jwtGenerator.generate(userParam, new Date()); | ||
} | ||
} |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
package org.example.config; | ||
|
||
import org.example.property.TokenProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
|
||
@Configuration | ||
@Import(UserApiConfig.class) | ||
@EnableConfigurationProperties(TokenProperty.class) | ||
@ComponentScan(basePackages = "org.example") | ||
public class ApiConfig { | ||
|
||
} |
22 changes: 0 additions & 22 deletions
22
app/api/src/main/java/org/example/security/token/RefreshTokenProcessor.java
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
39 changes: 39 additions & 0 deletions
39
app/api/user-api/src/main/java/org/example/controller/dto/request/LoginApiRequest.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,39 @@ | ||
package org.example.controller.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import org.example.entity.credential.AppleSocialCredential; | ||
import org.example.entity.credential.GoogleSocialCredential; | ||
import org.example.entity.credential.KakaoSocialCredential; | ||
import org.example.entity.credential.SocialCredential; | ||
import org.example.entity.credential.SocialCredentials; | ||
import org.example.service.dto.request.LoginServiceRequest; | ||
import org.example.vo.SocialLoginType; | ||
|
||
public record LoginApiRequest( | ||
@NotNull(message = "소셜 로그인 타입은 필수 입력값입니다.") | ||
SocialLoginType socialLoginType, | ||
|
||
@NotNull(message = "소셜 로그인 식별값은 필수 입력값입니다.") | ||
String socialLoginIdentifier | ||
) { | ||
|
||
public LoginServiceRequest toLoginServiceRequest() { | ||
return LoginServiceRequest.builder() | ||
.socialCredentials(socialCredentials()) | ||
.build(); | ||
} | ||
|
||
private SocialCredentials socialCredentials() { | ||
SocialCredentials socialCredentials = new SocialCredentials(); | ||
socialCredentials.saveCredentials(socialLoginType, socialCredential()); | ||
return socialCredentials; | ||
} | ||
|
||
private SocialCredential socialCredential() { | ||
return switch (socialLoginType) { | ||
case GOOGLE -> new GoogleSocialCredential(socialLoginIdentifier); | ||
case KAKAO -> new KakaoSocialCredential(socialLoginIdentifier); | ||
case APPLE -> new AppleSocialCredential(socialLoginIdentifier); | ||
}; | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
app/api/user-api/src/main/java/org/example/dto/request/SignUpRequest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.