diff --git a/ee/api/chalicelib/blueprints/bp_core_dynamic.py b/ee/api/chalicelib/blueprints/bp_core_dynamic.py index 9abd4cab8..20fdad3a0 100644 --- a/ee/api/chalicelib/blueprints/bp_core_dynamic.py +++ b/ee/api/chalicelib/blueprints/bp_core_dynamic.py @@ -40,7 +40,7 @@ def login(): tenant_id = r.pop("tenantId") # change this in open-source r["limits"] = { - "teamMember": -1, + "teamMember": int(environ.get("numberOfSeats", 0)), "projects": -1, "metadata": metadata.get_remaining_metadata_with_count(tenant_id)} @@ -64,7 +64,7 @@ def get_account(context): 'data': { **r, "limits": { - "teamMember": -1, + "teamMember": int(environ.get("numberOfSeats", 0)), "projects": -1, "metadata": metadata.get_remaining_metadata_with_count(context['tenantId']) }, diff --git a/ee/api/chalicelib/core/license.py b/ee/api/chalicelib/core/license.py index caf107dc7..f41d337b1 100644 --- a/ee/api/chalicelib/core/license.py +++ b/ee/api/chalicelib/core/license.py @@ -1,3 +1,4 @@ +from chalicelib.utils.helper import environ from chalicelib.utils import pg_client from chalicelib.core import unlock @@ -14,7 +15,8 @@ def get_status(tenant_id): "edition": r.get("edition", "").upper(), "versionNumber": r.get("version_number", ""), "license": license[0:2] + "*" * (len(license) - 4) + license[-2:], - "expirationDate": unlock.get_expiration_date() + "expirationDate": unlock.get_expiration_date(), + "teamMember": int(environ.get("numberOfSeats", 0)) }, "count": { "teamMember": r.get("t_users"), diff --git a/ee/api/chalicelib/core/unlock.py b/ee/api/chalicelib/core/unlock.py index 3d9d0f3d1..f4d5da19c 100644 --- a/ee/api/chalicelib/core/unlock.py +++ b/ee/api/chalicelib/core/unlock.py @@ -13,9 +13,14 @@ def get_license(): def check(): - license=get_license() + license = get_license() + if license is None or len(license) == 0: + print("!! license key not found, please provide a LICENSE_KEY env var") + environ["expiration"] = "-1" + environ["numberOfSeats"] = "0" + return print(f"validating: {license}") - r = requests.post('https://parrot.asayer.io/os/license', json={"mid": __get_mid(), "license": get_license()}) + r = requests.post('https://api.openreplay.com/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) @@ -23,6 +28,8 @@ def check(): else: environ["expiration"] = str(r.json()["data"].get("expiration")) environ["lastCheck"] = str(TimeUTC.now()) + if r.json()["data"].get("numberOfSeats") is not None: + environ["numberOfSeats"] = str(r.json()["data"]["numberOfSeats"]) def get_expiration_date(): diff --git a/ee/api/chalicelib/utils/SAML2_helper.py b/ee/api/chalicelib/utils/SAML2_helper.py index af4612005..a0d9f28b5 100644 --- a/ee/api/chalicelib/utils/SAML2_helper.py +++ b/ee/api/chalicelib/utils/SAML2_helper.py @@ -26,7 +26,7 @@ SAML2 = { } idp = None # SAML2 config handler -if len(environ.get("SAML2_MD_URL")) > 0: +if len(environ.get("SAML2_MD_URL","")) > 0: print("SAML2_MD_URL provided, getting IdP metadata config") from onelogin.saml2.idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser