Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7301
Summary
Adds an opt-in
--cookie-max-age <seconds>flag so the login cookie can outlive the browser session.Problem
The login cookie is set without
Max-Age/Expires, so it is a session cookie and users must log in again every time the browser is closed (#7301). There is no setting to change this.Solution
A new numeric flag
cookie-max-age. When set, the cookie set insrc/node/routes/login.tsgetsmaxAge = seconds * 1000. Without the flag behaviour is unchanged. Non-positive or non-numeric values throw at startup, like--idle-timeout-seconds. The max age is added at login only, not ingetCookieOptions, because logout reuses those options to clear the cookie.Changes
src/node/cli.tscookie-max-ageoption, description, validationsrc/node/routes/login.tsmaxAgewhen setting the login cookieCHANGELOG.mdtest/unit/node/cli.test.tstest/unit/node/routes/login.test.tsMax-Age=3600with the flag, noMax-Age/Expireswithout itBefore / After
Before:
Set-Cookie: code-server-session=...; Path=/; HttpOnly; SameSite=LaxAfter (
--cookie-max-age=3600):...; Max-Age=3600; Expires=...How to test
PASSWORD=x code-server --cookie-max-age 3600, log in, check the cookie expiry in devtools; restart the browser and confirm you are still logged in.Testing done
Notes for reviewers
Documented in the CHANGELOG and
--help. No env var yet; happy to addCODE_SERVER_COOKIE_MAX_AGEif you want one.