sveltejs / sveltejs/kit

Cookie signing powered by SK

Open
#6,996 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

I can see examples on the web where raw userId is used as session key: https://dev.to/theether0/sveltekit-changes-session-and-cookies-enb

cookies.set('session', user.entityId, {
            path: '/',
            httpOnly: true,
            sameSite: 'strict',
            secure: !dev,
            maxAge: 60 * 60 * 24 * 30
        });
export const handle: Handle = async ({ event, resolve }) => {
    const session = event.cookies.get('session');
    // ...
    const currentUser = await userRepository.fetch(session as string);
    // ...
}
Describe the proposed solution

Cookies should be signed by default, or the option to sign cookies should be integrated in SK.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the cookies.set and event.cookies.get APIs shown in the issue through the SvelteKit repository. No repository files or tests are named, so identify the cookie implementation and its existing test coverage before deciding whether signing is a default behavior or an opt-in API. Done should include a defined signing interface and coverage for signed cookie creation and retrieval.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.