Skip to content

Only allow GET and POST requests for views#135

Merged
Themitchell merged 1 commit intomainfrom
fix-csrf-sonarqube-issues
Nov 11, 2025
Merged

Only allow GET and POST requests for views#135
Themitchell merged 1 commit intomainfrom
fix-csrf-sonarqube-issues

Conversation

@Themitchell
Copy link
Copy Markdown
Contributor

What is the change?

Only allow get (or GET / POST) requests in views

Why are we making this change?

Allowing other requests is a security vulnerability

jamiefalcus
jamiefalcus previously approved these changes Nov 10, 2025
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@miriam-z miriam-z left a comment

Choose a reason for hiding this comment

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

I've left a comment.

from .decorators.participant_decorators import require_participant
from ..forms.date_of_birth_form import DateOfBirthForm

@require_http_methods(["GET", "POST"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@require_http_methods/@require_GET decorators are placed above @require_participant. A disallowed-method request will return 405 before any participant logic runs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If i understand correctly thats the behaviour we want. In other words if someone request the endpoint with an invalid method they are given a 405 as the endpoint does not exist. I suppose an argument could be made for not exposing the that that a PUT does not exist but im not sure we care here?

@Themitchell Themitchell merged commit fd1201f into main Nov 11, 2025
23 checks passed
@Themitchell Themitchell deleted the fix-csrf-sonarqube-issues branch November 11, 2025 13:59
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.

3 participants