-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 애플 소셜로그인 서버 연동 #8
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
8 commits
Select commit
Hold shift + click to select a range
da732f0
[FEAT] 키체인 및 토근관리 유틸 기능 추가
dlrjswns 12d920f
[FEAT] 네트워킹 관리 유틸 이동 및 공통 응답 모델 추가
dlrjswns 45330d8
[FEAT] 로그인 기능 연동 로직 추가
dlrjswns d71c635
[CHORE] 로그인 코드 변경에 따른 수정
dlrjswns 48b426e
[FEAT] 토큰관련 정보 보호를 위한 Log privacy 변경
dlrjswns cb55d85
[CHORE] Token관련 로직 수행 후 에러처리 부분 수정
dlrjswns bb3e335
[FEAT] API에러 발생 시 로그 추가
dlrjswns fc42104
[CHORE] 코코아팟 버전 업데이트
dlrjswns 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
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,25 @@ | ||
| // | ||
| // KeyChainAccount.swift | ||
| // GAMSS | ||
| // | ||
| // Created by 이건준 on 7/29/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum KeyChainAccount { | ||
| case accessToken | ||
| case refreshToken | ||
|
|
||
| var description: String { | ||
| return String(describing: self) | ||
| } | ||
|
|
||
| var keyChainClass: CFString { | ||
| switch self { | ||
| case .accessToken, .refreshToken: | ||
| return kSecClassGenericPassword | ||
| } | ||
| } | ||
| } | ||
|
|
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,22 @@ | ||
| // | ||
| // KeyChainError.swift | ||
| // GAMSS | ||
| // | ||
| // Created by 이건준 on 7/29/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum KeyChainError: LocalizedError { | ||
| case unhandledError(status: OSStatus) | ||
| case itemNotFound | ||
|
|
||
| var errorDescription: String? { | ||
| switch self { | ||
| case .unhandledError(let status): | ||
| return "KeyChain unhandle Error: \(status)" | ||
| case .itemNotFound: | ||
| return "KeyChain item Not Found" | ||
| } | ||
| } | ||
| } |
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,67 @@ | ||
| // | ||
| // KeyChainManager.swift | ||
| // GAMSS | ||
| // | ||
| // Created by 이건준 on 7/29/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| final class KeyChainManager { | ||
| static let shared = KeyChainManager() | ||
| private let service = Environment.bundleID | ||
|
|
||
| private init() { } | ||
|
|
||
| func create(account: KeyChainAccount, data: String) throws { | ||
| let query = [kSecAttrService: service, | ||
| kSecClass: account.keyChainClass, | ||
| kSecAttrAccount: account.description, | ||
| kSecValueData: data.data(using: .utf8, allowLossyConversion: false)!] as CFDictionary | ||
|
|
||
| SecItemDelete(query) | ||
|
|
||
| let status = SecItemAdd(query, nil) | ||
|
|
||
| guard status == noErr else { | ||
| throw KeyChainError.unhandledError(status: status) | ||
| } | ||
| } | ||
|
|
||
| func read(account: KeyChainAccount) throws -> String { | ||
| let query = [kSecAttrService: service, | ||
| kSecClass: account.keyChainClass, | ||
| kSecAttrAccount: account.description, | ||
| kSecReturnData: true] as CFDictionary | ||
|
|
||
| var dataTypeRef: AnyObject? | ||
| let status = SecItemCopyMatching(query, &dataTypeRef) | ||
|
|
||
|
|
||
| guard status != errSecItemNotFound else { | ||
| throw KeyChainError.itemNotFound | ||
| } | ||
|
|
||
| if status == errSecSuccess, | ||
| let item = dataTypeRef as? Data, | ||
| let data = String(data: item, encoding: String.Encoding.utf8) { | ||
| return data | ||
| } else { | ||
| throw KeyChainError.unhandledError(status: status) | ||
| } | ||
| } | ||
|
|
||
| func delete(account: KeyChainAccount) throws { | ||
| let query = [kSecAttrService: service, | ||
| kSecClass: account.keyChainClass, | ||
| kSecAttrAccount: account.description] as CFDictionary | ||
|
|
||
| let status = SecItemDelete(query) | ||
|
|
||
| guard status == errSecSuccess || status == errSecItemNotFound else { | ||
| throw KeyChainError.unhandledError(status: status) | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
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,30 @@ | ||
| // | ||
| // LoginState.swift | ||
| // GAMSS | ||
| // | ||
| // Created by 이건준 on 7/29/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum LoginState { | ||
| /// 로그인 안되어 있음 | ||
| case notLoggedIn | ||
| /// 자동 로그인 설정이 되어있음, accessToken 갱신 필요 | ||
| case autoLoginPending | ||
| /// 로그인 되어있음 | ||
| case loggedIn | ||
|
|
||
| /// 현재 로그인 상태 반환 | ||
| static var current: Self { | ||
| guard TokenStorage.shared.readToken(.refreshToken) != nil else { | ||
| return .notLoggedIn | ||
| } | ||
|
|
||
| guard TokenStorage.shared.readToken(.accessToken) != nil else { | ||
| return .autoLoginPending | ||
| } | ||
|
|
||
| return .loggedIn | ||
| } | ||
| } |
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
File renamed without changes.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // | ||
| // APIResponse.swift | ||
| // GAMSS | ||
| // | ||
| // Created by 이건준 on 7/29/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct APIResponse<T: Decodable>: Decodable { | ||
| let success: Bool | ||
| let data: T | ||
| let error: ErrorResponse? | ||
| } | ||
|
dlrjswns marked this conversation as resolved.
|
||
|
|
||
| struct ErrorResponse: Decodable { | ||
| let code: String | ||
| let message: String | ||
| } | ||
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,12 @@ | ||
| // | ||
| // LoginRequestDTO.swift | ||
| // GAMSS | ||
| // | ||
| // Created by 이건준 on 7/29/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct LoginRequestDTO: Encodable { | ||
| let idToken: String | ||
| } |
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,13 @@ | ||
| // | ||
| // LoginResponseDTO.swift | ||
| // GAMSS | ||
| // | ||
| // Created by 이건준 on 7/29/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct LoginResponseDTO: Decodable { | ||
| let accessToken: String | ||
| let refreshToken: String | ||
| } |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 모야랑 비슷하네요
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cchanmi 지금 Endpoint에서 헤더값에 디폴트로 넣고있는데 추후에 토큰값을 넣어야하는 경우에 따른 HeaderType도 넣으면 깔끔할꺼같아요 👍 |
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,33 @@ | ||
| // | ||
| // AuthEndpoint.swift | ||
| // GAMSS | ||
| // | ||
| // Created by 이건준 on 7/29/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum AuthEndpoint: Endpoint { | ||
| case login(LoginRequestDTO) | ||
|
|
||
| var path: String { | ||
| switch self { | ||
| case .login: | ||
| return "/api/auth/login" | ||
| } | ||
| } | ||
|
|
||
| var method: HTTPMethod { | ||
| switch self { | ||
| case .login: | ||
| return .post | ||
| } | ||
| } | ||
|
|
||
| var body: Encodable? { | ||
| switch self { | ||
| case let .login(request): | ||
| return request | ||
| } | ||
| } | ||
| } |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
실패시 crash 발생이라 guard let을 사용하는 것도 좋을 것 같습니다