Skip to content

Keep the Onshape sign-in for 30 days instead of until the browser closes - #62

Merged
sushilm20 merged 1 commit into
mainfrom
fix/session-cookie-lifetime
Oct 29, 2026
Merged

sushilm20 merged 1 commit into
mainfrom
fix/session-cookie-lifetime

Conversation

@sushilm20

Copy link
Copy Markdown
Contributor

Owner: "why do i have to connect onshape everytime its kinda annoying".

Cause. controlkit_session was set without Max-Age or Expires, which makes it a browser session cookie. Browsers drop those when they close, but the stored session in KV lives 30 days. So every new browser session showed "Connect Onshape" again, although the sign-in itself was still valid.

Fix.

  • The session cookie now carries Max-Age=2592000 (30 days), the same lifetime as the stored session.
  • Every successful /api/session answer sets the cookie again, so the 30 days restart on each panel load. That costs a response header, not a KV write; the KV session is still re-saved at most once a day.
  • A cookie set before this change becomes a 30-day cookie on its next panel load, so existing sign-ins carry over.

Not changed. If a browser blocks third-party cookies inside Onshape's iframe, sign-in still can't persist there. Onshape's own OAuth guide requires third-party cookies to be allowed for embedded apps.

Tests. index.test.ts checks the redirect cookie's Max-Age and the cookie set again by /api/session. Typecheck and 324 unit tests pass.

The session cookie had no Max-Age, so browsers treated it as a session
cookie and dropped it on every restart while the stored session still lived
for 30 days; people had to connect Onshape again. The cookie now lasts 30
days, and every /api/session answer sets it again, restarting the 30 days
without a KV write.
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps controlkit_session across browser restarts by adding a 30-day Max-Age.

  • The Onshape sign-in cookie now lasts 30 days and renews on panel loads.

Reviews (1) · Last reviewed commit: "Keep the Onshape sign-in for 30 days ins..." · Reviewed by Greptile

@sushilm20
sushilm20 merged commit dbb87b6 into main Oct 29, 2026
2 checks passed
@sushilm20
sushilm20 deleted the fix/session-cookie-lifetime branch October 29, 2026 04:28
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