[PR #2500] [MERGED] feat: add OAuth desktop authentication flow with deep linking #10029

Closed
opened 2026-04-23 09:21:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2500
Author: @kolaente
Created: 3/29/2026
Status: ✅ Merged
Merged: 3/30/2026
Merged by: @kolaente

Base: main ← Head: claude/oauth-pkce-electron-1ZqWX


📝 Commits (4)

  • baa8a1a chore: add plans/ directory to .gitignore
  • 7c7e83a feat: add OAuth PKCE authentication flow to desktop app
  • 95ba63c feat: add server selection UI for desktop OAuth login
  • f9ae70a feat: show close-tab message after OAuth redirect

📊 Changes

15 files changed (+481 additions, -9 deletions)

View changed files

📝 .gitignore (+1 -0)
📝 desktop/main.js (+111 -3)
➕ desktop/oauth.js (+115 -0)
📝 desktop/package.json (+4 -0)
➕ desktop/preload.js (+15 -0)
📝 frontend/src/components/misc/NoAuthWrapper.vue (+8 -2)
📝 frontend/src/helpers/auth.ts (+18 -0)
➕ frontend/src/helpers/desktopAuth.ts (+21 -0)
📝 frontend/src/i18n/lang/en.json (+6 -0)
📝 frontend/src/stores/auth.ts (+13 -0)
📝 frontend/src/stores/base.ts (+14 -0)
➕ frontend/src/types/desktop.d.ts (+19 -0)
➕ frontend/src/views/user/DesktopLogin.vue (+119 -0)
📝 frontend/src/views/user/Login.vue (+9 -2)
📝 frontend/src/views/user/OAuthAuthorize.vue (+8 -2)

📄 Description

Summary

Implements OAuth-based authentication for the Vikunja desktop application using PKCE (Proof Key for Code Exchange) flow with deep linking support. Users can now authenticate via their browser instead of entering credentials directly in the desktop app.

Key Changes

Desktop (Electron) Implementation

  • New desktop/oauth.js: Implements PKCE OAuth flow with functions to:

    • Generate code verifier and challenge for PKCE
    • Build authorization URLs
    • Exchange authorization codes for tokens
    • Refresh access tokens
    • Handle HTTP requests to token endpoints
  • Updated desktop/main.js:

    • Registers custom vikunja-desktop:// protocol for deep linking
    • Implements single-instance lock to ensure deep links reach the running app
    • Handles deep link callbacks on macOS (open-url event) and Windows/Linux (second-instance event)
    • Adds IPC handlers for oauth:start-login and oauth:refresh-token
    • Opens authorization URL in default browser via shell.openExternal()
  • New desktop/preload.js: Exposes desktop OAuth API to frontend via context bridge:

    • startOAuthLogin(apiUrl): Initiates OAuth flow
    • onOAuthTokens(callback): Listens for token responses
    • onOAuthError(callback): Listens for OAuth errors
    • refreshToken(apiUrl, refreshToken): Refreshes access tokens
    • isDesktop: Boolean flag identifying desktop environment
  • Updated desktop/package.json: Registers vikunja-desktop protocol scheme for deep linking

Frontend Implementation

  • New frontend/src/helpers/desktopAuth.ts: Helper functions to interact with desktop OAuth API

  • New frontend/src/types/desktop.d.ts: TypeScript definitions for desktop OAuth types and window interface

  • Updated frontend/src/views/user/Login.vue:

    • Detects desktop environment and shows desktop-specific login UI
    • Displays "Sign in with your browser" button instead of form fields
    • Shows loading state while waiting for browser authentication
    • Hides traditional login form and OpenID providers on desktop
  • Updated frontend/src/stores/auth.ts:

    • New handleDesktopOAuthTokens() method to process OAuth tokens from desktop
    • Stores refresh token in localStorage for token renewal
  • Updated frontend/src/helpers/auth.ts:

    • Modified refreshToken() to use desktop OAuth refresh flow when in desktop app
    • Stores and retrieves desktop OAuth refresh token from localStorage
  • Updated frontend/src/i18n/lang/en.json: Added translation strings for desktop OAuth UI

Notable Implementation Details

  • PKCE Flow: Uses SHA256 code challenge method for enhanced security without client secrets
  • Deep Linking: Implements platform-specific deep link handling for macOS, Windows, and Linux
  • Token Management: Separates desktop OAuth refresh tokens from regular auth tokens in localStorage
  • Error Handling: Comprehensive error handling with user-friendly messages for OAuth failures
  • Context Isolation: Maintains Electron security best practices with context bridge and sandbox enabled

https://claude.ai/code/session_016V63HyNT7u6yXAx8ZeFVah


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2500 **Author:** [@kolaente](https://github.com/kolaente) **Created:** 3/29/2026 **Status:** ✅ Merged **Merged:** 3/30/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `claude/oauth-pkce-electron-1ZqWX` --- ### 📝 Commits (4) - [`baa8a1a`](https://github.com/go-vikunja/vikunja/commit/baa8a1ab5891b322c78217b4d887ce803e532613) chore: add plans/ directory to .gitignore - [`7c7e83a`](https://github.com/go-vikunja/vikunja/commit/7c7e83a19d5394ebed29450fdaa72699b02a0f57) feat: add OAuth PKCE authentication flow to desktop app - [`95ba63c`](https://github.com/go-vikunja/vikunja/commit/95ba63c2dc6784c38575c9a2ffaa12ac9bb20c3d) feat: add server selection UI for desktop OAuth login - [`f9ae70a`](https://github.com/go-vikunja/vikunja/commit/f9ae70acd8f4df6c2e882f60315aadef742e9ef3) feat: show close-tab message after OAuth redirect ### 📊 Changes **15 files changed** (+481 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+1 -0) 📝 `desktop/main.js` (+111 -3) ➕ `desktop/oauth.js` (+115 -0) 📝 `desktop/package.json` (+4 -0) ➕ `desktop/preload.js` (+15 -0) 📝 `frontend/src/components/misc/NoAuthWrapper.vue` (+8 -2) 📝 `frontend/src/helpers/auth.ts` (+18 -0) ➕ `frontend/src/helpers/desktopAuth.ts` (+21 -0) 📝 `frontend/src/i18n/lang/en.json` (+6 -0) 📝 `frontend/src/stores/auth.ts` (+13 -0) 📝 `frontend/src/stores/base.ts` (+14 -0) ➕ `frontend/src/types/desktop.d.ts` (+19 -0) ➕ `frontend/src/views/user/DesktopLogin.vue` (+119 -0) 📝 `frontend/src/views/user/Login.vue` (+9 -2) 📝 `frontend/src/views/user/OAuthAuthorize.vue` (+8 -2) </details> ### 📄 Description ## Summary Implements OAuth-based authentication for the Vikunja desktop application using PKCE (Proof Key for Code Exchange) flow with deep linking support. Users can now authenticate via their browser instead of entering credentials directly in the desktop app. ## Key Changes ### Desktop (Electron) Implementation - **New `desktop/oauth.js`**: Implements PKCE OAuth flow with functions to: - Generate code verifier and challenge for PKCE - Build authorization URLs - Exchange authorization codes for tokens - Refresh access tokens - Handle HTTP requests to token endpoints - **Updated `desktop/main.js`**: - Registers custom `vikunja-desktop://` protocol for deep linking - Implements single-instance lock to ensure deep links reach the running app - Handles deep link callbacks on macOS (`open-url` event) and Windows/Linux (`second-instance` event) - Adds IPC handlers for `oauth:start-login` and `oauth:refresh-token` - Opens authorization URL in default browser via `shell.openExternal()` - **New `desktop/preload.js`**: Exposes desktop OAuth API to frontend via context bridge: - `startOAuthLogin(apiUrl)`: Initiates OAuth flow - `onOAuthTokens(callback)`: Listens for token responses - `onOAuthError(callback)`: Listens for OAuth errors - `refreshToken(apiUrl, refreshToken)`: Refreshes access tokens - `isDesktop`: Boolean flag identifying desktop environment - **Updated `desktop/package.json`**: Registers `vikunja-desktop` protocol scheme for deep linking ### Frontend Implementation - **New `frontend/src/helpers/desktopAuth.ts`**: Helper functions to interact with desktop OAuth API - **New `frontend/src/types/desktop.d.ts`**: TypeScript definitions for desktop OAuth types and window interface - **Updated `frontend/src/views/user/Login.vue`**: - Detects desktop environment and shows desktop-specific login UI - Displays "Sign in with your browser" button instead of form fields - Shows loading state while waiting for browser authentication - Hides traditional login form and OpenID providers on desktop - **Updated `frontend/src/stores/auth.ts`**: - New `handleDesktopOAuthTokens()` method to process OAuth tokens from desktop - Stores refresh token in localStorage for token renewal - **Updated `frontend/src/helpers/auth.ts`**: - Modified `refreshToken()` to use desktop OAuth refresh flow when in desktop app - Stores and retrieves desktop OAuth refresh token from localStorage - **Updated `frontend/src/i18n/lang/en.json`**: Added translation strings for desktop OAuth UI ## Notable Implementation Details - **PKCE Flow**: Uses SHA256 code challenge method for enhanced security without client secrets - **Deep Linking**: Implements platform-specific deep link handling for macOS, Windows, and Linux - **Token Management**: Separates desktop OAuth refresh tokens from regular auth tokens in localStorage - **Error Handling**: Comprehensive error handling with user-friendly messages for OAuth failures - **Context Isolation**: Maintains Electron security best practices with context bridge and sandbox enabled https://claude.ai/code/session_016V63HyNT7u6yXAx8ZeFVah --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 09:21:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#10029