Skip to content

fix(auth): make DISABLE_AUTH usable for /workspace#3297

Merged
waleedlatif1 merged 1 commit intosimstudioai:stagingfrom
jayy-77:fix/disable-auth-workspace-2524
Feb 24, 2026
Merged

fix(auth): make DISABLE_AUTH usable for /workspace#3297
waleedlatif1 merged 1 commit intosimstudioai:stagingfrom
jayy-77:fix/disable-auth-workspace-2524

Conversation

@jayy-77
Copy link
Contributor

@jayy-77 jayy-77 commented Feb 22, 2026

Summary

  • Fix DISABLE_AUTH mode causing a blank /workspace by returning an anonymous session using the same response envelope as Better Auth’s get-session endpoint.
  • Make the session provider tolerant to both wrapped ({ data: ... }) and raw session payload shapes.

Test plan

  • bun run test -- lib/auth/session-response.test.ts \"app/api/auth/[...all]/route.test.ts\"

Fixes #2524

Return an anonymous session using the same response envelope as Better Auth's get-session endpoint, and make the session provider tolerant to both wrapped and raw session payloads.

Fixes simstudioai#2524
@vercel
Copy link

vercel bot commented Feb 22, 2026

@jayy-77 is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

@waleedlatif1 waleedlatif1 marked this pull request as ready for review February 24, 2026 17:42
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 24, 2026

Greptile Summary

This PR fixes DISABLE_AUTH mode for /workspace by ensuring the anonymous session response matches Better Auth's expected { data: ... } envelope format. The session provider now tolerantly handles both wrapped and raw session payloads.

Key changes:

  • Added extractSessionDataFromAuthClientResult utility to handle both { data: session } (Better Auth format) and raw { user, session } payloads
  • Created createAnonymousGetSessionResponse to wrap anonymous sessions in the proper envelope
  • Updated /api/auth/get-session endpoint to return wrapped response when auth is disabled
  • Made SessionProvider use the extraction utility for consistent session handling
  • Added comprehensive test coverage for both new utilities

The fix ensures /workspace no longer shows a blank page in DISABLE_AUTH mode.

Confidence Score: 4/5

  • This PR is safe to merge with one minor style improvement recommended
  • The implementation correctly fixes the DISABLE_AUTH blank page issue with proper response envelope wrapping. Comprehensive test coverage validates both the extraction utility and route behavior. The only concern is a type assertion in session-provider.tsx that bypasses type safety, though it's unlikely to cause runtime issues given the extraction function's validation logic.
  • No files require special attention - all changes are straightforward with good test coverage

Important Files Changed

Filename Overview
apps/sim/lib/auth/session-response.ts Added utility to extract session data from wrapped or raw payloads, handles both Better Auth's { data: ... } envelope and raw session objects
apps/sim/lib/auth/anonymous.ts Added createAnonymousGetSessionResponse to wrap anonymous session in Better Auth's expected { data: ... } response envelope
apps/sim/app/api/auth/[...all]/route.ts Updated to return properly wrapped anonymous session response using createAnonymousGetSessionResponse for consistency with Better Auth format
apps/sim/app/_shell/providers/session-provider.tsx Updated to use extractSessionDataFromAuthClientResult for tolerant handling of both wrapped and raw session responses, but uses unsafe type assertion

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[SessionProvider requests session] --> B{DISABLE_AUTH enabled?}
    B -->|Yes| C[ensureAnonymousUserExists]
    C --> D[createAnonymousGetSessionResponse]
    D --> E[Return wrapped anonymous session]
    B -->|No| F[Delegate to Better Auth handler]
    F --> E
    E --> G[extractSessionDataFromAuthClientResult]
    G --> H{Response has data property?}
    H -->|Yes| I[Extract from data envelope]
    H -->|No| J{Response has user property?}
    J -->|Yes| K[Use raw response]
    J -->|No| L[Return null]
    I --> M[Session loaded in provider]
    K --> M
    L --> M
Loading

Last reviewed commit: ee579b5

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.

6 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 9e817bc into simstudioai:staging Feb 24, 2026
9 of 10 checks passed
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.

2 participants