Last active
August 27, 2015 13:33
-
-
Save wandernauta/5eeb012f2039bb2fb0d0 to your computer and use it in GitHub Desktop.
Authenticating Estonian ID cards using Flask and nginx
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
import re | |
from flask import Flask, request | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
dn = request.headers['X-Client'] | |
fields = dict(re.findall("/([^=]*)=([^/]*)", dn)) | |
doctype = "<!doctype html>" | |
title = "<title>eID test</title>" | |
style = "<style>body{text-align:center;font-family:sans-serif;}</style>" | |
content = "<h2><br><br>HEY THERE, {GN} {SN}!</h2>" | |
return doctype + title + style + content.format(**fields) | |
if __name__ == "__main__": | |
app.run(debug=True, port=8080) |
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
events {} | |
http { | |
server { | |
listen 443 ssl; | |
ssl_certificate /etc/nginx/ssl/server.crt; | |
ssl_certificate_key /etc/nginx/ssl/server.key; | |
ssl_client_certificate /etc/nginx/ssl/id.crt; | |
ssl_verify_client on; | |
ssl_verify_depth 3; | |
location / { | |
proxy_pass http://localhost:8080/; | |
proxy_set_header X-Client $ssl_client_s_dn; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment