Basic template rendering of saml token.

dev
Sean McArdle 2018-11-06 15:28:21 -08:00
parent f031b7aa15
commit 028e773e8e
2 changed files with 28 additions and 5 deletions

View File

@ -2,11 +2,14 @@
import flask
import json
import urllib.parse
import xml.dom.minidom
from base64 import b64decode
from flask import jsonify
from flask import request
from flask import render_template
app = flask.Flask(__name__)
app.config.update({
@ -25,8 +28,9 @@ def get_saml_claims():
error = None
if request.method == 'POST':
saml_response = request.form
saml_xml = b64decode(saml_response['SAMLResponse'])
return saml_xml
saml_text = b64decode(urllib.parse.unquote(saml_response['SAMLResponse']), validate=False)
saml_xml = xml.dom.minidom.parseString(saml_text).toprettyxml()
return render_template('saml.html', token=saml_xml)
if request.method == 'GET':
return "Dude where's my claims?"
@ -36,12 +40,11 @@ def get_saml_claims():
def get_oauth_claims():
error = None
if request.method == 'POST':
# handle claims token
return "Dude where's my claims?"
pass
if request.method == 'GET':
#
return "Dude where's my claims?"
pass
return render_template('claims.html', error=error)
if __name__ == "__main__":

20
src/templates/saml.html Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>icanhasclaims</title>
</head>
<body>
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %}
</ul>
<h1>SAML Token</h1>
<pre><code>
{{ token }}
</code></pre>
</body>
</html>