-
Notifications
You must be signed in to change notification settings - Fork 18
Add Apple OAuth2 authentication support #3757
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
Conversation
- Add Apple variant to Identity enum (codec index 11) - Add Apple to Web2IdentityType enum - Add Apple to UserId enum with conversions - Add Apple variant to OAuth2Provider enum - Update identity helpers (to_native_account, to_omni_account, to_did)
- Add AppleOAuth2Config struct to config-loader - Implement env var loading (OE_APPLE_CLIENT_ID_*, OE_APPLE_CLIENT_SECRET_*) - Add AppleOAuth2Factory with caching support - Export AppleOAuth2Config in public API
- Implement AppleOAuth2Client for token exchange - Add Apple authorization URL helper with scope 'email' - Add ID token decoder for Apple tokens - Export apple module from oauth-providers and identity-verification
- Rename omni_getOAuth2GoogleAuthorizationUrl -> omni_getOAuth2AuthorizationUrl - Add provider parameter to support both Google and Apple - Update login_with_oauth2 to accept Apple provider - Add Apple factory to RpcContext - Update error messages to include both providers
- Implement verify_apple_oauth2 function - Add state verifier validation for Apple - Add code-to-token exchange for Apple - Extract email from Apple ID token - Update verify_oauth2_authentication to handle Apple provider
Makes OAuth2Provider more ergonomic to use by avoiding unnecessary clones
- Merge GoogleOAuth2Config and AppleOAuth2Config into unified OAuth2Config - Replace separate config maps with single oauth2_configs map - Create generic load_oauth2_configs function for all providers - Add unified get_oauth2_config(client_id, provider) method - Reduce config loading code by ~100 lines
- Add OAuth2ProviderConfig trait for provider-specific settings - Implement GoogleProviderConfig and AppleProviderConfig - Create unified OAuth2Client replacing duplicate implementations - Remove separate google.rs and apple.rs files (110 lines eliminated)
- Add oauth2_common module with shared AuthorizeData struct - Create generic get_authorize_data function - Refactor Google and Apple modules to use shared logic - Eliminate ~40 lines of duplicated authorization code
- Create OAuth2ConfigFactory supporting all providers - Remove GoogleOAuth2Factory and AppleOAuth2Factory (157 lines deleted) - Unified caching with (client_id, provider) key - Single get_config method for all providers
- Replace verify_google_oauth2 and verify_apple_oauth2 with verify_oauth2_provider - Eliminate 80+ lines of duplicated verification code - Share state validation, config fetching, and token exchange logic - Provider-specific handling only for token decoding
- Update get_oauth2_authorization_url to use single factory - Replace two factory fields in RpcContext with one oauth2_factory - Cleaner initialization with single factory instantiation - Streamline authorization URL generation logic
Claude encountered an error —— View job Code Review: Apple OAuth2 Authentication Support
I'll review this PR for code quality, security, performance, and potential issues. Todo List:
|
Claude finished @silva-fj's task —— View job Code Review: Apple OAuth2 Authentication Support ✅I've completed a comprehensive review of this PR that adds Apple OAuth2 authentication support. The implementation is well-architected and follows security best practices. Todo List:
✅ StrengthsArchitecture & Design
Security Implementation
Code Quality
|
- Add Apple case to prometheus metrics identity match - Add Apple variant to OAuth2Provider enum in authentication_utils - Add placeholder verification (returns not yet supported error)
- Fix 6 exhaustive match patterns in test functions - Apple is web2 (true), not web3/substrate/evm/bitcoin/solana (false)
tee-worker/omni-executor/heima/identity-verification/src/web2/apple/mod.rs
Show resolved
Hide resolved
tee-worker/omni-executor/rpc-server/src/methods/omni/login_with_oauth2.rs
Show resolved
Hide resolved
- Move decode_id_token logic to oauth2_common as generic function - Move base64_decode helper to oauth2_common - Update Apple and Google modules to use shared implementation - Eliminate 28 lines of duplicated JWT decoding code
- Add OAuth2VerificationData struct to store state and nonce - Add id_token field to OAuth2Data for client-side token verification - Remove Identity parameter from OmniAuth::OAuth2 variant - Update OAuth2StateVerifierStorage to store OAuth2VerificationData
Google IdToken: - email_verified: bool -> String (Google returns "true"/"false") - hd: String -> Option<String> (only for Workspace accounts) - at_hash: String -> Option<String> - nonce: String -> Option<String> Apple IdToken: - email_verified: Option<String> -> bool - nonce: String -> Option<String> - Add optional fields: is_private_email, c_hash, auth_time
- Add OAuth2ProviderConfig struct to centralize provider configuration - Export BASE_URL and SCOPES as public constants in provider modules - Remove wrapper functions (get_authorize_data, decode_id_token) - Add nonce parameter to authorization data
- Rename omni_getOAuth2AuthorizationUrl -> omni_getOAuth2AuthorizationData - Return structured data (url, state, nonce, scope, response_type, etc) - Use OAuth2ProviderConfig for cleaner provider-specific configuration - Store both state and nonce in OAuth2VerificationData
- Add id_token parameter to login flow - Verify id_token before token exchange (decode, aud, nonce) - Add verify_id_token_claims helper to reduce code duplication - Remove Identity parameter from OAuth2 verification - Use oauth2_common::decode_id_token for both providers
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.
@Kailai-Wang @kziemianek Please also take a look. Thank you.
Summary
Add Apple OAuth2 authentication support and refactor OAuth2 flow.
Changes
OAuth2 Flow Refactoring (Implicit Flow)
Security enhancements:
OAuth2VerificationData
API changes:
omni_getOAuth2AuthorizationUrl
→omni_getOAuth2AuthorizationData
id_token
parameter toOAuth2Data
OmniAuth::OAuth2
variantEnvironment Variables