Skip to content

Fix: Add missing CSRF token to organization Add Member form - #335

Closed
cooper667 wants to merge 1 commit into
masterfrom
fix/add-csrf-token-org-member-new
Closed

cooper667 wants to merge 1 commit into
masterfrom
fix/add-csrf-token-org-member-new

Conversation

@cooper667

Copy link
Copy Markdown
Contributor

Summary

CKAN 2.11 enforces CSRF protection on POST forms. PR #329 (chore (6/8): add CSRF tokens for CKAN 2.11 forms) added {{ h.csrf_input() }} to most extension forms but missed organization/member_new.html, which still causes:

400 Bad Request: The CSRF token is missing.

whenever an organization admin submits the Add Member / Edit Member form.

Root cause

Confirmed via live reproduction on dev-adr.unaids.org: fetched the raw server-rendered HTML for organization/member_new.html and confirmed no csrf_token hidden input is present in the <form>, while the same page's other forms (logout, language switcher) correctly include it. Checked all 8 merged CKAN-2.11-migration PRs (#324-#331) — none of them add the token to this file. PR #328 (Bootstrap 5 migration) touched this file only for a pull-left → float-start class rename, unrelated to CSRF.

Fix

One line, matching the exact pattern used by PR #329 elsewhere: add {{ h.csrf_input() }} immediately after the opening <form> tag.

Scope note

group/member_new.html does not need the same fix — it doesn't exist as a theme override on master (only exists on an unrelated unmerged branch), so group Add Member already falls back to CKAN core's template, which already has the CSRF field.

CKAN 2.11 enforces CSRF protection on POST forms (PR #329 added the
token to most extension forms), but organization/member_new.html was
missed, causing '400 Bad Request: The CSRF token is missing' whenever
an org admin submits Add Member. group/member_new.html doesn't need
the same fix — it doesn't exist as a theme override, so it already
falls back to CKAN core's template, which has the token.
@cooper667

Copy link
Copy Markdown
Contributor Author

Closing in favor of #336, which targets development (the actually-deployed branch) instead of master.

@cooper667 cooper667 closed this Jul 9, 2026
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.

1 participant