Introduction #
SmartChart’s Single Sign-On (SSO) allows users from third-party systems to log in directly to the SmartChart platform using an encrypted token — no username/password required. The token uses SHA1 algorithm based on a secret key, timestamp, and username, effectively preventing forgery. Unlike single-page embedding, SSO login grants access to the entire platform, not just specific reports.
SSO Integration #
'/echart/smart_login?id=xxx&stamp=xxx&token=xxx&url=/'
Parameters:
id: Username (managed in SmartChart platform)
stamp: Timestamp (milliseconds since Jan 1, 1970)
token: SHA1 encrypted, token = SHA1(link_key + stamp + id)
Set environment variable SMART_KEY = link_key on the SmartChart server
url: Redirect URL after successful login
Python Example #
import time
import hashlib
import os
SMART_CHART_URL = 'http://127.0.0.1:8000'
LOGIN_URL = SMART_CHART_URL + '/echart/smart_login?id={id}&stamp={stamp}&token={token}&url={url}'
SMART_KEY = 'link_key'
def get_smarturl(username, url='/'):
stamp = int(time.time() * 1000)
id = username
res = SMART_KEY + str(stamp) + id
token = hashlib.sha1(res.encode('utf-8')).hexdigest()
LOGIN_DICT = {
"id": id,
"stamp": stamp,
"token": token,
"url": url
}
visit_url = LOGIN_URL.format(**LOGIN_DICT)
return visit_url