-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into choer(#35)-redis-setting
- Loading branch information
Showing
29 changed files
with
1,355 additions
and
35 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,39 @@ | ||
name: Spring Boot & Gradle CI Jobs (With. dev branches pull_request) | ||
|
||
on: | ||
pull_request: | ||
branches: [ dev ] | ||
|
||
jobs: | ||
build: | ||
# 실행 환경 (Git Runners 개인 서버) | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
|
||
# application.yml 파일 설정 | ||
- name: resources 폴더 생성 | ||
run: | | ||
mkdir -p ./backend/src/main/resources | ||
- name: yml 파일 생성 | ||
run: | | ||
echo "${{ secrets.APPLICATION_DEFAULT }}" > ./backend/src/main/resources/application.yml | ||
echo "${{ secrets.APPLICATION_LOCAL }}" > ./backend/src/main/resources/application-local.yml | ||
echo "${{ secrets.APPLICATION_TEST }}" > ./backend/src/main/resources/application-test.yml | ||
# gradlew를 실행시키기 위해 권한 부여 | ||
- name: Gradlew에게 실행권한 부여 | ||
run: chmod +x ./backend/gradlew | ||
|
||
# 멀티모듈 빌드하기 | ||
- name: 멀티모듈 전체 빌드 | ||
run: | | ||
cd ./backend | ||
./gradlew clean build -x test |
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
78 changes: 68 additions & 10 deletions
78
backend/src/main/java/com/example/backend/auth/api/service/auth/AuthService.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
19 changes: 19 additions & 0 deletions
19
backend/src/main/java/com/example/backend/auth/api/service/jwt/JwtToken.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,19 @@ | ||
package com.example.backend.auth.api.service.jwt; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class JwtToken { | ||
private String accessToken; | ||
private String refreshToken; | ||
|
||
@Builder | ||
public JwtToken(String accessToken, String refreshToken) { | ||
this.accessToken = accessToken; | ||
this.refreshToken = refreshToken; | ||
} | ||
} |
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
59 changes: 59 additions & 0 deletions
59
...rc/main/java/com/example/backend/auth/api/service/oauth/adapter/google/GoogleAdapter.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,59 @@ | ||
package com.example.backend.auth.api.service.oauth.adapter.google; | ||
|
||
import com.example.backend.auth.api.service.oauth.adapter.OAuthAdapter; | ||
import com.example.backend.auth.api.service.oauth.response.OAuthResponse; | ||
import com.example.backend.common.exception.ExceptionMessage; | ||
import com.example.backend.common.exception.oauth.OAuthException; | ||
import com.example.backend.external.clients.oauth.google.GoogleProfileClients; | ||
import com.example.backend.external.clients.oauth.google.GoogleTokenClients; | ||
import com.example.backend.external.clients.oauth.google.response.GoogleProfileResponse; | ||
import com.example.backend.external.clients.oauth.google.response.GoogleTokenResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
import java.net.URI; | ||
import static com.example.backend.domain.define.user.constant.UserPlatformType.GOOGLE; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class GoogleAdapter implements OAuthAdapter { | ||
|
||
private final GoogleTokenClients googleTokenClients; | ||
private final GoogleProfileClients googleProfileClients; | ||
|
||
@Override | ||
public String getToken(String tokenURL) { | ||
try { | ||
GoogleTokenResponse token = googleTokenClients.getToken(URI.create(tokenURL)); | ||
// URL로 액세스 토큰을 요청 | ||
|
||
// 만약 token이 null일 경우 예외처리 | ||
if (token.getAccess_token() == null) { | ||
throw new OAuthException(ExceptionMessage.OAUTH_INVALID_TOKEN_URL); | ||
} | ||
return token.getAccess_token(); | ||
} catch (RuntimeException e) { | ||
log.error(">>>> [ Google Oauth 인증 에러 발생: {}", ExceptionMessage.OAUTH_INVALID_TOKEN_URL.getText()); | ||
throw new OAuthException(ExceptionMessage.OAUTH_INVALID_TOKEN_URL); | ||
} | ||
} | ||
|
||
@Override | ||
public OAuthResponse getProfile(String accessToken) { | ||
try { | ||
GoogleProfileResponse profile = googleProfileClients.getProfile("Bearer " + accessToken); | ||
|
||
// 액세스 토큰을 사용하여 프로필 정보 요청 | ||
return OAuthResponse.builder() | ||
.platformId(profile.getSub()) | ||
.platformType(GOOGLE) | ||
.name(profile.getName()) | ||
.profileImageUrl(profile.getPicture()) | ||
.build(); | ||
} catch (RuntimeException e) { | ||
log.error(">>>> [ Google Oauth 인증 에러 발생: {}", ExceptionMessage.OAUTH_INVALID_ACCESS_TOKEN.getText()); | ||
throw new OAuthException(ExceptionMessage.OAUTH_INVALID_ACCESS_TOKEN); | ||
} | ||
} | ||
} |
Oops, something went wrong.