feat(auth): implement Unsplash OAuth2 flow#34
Merged
Conversation
This commit introduces a static web page to handle OAuth redirection for both desktop and web platforms, along with a GitHub Actions workflow for automated deployment to GitHub Pages.
Key changes:
- **OAuth Callback Page**: Added a Material 3-styled static site under `site/auth/callback/` that extracts authorization codes from URL parameters.
- **Redirection Logic**:
- Implemented deep linking (`omnihub://`) to redirect codes back to the desktop application.
- Integrated `localStorage` persistence and automatic redirection for the Web (KMP Wasm) version.
- **CI/CD**: Created `deploy_auth_web.yml` to deploy the site to GitHub Pages on every push to `main` or pull request.
- **Project Configuration**: Updated existing CI workflows to ignore changes in the `site/` directory and the new deployment workflow to avoid redundant runs.
10 tasks
This commit updates the GitHub Pages deployment workflow to use the correct directory for static web content. Changes: - **CI/CD**: Updated `upload-pages-artifact` path from `./web` to `./site` in `deploy_auth_web.yml`.
|
|
This commit introduces the Unsplash OAuth login flow and deep link handling for the multiplatform project.
Key changes:
- **Authentication**: Added `DeepLinkBuffer` to capture and consume auth codes from platform-specific deep links. Integrated `ExchangeOAuthUseCase` and `GetMeUseCase` in `GalleryViewModel` to handle token exchange and user profile fetching.
- **Android Integration**: Updated `MainActivity` to handle incoming intents and pass deep link data to the common layer. Configured `AndroidManifest.xml` with `intent-filter` for the `omnihub://auth/callback` scheme and set `launchMode="singleTask"`.
- **UI Updates**:
- Added a login/profile button in `GalleryScreen` top bar that toggles between an account icon, loading indicator, and user avatar.
- Implemented `GallerySideEffect.OpenUrl` to launch the Unsplash authorization page via `LocalUriHandler`.
- Integrated user profile state into `GalleryContract` and `GalleryUiState`.
- **Platform Configuration**: Added `getUnsplashSecretKey` expected/actual functions across Android, iOS, JVM, and Web platforms.
- **Environment**: Defined a centralized `AUTH_REDIRECT_URL` in the common utility package.
This commit refactors the authentication flow to use a reactive approach for handling deep links, replacing the manual lifecycle-based check.
Key changes:
- **DeepLinkBuffer**: Converted `pendingUrl` from a manual property to a `MutableStateFlow` (`deepLinkUrl`), allowing observers to react to incoming links. Added `consumeDeepLink` to clear the state.
- **GalleryViewModel**:
- Added a coroutine to collect `deepLinkUrl` updates automatically.
- Updated `handleAuthCallback` to accept the auth code directly from the stream.
- Removed `GalleryIntent.CheckAuth` and its manual invocation logic.
- **GalleryScreen**: Removed the `LifecycleEventEffect` that previously triggered the auth check on `ON_START`.
- **GalleryContract**: Removed the obsolete `CheckAuth` intent.
This commit adds the necessary configuration and logic to handle deep links on iOS, enabling the application to intercept and process `omnihub://` URLs. Key changes: - **Configuration**: Updated `Info.plist` to register the `omnihub` URL scheme and `io.lackstudio.omnihub` identifier. - **Deep Link Handling**: Added an `.onOpenURL` modifier in `iOSApp.swift` to intercept incoming URLs. - **Integration**: Integrated with the shared Kotlin code by passing received URLs to `DeepLinkBuffer.shared`.
This commit introduces a unified authentication management system across Android, iOS, JVM (Desktop), and Web, enabling OAuth2 login via Unsplash.
Key changes:
- **Authentication Core**: Introduced `AuthManager` interface to abstract platform-specific login logic (Deep Links for mobile, Local Server for desktop, and Window Location for web).
- **Platform Implementations**:
- **Android/iOS**: Uses system browser with custom scheme deep links (`omnihub://auth/callback`).
- **JVM**: Starts a temporary local HTTP server on port 54321 to capture the auth code and displays a custom `auth_success.html` page.
- **Web**: Manages URL redirection and captures auth codes from the browser's location state.
- **UI & Navigation**:
- Renamed `AccountScreen` to `SettingsScreen` and updated navigation routes.
- Updated `App` logic to automatically navigate to the Gallery feature if an auth code is detected in the `DeepLinkBuffer`.
- Switched "Account" icon to "Settings" in the main navigation.
- **Architecture**:
- Integrated `authModule` into Koin for dependency injection across all platforms.
- Updated `GalleryViewModel` to use `AuthManager` for triggering logins and handling token exchange with dynamic redirect URIs.
- **Environment**: Added `AUTH_REMOTE_REDIRECT_URL` and `AUTH_LOCAL_REDIRECT_URL` to manage different callback targets.
|
🎉 This PR is included in version 0.13.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related Issues
Closes #33
Type of Change
Please check the main type of change this PR introduces. If there are multiple, please select the most significant one.
Description
This PR implements the full Unsplash OAuth2 login flow across all platforms and establishes a unified authentication architecture. [cite_start]It covers specific implementations for Android, iOS, JVM (Desktop), and Web[cite: 1].
Key Changes:
1. Core Authentication & Cross-Platform Implementation (
feat(auth))AuthManagerto abstract platform-specific login logic[cite: 2].omnihub://auth/callback)[cite: 3].auth_success.htmlpage[cite: 4].authModuleinto Koin for dependency injection and updatedGalleryViewModelto handle token exchange (ExchangeOAuthUseCase) and user profile fetching (GetMeUseCase)[cite: 9, 10, 23].2. Deep Link Handling & Bug Fixes (
fix(auth),feat(ios))Info.plistto register the URL scheme and added.onOpenURLhandling iniOSApp.swift[cite: 12, 13, 14].DeepLinkBufferto useMutableStateFlow[cite: 17].GalleryViewModelto automatically collect deep link updates, removing the obsoleteON_STARTcheck logic[cite: 18, 20].3. UI & Navigation Updates
GalleryScreentop bar that toggles between an account icon, loading indicator, and user avatar[cite: 26].4. Infrastructure (
chore(cd),feat(auth web))site/auth/callback/to handle OAuth redirection (supporting Desktop and Web flows)[cite: 33].deploy_auth_web.ymlto automatically deploy the static auth site to GitHub Pages[cite: 36].How to test it?
Please follow these steps to verify the login flow on each platform:
Tested Platforms:
Test Details:
Android / iOS:
Desktop (JVM):
Web (Wasm/JS):
Review Checklist
Before submitting this PR, please confirm the following: