Embedding the In-App Marketplace
Embed Pandium’s In-App Marketplace via iframe and JWT-based SSO to securely show user-specific integrations, installations, and configs inside your app without an extra login.
Last updated
Was this helpful?
Was this helpful?
import time
import uuid
import falcon
from jwt import encode
class PandiumSSOJWTEndpoint:
def __init__(self, config):
self.config = config
def on_get(self, req: falcon.Request):
payload = {
'iat': int(time.time()),
'jti': str(uuid.uuid4()), # Required.
'external_id': '', # Not Required. Add this if the unique id you use for your user is not the same as email address
'meta': '', # Not Required. Free form object to associate with your user in Pandium
'sub': '', # Required. Email address of your user. Pandium uses this to link our tenant to your user's account in your system
}
jwt = encode(payload, self.config['PANDIUM_SHARED_SECRET'], algorithm='HS256')
sso_url = f"https://{self.config['PANDIUM_SUB_DOMAIN']}.go.pandium.com/?tenant={jwt}"
raise falcon.HTTPTemporaryRedirect(sso_url)
app = falcon.API()
app.add_route('/pandium-sso', PandiumSSOJWTEndpoint({'PANDIUM_SHARED_SECRET': '', 'PANDIUM_SUB_DOMAIN': ''})){
"alg": "HS256",
"typ": "JWT"
}eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
{
"iat": 1621521641,
"jti": "1cfa7dbf-8110-4237-ad22-410608791b7d",
"ti": {
"udn": "Pandium Test",
"ufn": "Important Person",
"uem": "test@pandium.com",
"ili": [
"new-id",
"something-different"
],
"aid": "",
"adn": "",
"xti": {
"extraProp": "extra value",
"extraList": [
"bla",
"listVal"
]
}
},
"sub": "test-pandium-com"
}
HMAC-SHA256(base64url-encoded(header) + "." + base64url-encoded(payload)), <shared secret>)eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ
.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c