-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] OAuth callback 처리 상태 관리 #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,18 @@ | ||
| ALTER TABLE oauth_authorization_request | ||
| ADD COLUMN status VARCHAR(20) NULL AFTER used_at, | ||
| ADD COLUMN failure_stage VARCHAR(30) NULL AFTER status, | ||
| ADD COLUMN failure_type VARCHAR(30) NULL AFTER failure_stage, | ||
| ADD COLUMN processing_started_at DATETIME(6) NULL AFTER failure_type, | ||
| ADD COLUMN completed_at DATETIME(6) NULL AFTER processing_started_at; | ||
|
|
||
| UPDATE oauth_authorization_request | ||
| SET status = CASE WHEN used_at IS NULL THEN 'ISSUED' ELSE 'LEGACY' END, | ||
| processing_started_at = used_at, | ||
| completed_at = used_at | ||
| WHERE status IS NULL; | ||
|
|
||
| ALTER TABLE oauth_authorization_request | ||
| MODIFY COLUMN status VARCHAR(20) NOT NULL; | ||
|
|
||
| CREATE INDEX idx_oauth_authorization_request_status_processing | ||
| ON oauth_authorization_request (status, processing_started_at); | ||
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
...n/java/com/example/todayEng/domain/user/entity/enums/OAuthAuthorizationRequestStatus.java
This file contains hidden or 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.example.todayEng.domain.user.entity.enums; | ||
|
|
||
| public enum OAuthAuthorizationRequestStatus { | ||
| LEGACY, | ||
| ISSUED, | ||
| PROCESSING, | ||
| SUCCEEDED, | ||
| FAILED | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/example/todayEng/domain/user/entity/enums/OAuthCallbackFailureStage.java
This file contains hidden or 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.example.todayEng.domain.user.entity.enums; | ||
|
|
||
| public enum OAuthCallbackFailureStage { | ||
| CALLBACK_VALIDATION, | ||
| TOKEN_EXCHANGE, | ||
| USER_INFO, | ||
| ACCOUNT_SAVE, | ||
| STALE_PROCESSING | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/example/todayEng/domain/user/entity/enums/OAuthCallbackFailureType.java
This file contains hidden or 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,10 @@ | ||
| package com.example.todayEng.domain.user.entity.enums; | ||
|
|
||
| public enum OAuthCallbackFailureType { | ||
| AUTHORIZATION_DENIED, | ||
| AUTHORIZATION_CODE_MISSING, | ||
| EXTERNAL_API, | ||
| DATABASE, | ||
| CONFLICT, | ||
| INTERNAL | ||
| } |
This file contains hidden or 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 hidden or 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
40 changes: 40 additions & 0 deletions
40
.../com/example/todayEng/domain/user/service/OAuthAuthorizationRequestRecoveryScheduler.java
This file contains hidden or 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,40 @@ | ||
| package com.example.todayEng.domain.user.service; | ||
|
|
||
| import com.example.todayEng.domain.user.entity.enums.OAuthAuthorizationRequestStatus; | ||
| import com.example.todayEng.domain.user.entity.enums.OAuthCallbackFailureStage; | ||
| import com.example.todayEng.domain.user.entity.enums.OAuthCallbackFailureType; | ||
| import com.example.todayEng.domain.user.repository.OAuthAuthorizationRequestRepository; | ||
| import java.time.Duration; | ||
| import java.time.LocalDateTime; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.scheduling.annotation.Scheduled; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class OAuthAuthorizationRequestRecoveryScheduler { | ||
|
|
||
| private static final Duration PROCESSING_TIMEOUT = Duration.ofMinutes(15); | ||
|
|
||
| private final OAuthAuthorizationRequestRepository repository; | ||
|
|
||
| @Scheduled(fixedDelayString = "${oauth.callback.recovery-interval-millis:60000}") | ||
| @Transactional | ||
| public void failStaleProcessingRequests() { | ||
| LocalDateTime now = LocalDateTime.now(); | ||
| int updated = repository.failStaleProcessing( | ||
| OAuthAuthorizationRequestStatus.PROCESSING, | ||
| OAuthAuthorizationRequestStatus.FAILED, | ||
| OAuthCallbackFailureStage.STALE_PROCESSING, | ||
| OAuthCallbackFailureType.INTERNAL, | ||
| now.minus(PROCESSING_TIMEOUT), | ||
| now | ||
| ); | ||
| if (updated > 0) { | ||
| log.warn("Stale OAuth callback requests marked failed: count={}", updated); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.