Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #189 from Workiva/Move-imports-inside-of-csrf_check
Browse files Browse the repository at this point in the history
Move imports inside of csrf_check
  • Loading branch information
rmconsole4-wk authored Jul 6, 2022
2 parents 179af8c + 9469575 commit af4d2a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions furious/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@
# limitations under the License.
#

import logging

import webapp2


def csrf_check(request):
"""
Throws an HTTP 403 error if a CSRF attack is detected, same logic as the deferred module.
https://cloud.google.com/appengine/docs/standard/python/refdocs/modules/google/appengine/ext/deferred/deferred
"""
import logging
import webapp2

in_prod = (
not request.environ.get("SERVER_SOFTWARE").startswith("Devel"))
if in_prod and request.environ.get("REMOTE_ADDR") != "0.1.0.2":
logging.error("Detected an attempted CSRF attack from {}. This request did "
"not originate from Task Queue.".format(request.environ.get("REMOTE_ADDR")))
webapp2.abort(403)
webapp2.abort(403)
2 changes: 1 addition & 1 deletion furious/_pkg_meta.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (1, 6, 4)
version_info = (1, 6, 5)
version = '.'.join(map(str, version_info))

0 comments on commit af4d2a5

Please sign in to comment.