openreplay/ee/api/chalicelib/core/unlock.py
Kraiem Taha Yassine 9a5fc4bac7
SAML2 (#83)
* feat(api): remove stage name from email subject

* change(api): refactored code & SAML2 SSO SLO SLS

* change(api): SAML2 extracted & custom configuration

* change(api): SAML2 migrate user after signup

* feat(api): return project_key with session's details

* change(api): SAML2

* feat(db): tenants & users table changes for SAML2
2021-07-12 22:09:09 +02:00

35 lines
958 B
Python

from chalicelib.utils.helper import environ
from chalicelib.utils.TimeUTC import TimeUTC
import requests
import uuid
def __get_mid():
return str(uuid.UUID(int=uuid.getnode()))
def get_license():
return environ.get("LICENSE_KEY", "")
def check():
license=get_license()
print(f"validating: {license}")
r = requests.post('https://parrot.asayer.io/os/license', json={"mid": __get_mid(), "license": get_license()})
if r.status_code != 200 or "errors" in r.json() or not r.json()["data"].get("valid"):
print("license validation failed")
print(r.text)
environ["expiration"] = "-1"
else:
environ["expiration"] = str(r.json()["data"].get("expiration"))
environ["lastCheck"] = str(TimeUTC.now())
def get_expiration_date():
return int(environ.get("expiration", 0))
def is_valid():
if environ.get("lastCheck") is None:
check()
return get_expiration_date() - TimeUTC.now() > 0