-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle protected endpoints with query strings.
To facilitate nginx configuration, we've changed the redirect from https://$http_host/saml/login?url=$request_uri to https://$http_host/saml/login$request_uri. I erroneously thought $request_uri would be encoded, but it wasn't. The old way created a potentially invalid uri. The new way preserves the original url that we want to come back to.
- Loading branch information
1 parent
41d812e
commit e406790
Showing
5 changed files
with
107 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '3' | ||
services: | ||
saml: | ||
build: . | ||
image: nginx-saml-proxy | ||
volumes: | ||
- ./app.py:/app/app.py | ||
nginx: | ||
build: test/nginx | ||
image: mynginx | ||
ports: ["443:443"] | ||
volumes: | ||
- ./test/nginx/server.conf:/etc/nginx/conf.d/server.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM nginx as certbuilder | ||
|
||
RUN apt-get update && apt-get install -y ssl-cert && apt-get clean | ||
RUN mkdir /ssl && \ | ||
cp -p /etc/ssl/private/ssl-cert-snakeoil.key /ssl/key.pem && \ | ||
cp -p /etc/ssl/certs/ssl-cert-snakeoil.pem /ssl/cert.pem | ||
|
||
FROM nginx | ||
|
||
EXPOSE 80 | ||
EXPOSE 443 | ||
|
||
RUN rm /etc/nginx/conf.d/* && mkdir /static | ||
COPY server.conf /etc/nginx/conf.d/server.conf | ||
COPY --from=certbuilder /ssl /etc/nginx/ssl | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
server { | ||
listen 443 ssl; | ||
ssl_certificate /etc/nginx/ssl/cert.pem; | ||
ssl_certificate_key /etc/nginx/ssl/key.pem; | ||
root /usr/share/nginx/html; | ||
|
||
# anyone with a UW NetID can access this | ||
location / { | ||
auth_request /saml/status; | ||
auth_request_set $auth_user $upstream_http_x_saml_user; | ||
error_page 401 = @login_required; | ||
} | ||
|
||
# user must be a member of uw_it_all | ||
location /secure { | ||
auth_request /saml/status/group/uw_it_all; | ||
error_page 401 = @login_required; | ||
alias /usr/share/nginx/html; | ||
} | ||
|
||
location /saml/ { | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Saml-Entity-Id https://samldemo.iamdev.s.uw.edu/saml; | ||
proxy_set_header X-Saml-Acs /saml/login; | ||
proxy_pass http://saml:5000/; | ||
} | ||
|
||
location @login_required { | ||
return 302 https://$http_host/saml/login$request_uri; | ||
} | ||
} |