Hello there!

Need Help? We are right here!

support
miniOrange Support

Thanks for your inquiry.
One of our representatives will get in touch with you shortly via email.

Authenticate Python with JWT
miniOrange provides a ready to use code in python for solution. Use the following python code with any SAML IDP or any other social or enterprise credential store using JWT.

Python Single Sign On with SAML IDP using JWT


Follow the Step-by-Step Guide given below to integrate your Python code with SAML IDP using JWT.

Step 1: Set up an Identity Source in miniOrange

Step 2: Configure miniOrange as relying party in your SAML IDP

Step 3: Creating an external app in miniOrange

Step 4: Fetching the Customer Key and Customer Token Key

Step 5: Adding the request page

request.py
from Crypto.Cipher import AES
import base64
import webbrowser
import urllib
import time
 
key = <CUSTUMER_KEY>
customer_id=<CUSTUMER_ID>
app_secret=<APP_SECRET>
return_url = 'http://localhost:5000'
timestamp= long(round(time.time()*1000))
text=str(timestamp)+":"+app_secret
cipher = AES.new(key, AES.MODE_ECB)
padSize = 16 - (len(text) % 16);
for i in range(0,padSize):
    text += chr(padSize)
msg =cipher.encrypt(text)
cipher_text=(base64.b64encode(msg)).encode("utf-8")
webbrowser.open("https://mytest.miniorange.in/moas/broker/login/jwt/"+customer_id+"/"+"?token="+urllib.quote_plus(cipher_text)+"&returnUrl="+urllib.quote_plus(return_url), new=2)

Step 6: Adding the response page

callback.py
from flask import Flask,request
import urlparse
import base64
import json
import time 

app = Flask(__name__)

@app.route("/")
def main():
  if request.method == 'GET':
    parsed = urlparse.urlparse(request.url)
    id_token=urlparse.parse_qs(parsed.query)['id_token']
    id_array=str(id_token).split(".")
    id_array[1] += "=" * ((4 - len(id_array[1]) % 4) % 4)
    j=json.loads(base64.b64decode(id_array[1]))
    if j['exp']>long(round(time.time()/1000)):
      return j['NameID']
    else:
      return "Response expired. Try login again."

if __name__ == "__main__":
  app.run()

We offer Security Solutions of Single Sign-On, Two Factor Authentication, Fraud Prevention and much more.

Please call us at +1978 658 9387 (US), +91 77966 99612 (India) or email us at info@xecurify.com