Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document custom.py and how to remain logged in more than two weeks #960

Open
pmorch opened this issue Jan 26, 2025 · 1 comment
Open

Document custom.py and how to remain logged in more than two weeks #960

pmorch opened this issue Jan 26, 2025 · 1 comment

Comments

@pmorch
Copy link

pmorch commented Jan 26, 2025

Issue

By default when you log in, the login expires after two weeks. How can I change that so once I've logged in, I remain logged in indefinitely?

Solution

linkding is a django app, and for this it uses django's default values, one of which is (doc):

SESSION_COOKIE_AGE = 1209600

And 1209600 is 2*7*24*60*60 = two weeks.

When I look in the chrome network tab, as expected I see this header being sent when the login page sets the cookie:

set-cookie: sessionid=g6f5kwd8ctj8pyojquqy09nvsjh12szt; expires=Sun, 09 Feb 2025 09:57:52 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax

But this can be changed in a custom.py file, like this:

custom.py:

# Avoid login cookies expiring
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-age
# Default is two weeks
# SESSION_COOKIE_AGE = 1209600
# This is about 127 years
SESSION_COOKIE_AGE = 4000000000

docker-compose.yaml

diff --git a/linkding/docker-compose.yaml b/linkding/docker-compose.yaml
index ef738b5..ba3b59e 100644
--- a/linkding/docker-compose.yaml
+++ b/linkding/docker-compose.yaml
@@ -6,6 +6,7 @@ services:
       - "9090:9090"
     volumes:
       - "/path/to/linkding-data:/etc/linkding/data"
+      - "./custom.py:/etc/linkding/siteroot/settings/custom.py"
     env_file:
       - env
     restart: unless-stopped

Request for documentation

I can see no other documentation for customization is in the README, so perhaps the author doesn't want it in there, and perhaps this is so niche, that while the author would be open to describing customization, he perhaps doesn't want exactly this in the README. If so, I'm totally fine with this issue just being closed. The next person will likely be able to find this issue and get it sorted.

But perhaps it would be fine to document the custom.py and/or the many options that the shipped base.py allow to override through environment variables.

And perhaps SESSION_COOKIE_AGE could be added as one of the options to base.py that can be overridden by an env.

Because of this ambiguity, I'm not suggesting a PR for the README (yet).

@sissbruecker
Copy link
Owner

A documentation PR for this would be welcome. Could either be added to the "How to" page, or as a separate section in "Options" that explains how to override default Django settings in general. The latter would probably be more useful in the long term.

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

No branches or pull requests

2 participants