Getting setup for token parsing.
parent
8bb9638005
commit
5beb07a7fe
|
@ -2,6 +2,7 @@
|
|||
|
||||
import flask
|
||||
import json
|
||||
|
||||
import urllib.parse
|
||||
import xml.dom.minidom
|
||||
from base64 import b64decode
|
||||
|
@ -9,6 +10,7 @@ from flask import jsonify
|
|||
from flask import request
|
||||
from flask import render_template
|
||||
|
||||
import stsparse
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
|
@ -29,7 +31,9 @@ def get_saml_claims():
|
|||
if request.method == 'POST':
|
||||
saml_response = request.form
|
||||
saml_text = b64decode(urllib.parse.unquote(saml_response['SAMLResponse']), validate=False)
|
||||
saml_xml = xml.dom.minidom.parseString(saml_text).toprettyxml()
|
||||
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?"
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue