sveltejs / sveltejs/kit

option to disable CSRF for list of endpoints

Open
#6,784 13 comments 51 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

With the new csrf protection I can't receive webhooks without disabling csrf on all routes

Describe the proposed solution

In the csrf config, it would be nice to have a "exclude" setting to disable csrf protection in some routes.

// svelte.config.js

const config = {
    kit: {
        csrf: {
            checkOrigin: true,
            // exclude: [ "/webhooks/*" ],
            // AND/OR
            // exclude [ "/webhooks/1", "/webhooks/2" ]
        },
    },
};

export default config;

and/or

// src/routes/+(page.)server.js

export const csrf = false;
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 reading the CSRF configuration in svelte.config.js and the route-level example in src/routes/+(page.)server.js. Trace how CSRF checks are applied to endpoints and determine which exclusion form the project can support consistently. Done means selected webhook routes can receive requests without disabling protection for all routes, with coverage for the chosen configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.