Skip to content

10 - API (feat): Use Litestar Stores for Sessions - #236

Draft
RobertRosca wants to merge 5 commits into
feat/migrate-litestarfrom
feat/litestar-stores-sessions
Draft

10 - API (feat): Use Litestar Stores for Sessions#236
RobertRosca wants to merge 5 commits into
feat/migrate-litestarfrom
feat/litestar-stores-sessions

Conversation

@RobertRosca

Copy link
Copy Markdown
Member

Stack created with GitHub Stacks CLIGive Feedback 💬

@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch from 563d503 to 16ef9c9 Compare July 17, 2026 06:20
@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch 2 times, most recently from 39e5fbd to a70b372 Compare July 17, 2026 08:40
@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch from a70b372 to d1904ce Compare July 17, 2026 09:09
@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch from d1904ce to 5c42f18 Compare July 17, 2026 09:11
@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch 2 times, most recently from 12578d0 to 3678512 Compare July 17, 2026 09:12
@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch from 3678512 to 0bf01a3 Compare July 17, 2026 10:46
@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch 2 times, most recently from 7bc3aa1 to b86ffe0 Compare July 20, 2026 09:25
@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch from b86ffe0 to e9be966 Compare July 20, 2026 09:28
@RobertRosca
RobertRosca force-pushed the feat/litestar-stores-sessions branch from e9be966 to 107a031 Compare July 20, 2026 09:30

@CammilleCC CammilleCC left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this, looks good on first impression. Excited on we can utilize the stores in the future 😊

return f"{request.url.path}:{proposal_number}"


@get("/content", cache=5, cache_key_builder=_proposal_cache_key)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm: is this behind auth? I just wonder on the case when the cache is already built by an authorized user who just accessed it, and then subsequenltly accessed by unauthorized user. From reading the code, the endpoint will return the content regardless.

# id, with no parallel store to keep consistent.
request.session["user"] = user
token_store.store(str(user["sub"]), token)
request.session["tokens"] = token

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooh this is a bit scary. Do we have encryption on the file store or something similar?

# session data lives in a Litestar store. The same registry backs every
# named store (sessions, response cache); the backend is mode-dependent
# (in-memory locally, file-backed otherwise) and selected below.
session_config = ServerSideSessionConfig(key=SESSION_COOKIE_KEY)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add secure=... here? We can use/introduce an env var to denote if we're prod or dev (or local with is_local).

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.

2 participants