Skip to content

Commit

Permalink
chore: use CSRF protection only if not DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Lord committed Jul 9, 2024
1 parent 06ca807 commit 1fd27b1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/app/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ def bypass_cors_requests():
return Response()
# To create a slow-speed server: time.sleep(6)

@self.flask.before_request
def validate_csrf_source():
if request.method == "POST":
# Currently, GET has no side effect, so no need to protect.
if CSRF_HEADER_NAME not in request.headers:
return make_response(
f"CSRF Error! {CSRF_HEADER_NAME} header must be set."
)
if self.flask.config["DEBUG"] is not True:
self.flask.before_request(validate_csrf_source)


def set_jwt(self) -> None:
from .resources.base import file_jwt
Expand Down

0 comments on commit 1fd27b1

Please sign in to comment.