{"id":19494744,"url":"https://github.com/ceejbot/level-session-csrf","last_synced_at":"2025-06-23T16:40:14.126Z","repository":{"id":11020347,"uuid":"13349405","full_name":"ceejbot/level-session-csrf","owner":"ceejbot","description":"connect middleware that stores a csrf token in a level-session store","archived":false,"fork":false,"pushed_at":"2017-05-02T18:11:31.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-20T13:33:48.419Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ceejbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-05T17:34:57.000Z","updated_at":"2024-03-14T08:31:54.000Z","dependencies_parsed_at":"2022-07-21T12:32:39.764Z","dependency_job_id":null,"html_url":"https://github.com/ceejbot/level-session-csrf","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ceejbot/level-session-csrf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Flevel-session-csrf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Flevel-session-csrf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Flevel-session-csrf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Flevel-session-csrf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceejbot","download_url":"https://codeload.github.com/ceejbot/level-session-csrf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Flevel-session-csrf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261514347,"owners_count":23170356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T21:32:47.906Z","updated_at":"2025-06-23T16:40:14.077Z","avatar_url":"https://github.com/ceejbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# level-session-csrf\n\nConnect middleware that implements csrf tokens backed by a level-session store. API-compatible with [connect/csrf](http://www.senchalabs.org/connect/csrf.html).\n\n[![on npm](http://img.shields.io/npm/v/level-session-csrf.svg?style=flat)](https://www.npmjs.com/package/level-session-csrf)\n\n## Usage\n\n```javascript\n\tvar csrf = require('level-session-csrf');\n\n\tvar sessiondb = require('level-session')(\n\t{\n\t\tlocation: path.join(config.dbpath, 'sessions.db'),\n\t\texpire:   app.SESSION_TTL,\n\t\tkeys:     config.secrets\n\t});\n\n\tvar app = express();\n\tapp.use(sessiondb);\n\tapp.use(csrf());\n```\n\nThen to add the token to the locals for any specific request:\n\n```javascript\nresponse.render('template', { '_csrf': request.csrfToken() });\n```\n\nThe middleware by default assumes that you are providing the token in a form or query parameter named `_csrf`, or in a request header called `x-csrf-token` or `x-xsrf-token`.\n\n## Options\n\nYou can optionally pass an options object to `csrf()` to specify a custom value-checking function. The value-checking function is passed the request object, which it may inspect as it wishes. The function must return a token string. For instance, if you wanted to look at a custom form parameter instead of `_csrf`:\n\n```javascript\nfunction customValue(request)\n{\n\treturn request.body.my_form_parameter;\n}\n\nvar options = { 'value': customValue };\napp.use(csrf(options));\n```\n\n## LICENSE\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Flevel-session-csrf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceejbot%2Flevel-session-csrf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Flevel-session-csrf/lists"}