coder / coder/code-server

Allow configuring login cookie with an expiry duration

Đang mở
#7,301 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
TypeScript
Star
79.3k
Fork
6.8k
Merge trung bình
2 ngày 6 giờ
Pull request đã merge (30 ngày)
41

Mô tả

## What is your suggestion?

Allow configuring an (optional) expiry age for the login cookie so that it persists beyond a browser session. This is handy for not re-entering the password every time.

**Possible change**:
https://github.com/coder/code-server/blob/main/src/node/http.ts#L328

```ts
...
return {
domain: getCookieDomain(url.host, req.args["proxy-domain"]),
path: normalize(url.pathname) || "/",
sameSite: "lax",
// Load, if provided, max age for login cookie. 0 means it becomes a Session cookie (according to Express docs)
maxAge: getConfigCookieMaxAgeAsMilliseconds() || 0,
}
```

## Why do you want this feature?

I want to maintain my login status even after closing the browser (as the Cookie is currently session-only). Say keep the login cookie for a week or a month. Adding a max-age changes the cookie from `Session` to persistent for the given duration using Express' `maxAge` parameter ([docs](https://expressjs.com/en/api.html#res.cookie)).

## Are there any workarounds to get this functionality today?

No, none directly. User can manually edit the cookie in Devtools

## Are you interested in submitting a PR for this?

I'm not that familiar with how to make new configuration argument and also how the config args are read (there's some middleware for `args` IIRC, but not sure how to use that). But I can give it a go, with some help.

The above given change should be roughly all that's needed, sans the config reading.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.