Skip to content

Commit

Permalink
chore(revproxy): add csrf check
Browse files Browse the repository at this point in the history
csrf cookie-to-header check in the reverse proxy
  • Loading branch information
frickjack committed Jan 29, 2018
1 parent 79a520f commit 7516873
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions kube/services/revproxy/00nginx-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ data:
##
# Logging Settings
##
##
access_log /dev/stdout;
error_log /dev/stderr;
Expand All @@ -67,6 +66,21 @@ data:
if ($cookie_access_token) {
set $access_token "Bearer $cookie_access_token";
}
#
# CSRF check
# This block requires a csrftoken for all POST requests.
#
set $csrf_check "fail";
if ($cookie_csrftoken = $http_x_csrf_token) {
set $csrf_check "ok-$cookie_csrftoken";
}
if ($request_method != "POST") {
set $csrf_check "ok-$request_method";
}
if ($csrf_check !~ ^ok-\S.+$) {
return 403 "failed csrf check";
}
#
# Note - need to repeat this line in location blocks that call proxy_set_header,
Expand Down

0 comments on commit 7516873

Please sign in to comment.