Skip to content

implemented csrf on all admin and auth forms #21 7h#49

Open
cdsiats wants to merge 2 commits intostackpress:mainfrom
cdsiats:enhancement/csrf-on-admin-and-auth-forms
Open

implemented csrf on all admin and auth forms #21 7h#49
cdsiats wants to merge 2 commits intostackpress:mainfrom
cdsiats:enhancement/csrf-on-admin-and-auth-forms

Conversation

@cdsiats
Copy link
Copy Markdown
Collaborator

@cdsiats cdsiats commented Apr 12, 2026

What is this PR for?

  • Just updating content and/or documentation
  • This fixes issue Implement CSRF check on all admin forms #21
  • Spot fix (no issue #)
  • Merging WIP feature #_____
  • Merging done feature #_____
  • This is a merge from a version branch
  • Adding/Updating tests
  • This is a conflict resolution
  • This is a branch cleanup
  • Other: ________________

I verify that...

  • I have logged my time in the commits
  • I have logged my time in this PR
  • I have tagged all the relevant issues
  • I am using VS Code for type checks and linting, or
  • I have ran npm run test with no errors
  • I have manually checked that this bug or feature is working

@cdsiats cdsiats requested a review from cblanquera April 12, 2026 09:20
Copy link
Copy Markdown
Member

@cblanquera cblanquera left a comment

Choose a reason for hiding this comment

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

When I change the value in the csrf field on sign in form I get a JSON response error.

{"code":500,"status":"Internal Server Error","error":"Input buffers must have the same byte length","stack":[{"method":"Object.validateToken","file":"/Users/cblanquera/server/projects/stackpress/csrf-stackpress/stackpress/cjs/csrf/plugin.js","line":30,"char":55},{"method":"<none>","file":"/Users/cblanquera/server/projects/stackpress/csrf-stackpress/stackpress/cjs/session/pages/signin.js","line":46,"char":18},{"method":"Generator.next","file":"<anonymous>","line":0,"char":0},{"method":"fulfilled","file":"/Users/cblanquera/server/projects/stackpress/csrf-stackpress/stackpress/cjs/session/pages/signin.js","line":5,"char":58}]}

What do you think a normal person would think if they saw that? The issue clearly states:

Properly report an error if invalid 419 Page Expired with message This page may have been requested from an external source. We corrected the issue. Please try again. Load the form/confirmation view again (do not redirect out).

//variables
const tokenKey = config.path('csrf.name', 'csrf');
const token = config.path('csrf.token', '');
const confirmUrl = "?confirmed=true&" + tokenKey + "=" + 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.

//variables
const tokenKey = config.path('csrf.name', 'csrf');
const token = config.path('csrf.token', '');
const confirmUrl = "?confirmed=true&" + tokenKey + "=" + 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.

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