-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/apple user withdraw] #52
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
6 commits
Select commit
Hold shift + click to select a range
0a063e2
:sparkles: feat : add apple_refresh token logic for withdraw
ekgns33 7437b67
:sparkles: feat : add revoke appple_user logic
ekgns33 856f946
:hammer: chore : update application.yml; add AES secret key
ekgns33 d2f5c9e
:sparkles: feat : add encrypt/decrypt for refresh token
ekgns33 577f42a
:recycle: refactor : rename variable
ekgns33 8d2d465
:bug: fix : change passing value
ekgns33 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
44 changes: 44 additions & 0 deletions
44
src/main/java/org/runimo/runimo/auth/service/EncryptUtil.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,44 @@ | ||
| package org.runimo.runimo.auth.service; | ||
|
|
||
| import java.util.Base64; | ||
| import javax.crypto.Cipher; | ||
| import javax.crypto.spec.IvParameterSpec; | ||
| import javax.crypto.spec.SecretKeySpec; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class EncryptUtil { | ||
|
|
||
| @Value("${runimo.security.secret-key}") | ||
| private String secretKey; | ||
| @Value("${runimo.security.iv}") | ||
| private String iv; | ||
| private static final String CIPHER_TRANS = "AES/CBC/PKCS5Padding"; | ||
| private static final String ALGORITHM = "AES"; | ||
|
|
||
| public String encrypt(String plainText) throws Exception { | ||
| Cipher cipher = Cipher.getInstance(CIPHER_TRANS); | ||
| SecretKeySpec keySpec = new SecretKeySpec(secretKey.getBytes(), ALGORITHM); | ||
| IvParameterSpec ivSpec = new IvParameterSpec(iv.getBytes()); | ||
|
|
||
| cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec); | ||
| byte[] encrypted = cipher.doFinal(plainText.getBytes()); | ||
|
|
||
| return Base64.getEncoder().encodeToString(encrypted); | ||
| } | ||
|
ekgns33 marked this conversation as resolved.
|
||
|
|
||
| public String decrypt(String cipherText) throws Exception { | ||
| Cipher cipher = Cipher.getInstance(CIPHER_TRANS); | ||
| SecretKeySpec keySpec = new SecretKeySpec(secretKey.getBytes(), ALGORITHM); | ||
| IvParameterSpec ivSpec = new IvParameterSpec(iv.getBytes()); | ||
|
|
||
| cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); | ||
| byte[] decodedBytes = Base64.getDecoder().decode(cipherText); | ||
| byte[] decrypted = cipher.doFinal(decodedBytes); | ||
|
|
||
| return new String(decrypted); | ||
| } | ||
|
ekgns33 marked this conversation as resolved.
|
||
| } | ||
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
26 changes: 26 additions & 0 deletions
26
src/main/java/org/runimo/runimo/user/domain/AppleUserToken.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,26 @@ | ||
| package org.runimo.runimo.user.domain; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.runimo.runimo.common.BaseEntity; | ||
|
|
||
| @Table(name = "apple_user_token") | ||
| @Getter | ||
| @Entity | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class AppleUserToken extends BaseEntity { | ||
|
|
||
| @Column(name = "user_id") | ||
| private Long userId; | ||
| @Column(name = "refresh_token") | ||
| private String refreshToken; | ||
|
|
||
| public AppleUserToken(Long userId, String refreshToken) { | ||
| this.userId = userId; | ||
| this.refreshToken = refreshToken; | ||
| } | ||
| } | ||
|
ekgns33 marked this conversation as resolved.
|
||
10 changes: 10 additions & 0 deletions
10
src/main/java/org/runimo/runimo/user/repository/AppleUserTokenRepository.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 org.runimo.runimo.user.repository; | ||
|
|
||
| import java.util.Optional; | ||
| import org.runimo.runimo.user.domain.AppleUserToken; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface AppleUserTokenRepository extends JpaRepository<AppleUserToken, Long> { | ||
|
|
||
| Optional<AppleUserToken> findByUserId(Long id); | ||
| } |
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
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
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
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.