Skip to content

[DRAFT] Implement Web Authentication UI#6

Draft
al-imam wants to merge 7 commits into
mainfrom
feature/auth-2
Draft

[DRAFT] Implement Web Authentication UI#6
al-imam wants to merge 7 commits into
mainfrom
feature/auth-2

Conversation

@al-imam
Copy link
Copy Markdown

@al-imam al-imam commented May 15, 2026

Summary

  • Implement web authentication UI with login and desktop auth pages
  • Add authentication API client integration
  • Update landing page and add authentication routing
  • Add environment configuration for authentication

Files Changed

  • Added desktop authentication page
  • Added login page with authentication flow
  • Added authentication API client for backend communication
  • Updated landing page hero section
  • Updated environment configuration and dependencies

Authentication Flow Architecture

flowchart LR
  subgraph C["Clients"]
    W["Web App<br/>(Next.js)"]
    D["Desktop App<br/>(Tauri)"]
  end

  subgraph S["Oiper Server (Hono)"]
    WS["Web Auth<br/>/v1/auth/web/*"]
    DS["Desktop Auth<br/>/v1/auth/desktop/*"]
    API["Protected API<br/>/v1/*"]
    WH["Webhooks<br/>/v1/webhooks/workos"]
    DB[("PostgreSQL + Prisma")]
  end

  WO["WorkOS<br/>AuthKit"]

  W -->|"1) Start login (Email/Password or Google)"| WS
  WS -->|"2) Build Auth URL + PKCE + state"| WO
  WO -->|"3) Callback with auth code"| WS
  WS -->|"4) Set sealed session cookie"| W
  W -->|"5) Session/refresh/logout (cookie + CSRF)"| WS
  WS -->|"6) Return web access JWT"| W
  W -->|"7) Bearer JWT API calls"| API

  D -->|"A) POST /desktop/start (device + PKCE challenge)"| DS
  DS -->|"B) Return verification_url"| D
  D -->|"C) Open external browser"| W
  W -->|"D) POST /desktop/confirm (while signed in)"| DS
  DS -->|"E) Generate one-time handoff code"| W
  W -->|"F) Deep link: oiper://auth/callback?request_id&handoff_code&state"| D
  D -->|"G) POST /desktop/exchange (handoff_code + code_verifier)"| DS
  DS -->|"H) Issue desktop access + rotating refresh token"| D
  D -->|"I) Save refresh token in OS secure storage"| D
  D -->|"J) Bearer desktop access token API calls"| API

  WS -->|"User/audit writes"| DB
  DS -->|"Desktop request/session writes"| DB
  API -->|"Application data reads/writes"| DB

  WO -->|"session.revoked webhook"| WH
  WH -->|"Revoke active desktop sessions"| DB

  classDef client fill:#E0F2FE,stroke:#0284C7,stroke-width:2,color:#0C4A6E;
  classDef server fill:#FEF3C7,stroke:#D97706,stroke-width:2,color:#7C2D12;
  classDef idp fill:#EDE9FE,stroke:#7C3AED,stroke-width:2,color:#4C1D95;
  classDef data fill:#DCFCE7,stroke:#16A34A,stroke-width:2,color:#14532D;

  class W,D client;
  class WS,DS,API,WH server;
  class WO idp;
  class DB data;
Loading

Test plan

  • Test web authentication flow
  • Test login page functionality
  • Test desktop authentication page
  • Test API integration
  • Test authentication routing

Related PRs

al-imam added 7 commits May 15, 2026 23:29
…configuration

- Introduced DesktopAuthPage and AuthLoginPage components for handling desktop authentication and user login.
- Updated .env.example to include the OiPer server URL.
- Modified package.json to use dotenv-cli for local development and added dotenv-cli as a dependency.
- Enhanced HeroSection to manage authentication state and display user information.
- Implemented auth-related API functions in auth-api.ts for session management and logout functionality.
…-up, and password reset

- Added SignInForm, SignUpForm, and ForgotPasswordForm components for user authentication.
- Created PublicAuthModal to manage authentication modals without server-side rendering.
- Introduced AuthPageShell for consistent layout across authentication pages.
- Updated layout to include PublicAuthModalClientNoSSR for client-side rendering.
- Enhanced auth-related API functions for improved error handling and session management.
…ocesses

- Introduced VerifySignInPage and VerifySignUpPage components for email verification.
- Implemented EmailVerificationForm component to handle verification code input and submission.
- Updated PublicAuthModal to include email verification forms for both sign-in and sign-up flows.
- Removed email verification logic from SignInForm and SignUpForm, redirecting users to the new verification pages.
…proved session management

- Added AuthProvider component to manage user authentication state and session.
- Refactored SignInForm, SignUpForm, EmailVerificationForm, and ForgotPasswordForm to utilize the new AuthContext for authentication operations.
- Updated layout to include AuthProvider for consistent authentication context across the application.
- Enhanced error handling and session management in authentication forms.
…ndling

- Introduced auth-form-utils for managing callback paths and building verification URLs.
- Refactored SignInForm and SignUpForm to utilize new utility functions for cleaner code.
- Improved error handling in ForgotPasswordForm and EmailVerificationForm by integrating wrap function for API calls.
- Updated AuthProvider to handle session errors more effectively.
…vider

- Eliminated the refreshSession function from the AuthContextValue interface and the AuthProvider component to streamline authentication logic.
- Updated related code to ensure consistency and maintain functionality without the removed method.
…tion improvements

- Added Spinner component to SignInForm, SignUpForm, EmailVerificationForm, and ForgotPasswordForm for better user feedback during submission.
- Updated validation messages for confirmPassword fields in SignUpForm and ForgotPasswordForm to ensure clarity.
- Adjusted text sizes in AuthCard for improved readability.
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.

1 participant