Skip to content

Commit e9069e1

Browse files
committed
Use date-insensitive cookie expiration
On an out-of-time host (any raspberry offline and without working, battery-backed RTC), the cookie expiration would likely be set to a date in the past. Connecting via a strict, time-synced device (iOS) would thus not send (or even remove) the cookie set at credentials-sending\ resulting in a redirect to the login page. We are now setting the expiration as a seconds offset from now, that the client itself will interpret. https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.2 Fixes #8
1 parent ecb529c commit e9069e1

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Password visibility toggle on login page (dashboard#46)
1313

14+
## Fixed
15+
16+
- Unable to login in on out-of-time systems (#8)
17+
1418
## [1.3.2] - 2025-12-11
1519

1620
### Fixed

src/adminui/auth/session.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class Session(BaseModel):
1212
id: UUID
1313
expire_on: datetime.datetime
1414

15+
@property
16+
def expire_in(self) -> int:
17+
""" nb of seconds from now until expiration"""
18+
return int((self.expire_on - get_now()).total_seconds())
19+
1520
@property
1621
def is_valid(self) -> bool:
1722
return self.expire_on > get_now()

src/adminui/auth/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def login_auth(
6565
response.set_cookie(
6666
key=SESSION_COOKIE_NAME,
6767
value=str(session.id),
68-
expires=session.expire_on,
68+
max_age=session.expire_in,
6969
httponly=True,
7070
)
7171
return response

0 commit comments

Comments
 (0)