Skip to content

Conversation

@AnthonyRonning
Copy link
Contributor

@AnthonyRonning AnthonyRonning commented Jun 10, 2025

Fixes #94

Apple OAuth now properly redirects back to desktop app after authentication. Previously, AppleAuthProvider would navigate within the browser instead of checking the redirect-to-native flag and redirecting to the desktop app.

This fix adds the same Tauri redirect logic used by GitHub/Google OAuth:

  • Check localStorage for "redirect-to-native" flag
  • If set, clear flag and redirect to deep link with access/refresh tokens
  • Otherwise, use regular web navigation

Changes Made:

  • Updated AppleAuthProvider.tsx to check for Tauri desktop auth flow
  • Added same deep link redirect logic as GitHub/Google OAuth
  • Maintains backward compatibility with web and iOS flows

Testing:

  • ✅ Code formatting (Prettier)
  • ✅ Linting (ESLint) - only existing warnings
  • ✅ Build successful

Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved Apple authentication flow to support seamless redirection back to the native app when running in a Tauri environment.
    • Automatically handles deep linking with authentication tokens after successful sign-in on desktop or mobile native apps.
  • Bug Fixes

    • Ensured consistent redirection behavior after Apple authentication across both web and native environments.

Apple OAuth now properly redirects back to desktop app after authentication.
Previously, AppleAuthProvider would navigate within the browser instead of
checking the redirect-to-native flag and redirecting to the desktop app.

This fix adds the same Tauri redirect logic used by GitHub/Google OAuth:
- Check localStorage for "redirect-to-native" flag
- If set, clear flag and redirect to deep link with access/refresh tokens
- Otherwise, use regular web navigation

Fixes #94

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: AnthonyRonning <AnthonyRonning@users.noreply.github.com>
@coderabbitai
Copy link

coderabbitai bot commented Jun 10, 2025

Walkthrough

The code introduces a conditional authentication redirect flow in the AppleAuthProvider component. When running in a Tauri (native) environment, after successful Apple authentication, it constructs and triggers a deep link back to the native app, otherwise defaulting to the standard web flow. No exported or public entity declarations were altered.

Changes

File(s) Change Summary
frontend/src/components/AppleAuthProvider.tsx Added conditional logic to handle post-Apple-authentication redirection for Tauri/native vs. web flows.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AppleAuthProvider
    participant OpenSecretSDK
    participant NativeApp
    participant WebApp

    User->>AppleAuthProvider: Initiate Apple Sign-In
    AppleAuthProvider->>OpenSecretSDK: Handle Apple Auth Callback
    OpenSecretSDK-->>AppleAuthProvider: Return Auth Success

    alt "redirect-to-native" flag is true
        AppleAuthProvider->>AppleAuthProvider: Clear "redirect-to-native" flag
        AppleAuthProvider->>NativeApp: Redirect via deep link with tokens
    else
        AppleAuthProvider->>WebApp: Invoke onSuccess & redirectAfterLogin
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Enable Apple Web OAuth flow on desktop and redirect via browser (#94)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

A hop and a skip, with Apple we go,
From web to desktop, the tokens now flow.
A deep link is sent, the rabbit’s delight,
Hopping between worlds, authentication’s in sight!
With paws on the code and a twinkle anew,
The login is seamless—thanks to this crew!
🐇🍏✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Enhanced Apple OAuth implementation in frontend/src/components/AppleAuthProvider.tsx to properly handle desktop app authentication flow, ensuring users are redirected back to the Tauri desktop app after successful authentication.

  • Added Tauri desktop detection and redirect-to-native flag handling in AppleAuthProvider.tsx
  • Implemented deep link redirection with access/refresh tokens similar to GitHub/Google OAuth flows
  • Maintains existing web and iOS authentication flows while adding desktop support

1 file reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
frontend/src/components/AppleAuthProvider.tsx (1)

240-242: Document or make the timeout delay configurable.

The 1-second delay appears arbitrary. Consider documenting why this delay is necessary or making it configurable.

+            // Add delay to ensure token storage is complete before redirect
             setTimeout(() => {
               window.location.href = deepLinkUrl;
             }, 1000);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c251087 and a0504a6.

📒 Files selected for processing (1)
  • frontend/src/components/AppleAuthProvider.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build-ios
  • GitHub Check: browseruse-tests
  • GitHub Check: build-macos (universal-apple-darwin)
  • GitHub Check: build-linux
🔇 Additional comments (1)
frontend/src/components/AppleAuthProvider.tsx (1)

234-238:

Details

✅ Verification successful

Consider security implications of passing tokens in URL parameters.

Passing sensitive tokens in URL parameters could expose them in browser history, logs, or referrer headers. Verify that this approach is consistent with the existing GitHub and Google OAuth implementations mentioned in the PR description.


🏁 Script executed:

#!/bin/bash
# Description: Check how GitHub and Google OAuth implementations handle Tauri redirects
# Expected: Similar deep link patterns with tokens in URL parameters

echo "Searching for GitHub OAuth Tauri redirect implementation..."
rg -A 10 -B 5 "redirect-to-native.*github" --type tsx --type ts

echo "Searching for Google OAuth Tauri redirect implementation..."
rg -A 10 -B 5 "redirect-to-native.*google" --type tsx --type ts

echo "Searching for other OAuth deep link implementations..."
rg -A 5 "cloud\.opensecret\.maple://" --type tsx --type ts

Length of output: 653


🏁 Script executed:

#!/bin/bash
# Improved search without relying on built-in file type mappings

echo "Searching for GitHub OAuth Tauri redirect implementation..."
rg -g '*.ts' -g '*.tsx' -A10 -B5 'redirect-to-native.*github'

echo "Searching for Google OAuth Tauri redirect implementation..."
rg -g '*.ts' -g '*.tsx' -A10 -B5 'redirect-to-native.*google'

echo "Searching for any OAuth deep link patterns..."
rg -g '*.ts' -g '*.tsx' -A5 'cloud\.opensecret\.maple://'

Length of output: 2712


Deep link token handling is consistent across all providers

Verified that the GitHub and Google callbacks in
frontend/src/routes/auth.$provider.callback.tsx use the exact same deep-link pattern:

  • let deepLinkUrl = \cloud.opensecret.maple://auth?access_token=${encodeURIComponent(accessToken)}`;`
  • Optional &refresh_token=\${encodeURIComponent(refreshToken)}

The Apple implementation in frontend/src/components/AppleAuthProvider.tsx (lines 234–238) matches this pattern, so there’s no divergence in how tokens are passed.
Consider documenting the security trade-offs of URL-based token delivery (e.g., potential exposure in logs or referrers) if you haven’t already.

@AnthonyRonning AnthonyRonning merged commit b619878 into master Jun 10, 2025
12 checks passed
@AnthonyRonning AnthonyRonning deleted the claude/issue-94-20250610_062033 branch June 10, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Apple Web Oauth on Desktop

2 participants