Compare commits
3 Commits
f031b7aa15
...
5beb07a7fe
Author | SHA1 | Date |
---|---|---|
Sean McArdle | 5beb07a7fe | |
Sean McArdle | 8bb9638005 | |
Sean McArdle | 028e773e8e |
|
@ -0,0 +1,2 @@
|
|||
flask
|
||||
python3-saml
|
|
@ -2,11 +2,16 @@
|
|||
|
||||
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
|
||||
|
||||
import stsparse
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
app.config.update({
|
||||
|
@ -25,8 +30,11 @@ 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)
|
||||
attrs = stsparse.parse_saml_attr(saml_xml)
|
||||
saml_xml = saml_xml.toprettyxml()
|
||||
return render_template('saml.html', token=saml_xml)
|
||||
if request.method == 'GET':
|
||||
return "Dude where's my claims?"
|
||||
|
||||
|
@ -36,12 +44,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__":
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import xml.dom.minidom
|
||||
from functools import singledispatch
|
||||
|
||||
@singledispatch
|
||||
def parse_saml_attr(token):
|
||||
'''
|
||||
Takes a string or xml literal as input and returns the saml attributes
|
||||
as a dictionary claim_name:value.
|
||||
'''
|
||||
return None
|
|
@ -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>
|
Loading…
Reference in New Issue