From 3eccf4eec602a789e80b7b9d4be438d704af034b Mon Sep 17 00:00:00 2001 From: KRAIEM Taha Yassine Date: Sun, 9 May 2021 02:23:26 +0200 Subject: [PATCH] Changes: - fixed env-vars - fixed EE signup - changed EE DB structure - changed FOS DB structure - fixed announcements - use minio for api - use minio for sourcemaps-reader - share env-vars with sourcemaps-reader --- api/.chalice/config.json | 18 +- api/Dockerfile | 2 +- api/app.py | 2 +- api/chalicelib/core/announcements.py | 2 +- api/chalicelib/core/boarding.py | 20 +-- api/chalicelib/core/errors.py | 4 +- .../core/integration_github_issue.py | 2 +- .../core/integration_jira_cloud_issue.py | 4 +- api/chalicelib/core/log_tool_cloudwatch.py | 2 +- api/chalicelib/core/sessions.py | 8 +- api/chalicelib/core/signup.py | 7 +- api/chalicelib/core/telemetry.py | 4 +- api/chalicelib/utils/dev.py | 2 +- api/chalicelib/utils/email_helper.py | 4 +- api/chalicelib/utils/github_client_v3.py | 2 +- api/chalicelib/utils/helper.py | 11 -- .../utils/html/Project-Weekly-Report.html | 4 +- .../utils/html/alert_notification.html | 8 +- api/chalicelib/utils/html/assignment.html | 10 +- .../html/img/{asayer-logo.png => logo.png} | Bin .../img/weekly/{asayer-logo.png => logo.png} | Bin api/chalicelib/utils/html/invitation.html | 14 +- api/chalicelib/utils/html/reset_password.html | 2 +- api/chalicelib/utils/s3.py | 10 +- api/env_handler.py | 17 ++ ee/api/.chalice/config.json | 10 +- ee/api/app.py | 3 + ee/api/chalicelib/_overrides.py | 2 +- .../blueprints/bp_core_dynamic_crons.py | 7 +- ee/api/chalicelib/blueprints/bp_ee.py | 3 + ee/api/chalicelib/core/announcements.py | 2 +- .../core/integration_github_issue.py | 2 +- .../core/integration_jira_cloud_issue.py | 4 +- ee/api/chalicelib/core/log_tool_cloudwatch.py | 2 +- ee/api/chalicelib/core/telemetry.py | 43 ----- ee/api/chalicelib/ee/boarding.py | 20 +-- ee/api/chalicelib/ee/signup.py | 162 +++++++++++------- ee/api/chalicelib/ee/telemetry.py | 4 +- ee/api/chalicelib/ee/unlock.py | 25 +++ ee/api/chalicelib/utils/dev.py | 2 +- ee/api/chalicelib/utils/email_helper.py | 4 +- ee/api/chalicelib/utils/github_client_v3.py | 2 +- ee/api/chalicelib/utils/helper.py | 11 -- .../utils/html/Project-Weekly-Report.html | 4 +- .../utils/html/alert_notification.html | 8 +- ee/api/chalicelib/utils/html/assignment.html | 10 +- .../html/img/{asayer-logo.png => logo.png} | Bin .../img/weekly/{asayer-logo.png => logo.png} | Bin ee/api/chalicelib/utils/html/invitation.html | 14 +- .../chalicelib/utils/html/reset_password.html | 2 +- ee/api/chalicelib/utils/s3.py | 14 +- ee/api/env_handler.py | 17 ++ 52 files changed, 298 insertions(+), 238 deletions(-) rename api/chalicelib/utils/html/img/{asayer-logo.png => logo.png} (100%) rename api/chalicelib/utils/html/img/weekly/{asayer-logo.png => logo.png} (100%) create mode 100644 api/env_handler.py delete mode 100644 ee/api/chalicelib/core/telemetry.py create mode 100644 ee/api/chalicelib/ee/unlock.py rename ee/api/chalicelib/utils/html/img/{asayer-logo.png => logo.png} (100%) rename ee/api/chalicelib/utils/html/img/weekly/{asayer-logo.png => logo.png} (100%) create mode 100644 ee/api/env_handler.py diff --git a/api/.chalice/config.json b/api/.chalice/config.json index d6c3aa2f1..8048eae73 100644 --- a/api/.chalice/config.json +++ b/api/.chalice/config.json @@ -14,15 +14,15 @@ "isFOS": "true", "isEE": "false", "stage": "default-fos", - "jwt_issuer": "asayer-default-fos", + "jwt_issuer": "openreplay-default-fos", "allowCron": "true", "sentry": "false", "sentryURL": "", - "pg_host": "", + "pg_host": "postgresql.db.svc.cluster.local", "pg_port": "5432", - "pg_dbname": "", - "pg_user": "", - "pg_password": "", + "pg_dbname": "postgres", + "pg_user": "postgres", + "pg_password": "asayerPostgres", "alert_ntf": "http://127.0.0.1:8000/async/alerts/notifications/%s", "email_signup": "http://127.0.0.1:8000/async/email_signup/%s", "email_funnel": "http://127.0.0.1:8000/async/funnel/%s", @@ -44,7 +44,6 @@ "sourcemaps_bucket_secret": "", "sourcemaps_bucket_region": "", "js_cache_bucket": "", - "web_mobs": "https://mobs-staging.asayer.io", "async_Token": "", "EMAIL_HOST": "", "EMAIL_PORT": "587", @@ -56,10 +55,13 @@ "EMAIL_SSL_CERT": "", "EMAIL_FROM": "OpenReplay", "SITE_URL": "", - "announcement_bucket": "", + "announcement_url": "", "jwt_secret": "", "jwt_algorithm": "HS512", - "jwt_exp_delta_seconds": "2592000" + "jwt_exp_delta_seconds": "2592000", + "S3_HOST": "", + "S3_KEY": "", + "S3_SECRET": "" }, "lambda_timeout": 150, "lambda_memory_size": 400, diff --git a/api/Dockerfile b/api/Dockerfile index 4d25a923b..0ca8c1edf 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -13,4 +13,4 @@ ENV ENTERPRISE_BUILD ${envarg} ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini RUN chmod +x /tini ENTRYPOINT ["/tini", "--"] -CMD chalice local --no-autoreload --host 0.0.0.0 --stage ${ENTERPRISE_BUILD} \ No newline at end of file +CMD python env_handler.py && chalice local --no-autoreload --host 0.0.0.0 --stage ${ENTERPRISE_BUILD} \ No newline at end of file diff --git a/api/app.py b/api/app.py index 9edf3453b..7d39088f6 100644 --- a/api/app.py +++ b/api/app.py @@ -55,7 +55,7 @@ sys.stderr = F() _overrides.chalice_app(app) -# v0505 +# v0905 @app.middleware('http') def asayer_middleware(event, get_response): global ASAYER_SESSION_ID diff --git a/api/chalicelib/core/announcements.py b/api/chalicelib/core/announcements.py index bb719afb9..b4d4f2a22 100644 --- a/api/chalicelib/core/announcements.py +++ b/api/chalicelib/core/announcements.py @@ -22,7 +22,7 @@ def get_all(user_id): for a in announcements: a["createdAt"] = TimeUTC.datetime_to_timestamp(a["createdAt"]) if a["imageUrl"] is not None and len(a["imageUrl"]) > 0: - a["imageUrl"] = environ["announcement_bucket"] + a["imageUrl"] + a["imageUrl"] = environ["announcement_url"] + a["imageUrl"] return announcements diff --git a/api/chalicelib/core/boarding.py b/api/chalicelib/core/boarding.py index e39f8ff28..c303643c8 100644 --- a/api/chalicelib/core/boarding.py +++ b/api/chalicelib/core/boarding.py @@ -40,20 +40,20 @@ def get_state(tenant_id): meta = cur.fetchone()["sum"] > 0 return [ - {"task": "Install Asayer", + {"task": "Install OpenReplay", "done": recorded, - "URL": "https://docs.asayer.io/getting-started/quick-start"}, + "URL": "https://docs.openreplay.com/getting-started/quick-start"}, {"task": "Identify Users", "done": meta, - "URL": "https://docs.asayer.io/data-privacy-security/metadata"}, + "URL": "https://docs.openreplay.com/data-privacy-security/metadata"}, {"task": "Invite Team Members", "done": len(users.get_members(tenant_id=tenant_id)) > 1, - "URL": "https://app.asayer.io/client/manage-users"}, + "URL": "https://app.openreplay.com/client/manage-users"}, {"task": "Integrations", "done": len(log_tool_datadog.get_all(tenant_id=tenant_id)) > 0 \ or len(log_tool_sentry.get_all(tenant_id=tenant_id)) > 0 \ or len(log_tool_stackdriver.get_all(tenant_id=tenant_id)) > 0, - "URL": "https://docs.asayer.io/integrations"} + "URL": "https://docs.openreplay.com/integrations"} ] @@ -75,9 +75,9 @@ def get_state_installing(tenant_id): ) recorded = cur.fetchone()["count"] > 0 - return {"task": "Install Asayer", + return {"task": "Install OpenReplay", "done": recorded, - "URL": "https://docs.asayer.io/getting-started/quick-start"} + "URL": "https://docs.openreplay.com/getting-started/quick-start"} def get_state_identify_users(tenant_id): @@ -99,13 +99,13 @@ def get_state_identify_users(tenant_id): return {"task": "Identify Users", "done": meta, - "URL": "https://docs.asayer.io/data-privacy-security/metadata"} + "URL": "https://docs.openreplay.com/data-privacy-security/metadata"} def get_state_manage_users(tenant_id): return {"task": "Invite Team Members", "done": len(users.get_members(tenant_id=tenant_id)) > 1, - "URL": "https://app.asayer.io/client/manage-users"} + "URL": "https://app.openreplay.com/client/manage-users"} def get_state_integrations(tenant_id): @@ -113,4 +113,4 @@ def get_state_integrations(tenant_id): "done": len(log_tool_datadog.get_all(tenant_id=tenant_id)) > 0 \ or len(log_tool_sentry.get_all(tenant_id=tenant_id)) > 0 \ or len(log_tool_stackdriver.get_all(tenant_id=tenant_id)) > 0, - "URL": "https://docs.asayer.io/integrations"} + "URL": "https://docs.openreplay.com/integrations"} diff --git a/api/chalicelib/core/errors.py b/api/chalicelib/core/errors.py index 10ad52f59..a522c7f16 100644 --- a/api/chalicelib/core/errors.py +++ b/api/chalicelib/core/errors.py @@ -503,8 +503,8 @@ def search(data, project_id, user_id, flows=False, status="ALL", favorite_only=F GROUP BY timestamp ORDER BY timestamp) AS chart_details) AS chart_details ON (TRUE);""" - print("--------------------") - print(cur.mogrify(main_pg_query, params)) + # print("--------------------") + # print(cur.mogrify(main_pg_query, params)) cur.execute(cur.mogrify(main_pg_query, params)) total = cur.rowcount if flows: diff --git a/api/chalicelib/core/integration_github_issue.py b/api/chalicelib/core/integration_github_issue.py index 8bac3c619..a9e5e7317 100644 --- a/api/chalicelib/core/integration_github_issue.py +++ b/api/chalicelib/core/integration_github_issue.py @@ -41,7 +41,7 @@ class GithubIntegrationIssue(BaseIntegrationIssue): if a == str(u["id"]): real_assignees.append(u["login"]) break - real_labels = ["Asayer"] + real_labels = ["OpenReplay"] for l in labels: found = False for ll in metas["issueTypes"]: diff --git a/api/chalicelib/core/integration_jira_cloud_issue.py b/api/chalicelib/core/integration_jira_cloud_issue.py index b765903c2..00fac2fcb 100644 --- a/api/chalicelib/core/integration_jira_cloud_issue.py +++ b/api/chalicelib/core/integration_jira_cloud_issue.py @@ -16,7 +16,7 @@ class JIRACloudIntegrationIssue(BaseIntegrationIssue): 'description': description, 'issuetype': {'id': issue_type}, 'assignee': {"id": assignee}, - "labels": ["Asayer"] + "labels": ["OpenReplay"] } return self._client.create_issue(data) @@ -30,7 +30,7 @@ class JIRACloudIntegrationIssue(BaseIntegrationIssue): results = [] for integration_project_id in projects_map: self._client.set_jira_project_id(integration_project_id) - jql = 'labels = Asayer' + jql = 'labels = OpenReplay' if len(projects_map[integration_project_id]) > 0: jql += f" AND ID IN ({','.join(projects_map[integration_project_id])})" issues = self._client.get_issues(jql, offset=0) diff --git a/api/chalicelib/core/log_tool_cloudwatch.py b/api/chalicelib/core/log_tool_cloudwatch.py index bdd4a2644..a42de4943 100644 --- a/api/chalicelib/core/log_tool_cloudwatch.py +++ b/api/chalicelib/core/log_tool_cloudwatch.py @@ -47,7 +47,7 @@ def __find_events(client, log_group, streams, last_token, start_time, end_time): "startTime": start_time, "endTime": end_time, "limit": 10000, - "filterPattern": "asayer_session_id" + "filterPattern": "openreplay_session_id" } if last_token is not None: f_args["nextToken"] = last_token diff --git a/api/chalicelib/core/sessions.py b/api/chalicelib/core/sessions.py index 480877468..439bca0fd 100644 --- a/api/chalicelib/core/sessions.py +++ b/api/chalicelib/core/sessions.py @@ -1,11 +1,9 @@ from chalicelib.utils import pg_client, helper +from chalicelib.core import events, sessions_metas, socket_ios, metadata, events_ios, \ + sessions_mobs from chalicelib.utils import dev -from chalicelib.core import events, sessions_metas, socket_ios, metadata, events_ios, sessions_mobs -if helper.is_free_open_source_edition(): - from chalicelib.core import projects, errors -else: - from chalicelib.ee import projects, errors +from chalicelib.core import projects, errors from chalicelib.core import resources diff --git a/api/chalicelib/core/signup.py b/api/chalicelib/core/signup.py index 656d231ef..9acd5c7e5 100644 --- a/api/chalicelib/core/signup.py +++ b/api/chalicelib/core/signup.py @@ -56,8 +56,13 @@ def create_step1(data): project_name = data.get("projectName") if project_name is None or len(project_name) < 1: project_name = "my first project" - if len(get_signed_ups()) > 0 and data.get("tenantId") is None: + signed_ups = get_signed_ups() + if len(signed_ups) > 0 and data.get("tenantId") is None: errors.append("Tenant already exists, please select it from dropdown") + elif len(signed_ups) == 0 and data.get("tenantId") is not None \ + or len(signed_ups) > 0 and data.get("tenantId") not in [t['tenantId'] for t in signed_ups]: + errors.append("Tenant does not exist") + if len(errors) > 0: print("==> error") print(errors) diff --git a/api/chalicelib/core/telemetry.py b/api/chalicelib/core/telemetry.py index 362550553..c4ad14157 100644 --- a/api/chalicelib/core/telemetry.py +++ b/api/chalicelib/core/telemetry.py @@ -30,7 +30,7 @@ def compute(): RETURNING *,(SELECT email FROM public.users WHERE role='owner' LIMIT 1);""" ) data = cur.fetchone() - requests.post('https://parrot.asayer.io/os/telemetry', json=process_data(data)) + requests.post('https://parrot.openreplay.com/os/telemetry', json=process_data(data)) def new_client(): @@ -40,4 +40,4 @@ def new_client(): (SELECT email FROM public.users WHERE role='owner' LIMIT 1) AS email FROM public.tenants;""") data = cur.fetchone() - requests.post('https://parrot.asayer.io/os/signup', json=process_data(data)) + requests.post('https://parrot.openreplay.com/os/signup', json=process_data(data)) diff --git a/api/chalicelib/utils/dev.py b/api/chalicelib/utils/dev.py index 3b350ce7e..c5996e42c 100644 --- a/api/chalicelib/utils/dev.py +++ b/api/chalicelib/utils/dev.py @@ -21,7 +21,7 @@ def timed(f): 'handle_request', '_generic_handle', 'handle', '_bootstrap_inner', 'run', '_bootstrap', '_main_rest_api_handler', '_user_handler', '_get_view_function_response', 'wrapped_event', 'handle_one_request', - '_global_error_handler', 'asayer_middleware']] + '_global_error_handler', 'openreplay_middleware']] print("DEBUG: %s > %s took %d s to finish" % (" > ".join(call_stack), f.__name__, elapsed)) return result diff --git a/api/chalicelib/utils/email_helper.py b/api/chalicelib/utils/email_helper.py index 3e5565f26..8afc84d02 100644 --- a/api/chalicelib/utils/email_helper.py +++ b/api/chalicelib/utils/email_helper.py @@ -7,7 +7,7 @@ def send_team_invitation(recipient, user_name, temp_password, client_id, sender_ formatting_variables={"userName": __escape_text_html(user_name), "password": temp_password, "clientId": client_id, "sender": sender_name}) - SUBJECT = "Welcome to Asayer" + SUBJECT = "Welcome to OpenReplay" send_html(BODY_HTML, SUBJECT, recipient) @@ -115,5 +115,5 @@ def weekly_report2(recipients, data): """ BODY_HTML = __get_html_from_file("chalicelib/utils/html/Project-Weekly-Report.html", formatting_variables=data) - SUBJECT = "Asayer Project Weekly Report" + SUBJECT = "OpenReplay Project Weekly Report" send_html(BODY_HTML=BODY_HTML, SUBJECT=SUBJECT, recipient=recipients) diff --git a/api/chalicelib/utils/github_client_v3.py b/api/chalicelib/utils/github_client_v3.py index a86b721aa..692e878ae 100644 --- a/api/chalicelib/utils/github_client_v3.py +++ b/api/chalicelib/utils/github_client_v3.py @@ -42,7 +42,7 @@ class github_formatters: 'createdAt': github_formatters.get_timestamp(issue["created_at"]), 'closed': issue["closed_at"] is not None, 'commentsCount': issue["comments"], - 'issueType': [str(l["id"]) for l in labels if l["name"].lower() != "asayer"], + 'issueType': [str(l["id"]) for l in labels if l["name"].lower() != "openreplay"], 'labels': [l["name"] for l in labels] } return result diff --git a/api/chalicelib/utils/helper.py b/api/chalicelib/utils/helper.py index 5bb809dd8..a75e13bd8 100644 --- a/api/chalicelib/utils/helper.py +++ b/api/chalicelib/utils/helper.py @@ -40,17 +40,6 @@ def generate_salt(): return "".join(random.choices(string.hexdigits, k=36)) -def remove_empty_none_values(dictionary): - aux = {} - for key in dictionary.keys(): - if dictionary[key] is not None: - if isinstance(dictionary[key], dict): - aux[key] = remove_empty_none_values(dictionary[key]) - elif not isinstance(dictionary[key], str) or len(dictionary[key]) > 0: - aux[key] = dictionary[key] - return aux - - def unique_ordered_list(array): uniq = [] [uniq.append(x) for x in array if x not in uniq] diff --git a/api/chalicelib/utils/html/Project-Weekly-Report.html b/api/chalicelib/utils/html/Project-Weekly-Report.html index bb7b7a38e..6901efb31 100644 --- a/api/chalicelib/utils/html/Project-Weekly-Report.html +++ b/api/chalicelib/utils/html/Project-Weekly-Report.html @@ -11,7 +11,7 @@ """ BODY_HTML = __get_html_from_file("chalicelib/utils/html/Project-Weekly-Report.html", formatting_variables=data) - SUBJECT = "Asayer Project Weekly Report" + SUBJECT = "OpenReplay Project Weekly Report" send_html(BODY_HTML=BODY_HTML, SUBJECT=SUBJECT, recipient=recipients) diff --git a/ee/api/chalicelib/utils/github_client_v3.py b/ee/api/chalicelib/utils/github_client_v3.py index a86b721aa..692e878ae 100644 --- a/ee/api/chalicelib/utils/github_client_v3.py +++ b/ee/api/chalicelib/utils/github_client_v3.py @@ -42,7 +42,7 @@ class github_formatters: 'createdAt': github_formatters.get_timestamp(issue["created_at"]), 'closed': issue["closed_at"] is not None, 'commentsCount': issue["comments"], - 'issueType': [str(l["id"]) for l in labels if l["name"].lower() != "asayer"], + 'issueType': [str(l["id"]) for l in labels if l["name"].lower() != "openreplay"], 'labels': [l["name"] for l in labels] } return result diff --git a/ee/api/chalicelib/utils/helper.py b/ee/api/chalicelib/utils/helper.py index 5bb809dd8..a75e13bd8 100644 --- a/ee/api/chalicelib/utils/helper.py +++ b/ee/api/chalicelib/utils/helper.py @@ -40,17 +40,6 @@ def generate_salt(): return "".join(random.choices(string.hexdigits, k=36)) -def remove_empty_none_values(dictionary): - aux = {} - for key in dictionary.keys(): - if dictionary[key] is not None: - if isinstance(dictionary[key], dict): - aux[key] = remove_empty_none_values(dictionary[key]) - elif not isinstance(dictionary[key], str) or len(dictionary[key]) > 0: - aux[key] = dictionary[key] - return aux - - def unique_ordered_list(array): uniq = [] [uniq.append(x) for x in array if x not in uniq] diff --git a/ee/api/chalicelib/utils/html/Project-Weekly-Report.html b/ee/api/chalicelib/utils/html/Project-Weekly-Report.html index bb7b7a38e..6901efb31 100644 --- a/ee/api/chalicelib/utils/html/Project-Weekly-Report.html +++ b/ee/api/chalicelib/utils/html/Project-Weekly-Report.html @@ -11,7 +11,7 @@
- + @@ -154,7 +154,7 @@
- Asayer Metrics + OpenReplay Metrics Manage Notifications diff --git a/api/chalicelib/utils/html/alert_notification.html b/api/chalicelib/utils/html/alert_notification.html index 36f7a7614..881d6ffb0 100644 --- a/api/chalicelib/utils/html/alert_notification.html +++ b/api/chalicelib/utils/html/alert_notification.html @@ -11,7 +11,7 @@
@@ -38,9 +38,9 @@

- Sent with ♡ from Asayer © 2021 - All rights reserved.

- https://asayer.io/ + Sent with ♡ from OpenReplay © 2021 - All rights reserved.

+ https://openreplay.com/

diff --git a/api/chalicelib/utils/html/assignment.html b/api/chalicelib/utils/html/assignment.html index a6eacbfbf..64d40388b 100644 --- a/api/chalicelib/utils/html/assignment.html +++ b/api/chalicelib/utils/html/assignment.html @@ -385,7 +385,7 @@ width: 25%!important
- Asayer + OpenReplay
+ src="img/logo.png"/> @@ -401,7 +401,7 @@ width: 25%!important

Assigned session

@@ -514,10 +514,10 @@ width: 25%!important
diff --git a/api/chalicelib/utils/html/img/asayer-logo.png b/api/chalicelib/utils/html/img/logo.png similarity index 100% rename from api/chalicelib/utils/html/img/asayer-logo.png rename to api/chalicelib/utils/html/img/logo.png diff --git a/api/chalicelib/utils/html/img/weekly/asayer-logo.png b/api/chalicelib/utils/html/img/weekly/logo.png similarity index 100% rename from api/chalicelib/utils/html/img/weekly/asayer-logo.png rename to api/chalicelib/utils/html/img/weekly/logo.png diff --git a/api/chalicelib/utils/html/invitation.html b/api/chalicelib/utils/html/invitation.html index 9c8c1448f..76b7e2d61 100644 --- a/api/chalicelib/utils/html/invitation.html +++ b/api/chalicelib/utils/html/invitation.html @@ -378,7 +378,7 @@ width: 25%!important
- + @@ -394,7 +394,7 @@ width: 25%!important

- Welcome to Asayer! + Welcome to OpenReplay!

@@ -407,7 +407,7 @@ width: 25%!important

- You have been invited by %(sender)s to join %(clientId)s team on Asayer. + You have been invited by %(sender)s to join %(clientId)s team on OpenReplay.

@@ -450,7 +450,7 @@ width: 25%!important %(frontend_url)s%(frontend_url)s

@@ -553,10 +553,10 @@ width: 25%!important
diff --git a/api/chalicelib/utils/html/reset_password.html b/api/chalicelib/utils/html/reset_password.html index 68bb21e63..2f3d218cf 100644 --- a/api/chalicelib/utils/html/reset_password.html +++ b/api/chalicelib/utils/html/reset_password.html @@ -385,7 +385,7 @@ width: 25%!important
+ src="img/logo.png"/> diff --git a/api/chalicelib/utils/s3.py b/api/chalicelib/utils/s3.py index 544827001..29a8d28bc 100644 --- a/api/chalicelib/utils/s3.py +++ b/api/chalicelib/utils/s3.py @@ -1,9 +1,15 @@ from botocore.exceptions import ClientError +from chalicelib.utils.helper import environ import boto3 -client = boto3.client('s3') -sts_client = boto3.client('sts') +from botocore.client import Config + +client = boto3.client('s3', endpoint_url=environ["S3_HOST"], + aws_access_key_id=environ["S3_KEY"], + aws_secret_access_key=environ["S3_SECRET"], + config=Config(signature_version='s3v4'), + region_name='us-east-1') def exists(bucket, key): diff --git a/api/env_handler.py b/api/env_handler.py new file mode 100644 index 000000000..2d338a486 --- /dev/null +++ b/api/env_handler.py @@ -0,0 +1,17 @@ +from os import environ +import json + +with open('.chalice/config.json') as json_file: + data = json.load(json_file) + stages = data.get("stages", {}) + for s in stages.keys(): + target = f'chalicelib/.configs/{stages[s].get("environment_variables", {}).get("stage", s)}.json' + data = {} + try: + with open(target) as stage_vars: + data = json.load(stage_vars) + except IOError: + pass + with open(target, 'w') as outfile: + json.dump({**data, **environ}, outfile, indent=2, sort_keys=True) + print(f"injected env-vars to {target}") diff --git a/ee/api/.chalice/config.json b/ee/api/.chalice/config.json index 2884836a2..155657b67 100644 --- a/ee/api/.chalice/config.json +++ b/ee/api/.chalice/config.json @@ -14,7 +14,7 @@ "isFOS": "false", "isEE": "true", "stage": "default-ee", - "jwt_issuer": "asayer-default-ee", + "jwt_issuer": "openreplay-default-ee", "allowCron": "true", "sentry": "false", "sentryURL": "", @@ -49,7 +49,6 @@ "js_cache_bucket": "", "SIGN_ID": "", "SIGN_KEY": "", - "web_mobs": "https://mobs-staging.asayer.io", "async_Token": "", "EMAIL_HOST": "", "EMAIL_PORT": "587", @@ -61,10 +60,13 @@ "EMAIL_SSL_CERT": "", "EMAIL_FROM": "OpenReplay", "SITE_URL": "", - "announcement_bucket": "", + "announcement_url": "", "jwt_secret": "", "jwt_algorithm": "", - "jwt_exp_delta_seconds": "" + "jwt_exp_delta_seconds": "", + "S3_HOST": "", + "S3_KEY": "", + "S3_SECRET": "" }, "lambda_timeout": 150, "lambda_memory_size": 400, diff --git a/ee/api/app.py b/ee/api/app.py index 32d81c844..dadd5d7ac 100644 --- a/ee/api/app.py +++ b/ee/api/app.py @@ -60,6 +60,9 @@ _overrides.chalice_app(app) @app.middleware('http') def asayer_middleware(event, get_response): + from chalicelib.ee import unlock + if not unlock.is_valid(): + return Response(body={"errors": ["expired license"]}, status_code=403) if "{projectid}" in event.path.lower(): from chalicelib.ee import projects if not projects.is_authorized(project_id=event.uri_params["projectId"], diff --git a/ee/api/chalicelib/_overrides.py b/ee/api/chalicelib/_overrides.py index 5033b0324..740904aa0 100644 --- a/ee/api/chalicelib/_overrides.py +++ b/ee/api/chalicelib/_overrides.py @@ -13,7 +13,7 @@ base_time = datetime.now(pytz.utc) cors_config = CORSConfig( allow_origin='*', - allow_headers=['vnd.asayer.io.sid'], + allow_headers=['vnd.openreplay.com.sid'], # max_age=600, # expose_headers=['X-Special-Header'], allow_credentials=True diff --git a/ee/api/chalicelib/blueprints/bp_core_dynamic_crons.py b/ee/api/chalicelib/blueprints/bp_core_dynamic_crons.py index 4c8f0beb4..3b4a1357a 100644 --- a/ee/api/chalicelib/blueprints/bp_core_dynamic_crons.py +++ b/ee/api/chalicelib/blueprints/bp_core_dynamic_crons.py @@ -5,9 +5,14 @@ from chalicelib.utils import helper app = Blueprint(__name__) _overrides.chalice_app(app) from chalicelib.ee import telemetry - +from chalicelib.ee import unlock # Run every day. @app.schedule(Cron('0', '0', '?', '*', '*', '*')) def telemetry_cron(event): telemetry.compute() + + +@app.schedule(Cron('0/60', '*', '*', '*', '?', '*')) +def unlock_cron(event): + unlock.check() diff --git a/ee/api/chalicelib/blueprints/bp_ee.py b/ee/api/chalicelib/blueprints/bp_ee.py index 7b3a9454a..38ad071f4 100644 --- a/ee/api/chalicelib/blueprints/bp_ee.py +++ b/ee/api/chalicelib/blueprints/bp_ee.py @@ -1,6 +1,9 @@ from chalice import Blueprint from chalicelib import _overrides +from chalicelib.ee import unlock app = Blueprint(__name__) _overrides.chalice_app(app) + +unlock.check() diff --git a/ee/api/chalicelib/core/announcements.py b/ee/api/chalicelib/core/announcements.py index bb719afb9..b4d4f2a22 100644 --- a/ee/api/chalicelib/core/announcements.py +++ b/ee/api/chalicelib/core/announcements.py @@ -22,7 +22,7 @@ def get_all(user_id): for a in announcements: a["createdAt"] = TimeUTC.datetime_to_timestamp(a["createdAt"]) if a["imageUrl"] is not None and len(a["imageUrl"]) > 0: - a["imageUrl"] = environ["announcement_bucket"] + a["imageUrl"] + a["imageUrl"] = environ["announcement_url"] + a["imageUrl"] return announcements diff --git a/ee/api/chalicelib/core/integration_github_issue.py b/ee/api/chalicelib/core/integration_github_issue.py index 8bac3c619..a9e5e7317 100644 --- a/ee/api/chalicelib/core/integration_github_issue.py +++ b/ee/api/chalicelib/core/integration_github_issue.py @@ -41,7 +41,7 @@ class GithubIntegrationIssue(BaseIntegrationIssue): if a == str(u["id"]): real_assignees.append(u["login"]) break - real_labels = ["Asayer"] + real_labels = ["OpenReplay"] for l in labels: found = False for ll in metas["issueTypes"]: diff --git a/ee/api/chalicelib/core/integration_jira_cloud_issue.py b/ee/api/chalicelib/core/integration_jira_cloud_issue.py index b765903c2..00fac2fcb 100644 --- a/ee/api/chalicelib/core/integration_jira_cloud_issue.py +++ b/ee/api/chalicelib/core/integration_jira_cloud_issue.py @@ -16,7 +16,7 @@ class JIRACloudIntegrationIssue(BaseIntegrationIssue): 'description': description, 'issuetype': {'id': issue_type}, 'assignee': {"id": assignee}, - "labels": ["Asayer"] + "labels": ["OpenReplay"] } return self._client.create_issue(data) @@ -30,7 +30,7 @@ class JIRACloudIntegrationIssue(BaseIntegrationIssue): results = [] for integration_project_id in projects_map: self._client.set_jira_project_id(integration_project_id) - jql = 'labels = Asayer' + jql = 'labels = OpenReplay' if len(projects_map[integration_project_id]) > 0: jql += f" AND ID IN ({','.join(projects_map[integration_project_id])})" issues = self._client.get_issues(jql, offset=0) diff --git a/ee/api/chalicelib/core/log_tool_cloudwatch.py b/ee/api/chalicelib/core/log_tool_cloudwatch.py index bdd4a2644..a42de4943 100644 --- a/ee/api/chalicelib/core/log_tool_cloudwatch.py +++ b/ee/api/chalicelib/core/log_tool_cloudwatch.py @@ -47,7 +47,7 @@ def __find_events(client, log_group, streams, last_token, start_time, end_time): "startTime": start_time, "endTime": end_time, "limit": 10000, - "filterPattern": "asayer_session_id" + "filterPattern": "openreplay_session_id" } if last_token is not None: f_args["nextToken"] = last_token diff --git a/ee/api/chalicelib/core/telemetry.py b/ee/api/chalicelib/core/telemetry.py deleted file mode 100644 index 362550553..000000000 --- a/ee/api/chalicelib/core/telemetry.py +++ /dev/null @@ -1,43 +0,0 @@ -from chalicelib.utils import pg_client -import requests - - -def process_data(data, edition='fos'): - return { - 'edition': edition, - 'tracking': data["opt_out"], - 'version': data["version_number"], - 'user_id': data["user_id"], - 'owner_email': None if data["opt_out"] else data["email"], - 'organization_name': None if data["opt_out"] else data["name"], - 'users_count': data["t_users"], - 'projects_count': data["t_projects"], - 'sessions_count': data["t_sessions"], - 'integrations_count': data["t_integrations"] - } - - -def compute(): - with pg_client.PostgresClient() as cur: - cur.execute( - f"""UPDATE public.tenants - SET t_integrations = COALESCE((SELECT COUNT(DISTINCT provider) FROM public.integrations) + - (SELECT COUNT(*) FROM public.webhooks WHERE type = 'slack') + - (SELECT COUNT(*) FROM public.jira_cloud), 0), - t_projects=COALESCE((SELECT COUNT(*) FROM public.projects WHERE deleted_at ISNULL), 0), - t_sessions=COALESCE((SELECT COUNT(*) FROM public.sessions), 0), - t_users=COALESCE((SELECT COUNT(*) FROM public.users WHERE deleted_at ISNULL), 0) - RETURNING *,(SELECT email FROM public.users WHERE role='owner' LIMIT 1);""" - ) - data = cur.fetchone() - requests.post('https://parrot.asayer.io/os/telemetry', json=process_data(data)) - - -def new_client(): - with pg_client.PostgresClient() as cur: - cur.execute( - f"""SELECT *, - (SELECT email FROM public.users WHERE role='owner' LIMIT 1) AS email - FROM public.tenants;""") - data = cur.fetchone() - requests.post('https://parrot.asayer.io/os/signup', json=process_data(data)) diff --git a/ee/api/chalicelib/ee/boarding.py b/ee/api/chalicelib/ee/boarding.py index 6d0c87a92..08917e4b6 100644 --- a/ee/api/chalicelib/ee/boarding.py +++ b/ee/api/chalicelib/ee/boarding.py @@ -43,20 +43,20 @@ def get_state(tenant_id): meta = cur.fetchone()["sum"] > 0 return [ - {"task": "Install Asayer", + {"task": "Install OpenReplay", "done": recorded, - "URL": "https://docs.asayer.io/getting-started/quick-start"}, + "URL": "https://docs.openreplay.com/getting-started/quick-start"}, {"task": "Identify Users", "done": meta, - "URL": "https://docs.asayer.io/data-privacy-security/metadata"}, + "URL": "https://docs.openreplay.com/data-privacy-security/metadata"}, {"task": "Invite Team Members", "done": len(users.get_members(tenant_id=tenant_id)) > 1, - "URL": "https://app.asayer.io/client/manage-users"}, + "URL": "https://app.openreplay.com/client/manage-users"}, {"task": "Integrations", "done": len(log_tool_datadog.get_all(tenant_id=tenant_id)) > 0 \ or len(log_tool_sentry.get_all(tenant_id=tenant_id)) > 0 \ or len(log_tool_stackdriver.get_all(tenant_id=tenant_id)) > 0, - "URL": "https://docs.asayer.io/integrations"} + "URL": "https://docs.openreplay.com/integrations"} ] @@ -78,9 +78,9 @@ def get_state_installing(tenant_id): ) recorded = cur.fetchone()["count"] > 0 - return {"task": "Install Asayer", + return {"task": "Install OpenReplay", "done": recorded, - "URL": "https://docs.asayer.io/getting-started/quick-start"} + "URL": "https://docs.openreplay.com/getting-started/quick-start"} def get_state_identify_users(tenant_id): @@ -104,13 +104,13 @@ def get_state_identify_users(tenant_id): return {"task": "Identify Users", "done": meta, - "URL": "https://docs.asayer.io/data-privacy-security/metadata"} + "URL": "https://docs.openreplay.com/data-privacy-security/metadata"} def get_state_manage_users(tenant_id): return {"task": "Invite Team Members", "done": len(users.get_members(tenant_id=tenant_id)) > 1, - "URL": "https://app.asayer.io/client/manage-users"} + "URL": "https://app.openreplay.com/client/manage-users"} def get_state_integrations(tenant_id): @@ -118,4 +118,4 @@ def get_state_integrations(tenant_id): "done": len(log_tool_datadog.get_all(tenant_id=tenant_id)) > 0 \ or len(log_tool_sentry.get_all(tenant_id=tenant_id)) > 0 \ or len(log_tool_stackdriver.get_all(tenant_id=tenant_id)) > 0, - "URL": "https://docs.asayer.io/integrations"} + "URL": "https://docs.openreplay.com/integrations"} diff --git a/ee/api/chalicelib/ee/signup.py b/ee/api/chalicelib/ee/signup.py index 104372048..8dff65787 100644 --- a/ee/api/chalicelib/ee/signup.py +++ b/ee/api/chalicelib/ee/signup.py @@ -8,12 +8,9 @@ from chalicelib.utils.TimeUTC import TimeUTC def get_signed_ups(): with pg_client.PostgresClient() as cur: - query = cur.mogrify(f"SELECT tenant_id, name FROM public.tenants;") - cur.execute( - query - ) + cur.execute("SELECT tenant_id, name FROM public.tenants;") rows = cur.fetchall() - return {"data": helper.list_to_camel_case(rows)} + return helper.list_to_camel_case(rows) def create_step1(data): @@ -48,15 +45,19 @@ def create_step1(data): errors.append("Invalid full name.") print("Verifying company's name validity") - company_name = data.get("companyName") + company_name = data.get("organizationName") if company_name is None or len(company_name) < 1 or not helper.is_alphanumeric_space(company_name): - errors.append("invalid company's name") + errors.append("invalid organization's name") print("Verifying project's name validity") project_name = data.get("projectName") if project_name is None or len(project_name) < 1: project_name = "my first project" + signed_ups = get_signed_ups() + if len(signed_ups) == 0 and data.get("tenantId") is not None \ + or len(signed_ups) > 0 and data.get("tenantId") not in [t['tenantId'] for t in signed_ups]: + errors.append("Tenant does not exist") if len(errors) > 0: print("==> error") print(errors) @@ -64,64 +65,95 @@ def create_step1(data): print("No errors detected") print("Decomposed infos") tenant_id = data.get("tenantId") + + params = {"email": email, "password": password, + "fullname": fullname, "companyName": company_name, + "projectName": project_name, + "versionNumber": "0.0.0", + "data": json.dumps({"lastAnnouncementView": TimeUTC.now()})} if tenant_id is not None: - with pg_client.PostgresClient() as cur: - print("Starting ACID insert") - query = cur.mogrify(f"""\ - WITH t AS ( - UPDATE public.tenants - SET name = %(companyName)s, - version_number = %(versionNumber)s, - licence = %(licence)s - WHERE tenant_id=%(tenant_id)s - ), - u AS ( - UPDATE public.users - SET email = %(email)s, - name = %(fullname)s, - WHERE role ='owner' AND tenant_id=%(tenant_id)s - RETURNING user_id,email, role, name - ) - UPDATE public.basic_authentication - SET password= crypt(%(password)s, gen_salt('bf', 12)) - WHERE user_id = (SELECT user_id FROM u) - RETURNING %(tenant_id)s AS tenant_id""", - {"email": email, "password": password, - "fullname": fullname, "companyName": company_name, - "projectName": project_name, - "tenant_id": tenant_id}) - cur.execute( - query - ) - data = cur.fetchone() + query = """\ + WITH t AS ( + UPDATE public.tenants + SET name = %(companyName)s, + version_number = %(versionNumber)s, + licence = %(licence)s + WHERE tenant_id=%(tenant_id)s + RETURNING tenant_id, api_key + ), + u AS ( + UPDATE public.users + SET email = %(email)s, + name = %(fullname)s, + WHERE role ='owner' AND tenant_id=%(tenant_id)s + RETURNING user_id,email, role, name + ) + UPDATE public.basic_authentication + SET password= crypt(%(password)s, gen_salt('bf', 12)) + WHERE user_id = (SELECT user_id FROM u) + RETURNING %(tenant_id)s AS tenant_id""" else: - with pg_client.PostgresClient() as cur: - print("Starting ACID insert") - query = cur.mogrify(f"""\ - WITH t AS ( - INSERT INTO public.tenants (name, version_number, licence) - VALUES (%(companyName)s, %(versionNumber)s, %(licence)s) - RETURNING tenant_id - ), - u AS ( - INSERT INTO public.users (tenant_id, email, role, name, data) - VALUES ((SELECT tenant_id FROM t), %(email)s, 'owner', %(fullname)s,%(data)s) - RETURNING user_id,email,role,name - ), - au AS ( - INSERT INTO public.basic_authentication (user_id, password, generated_password) - VALUES ((SELECT user_id FROM u), crypt(%(password)s, gen_salt('bf', 12)), FALSE) - ) - INSERT INTO public.projects (tenant_id, name, active) - VALUES ((SELECT t.tenant_id FROM t), %(projectName)s, TRUE) - RETURNING tenant_id,project_id;""", - {"email": email, "password": password, - "fullname": fullname, "companyName": company_name, - "projectName": project_name, - "data": json.dumps({"lastAnnouncementView": TimeUTC.now()})}) - cur.execute( - query - ) - data = cur.fetchone() + query = """\ + WITH t AS ( + INSERT INTO public.tenants (name, version_number, edition) + VALUES (%(companyName)s, %(versionNumber)s, 'ee') + RETURNING tenant_id, api_key + ), + u AS ( + INSERT INTO public.users (tenant_id, email, role, name, data) + VALUES ((SELECT tenant_id FROM t), %(email)s, 'owner', %(fullname)s,%(data)s) + RETURNING user_id,email,role,name + ), + au AS ( + INSERT INTO public.basic_authentication (user_id, password, generated_password) + VALUES ((SELECT user_id FROM u), crypt(%(password)s, gen_salt('bf', 12)), FALSE) + ) + INSERT INTO public.projects (tenant_id, name, active) + VALUES ((SELECT t.tenant_id FROM t), %(projectName)s, TRUE) + RETURNING tenant_id,project_id, (SELECT api_key FROM t) AS api_key;""" + + with pg_client.PostgresClient() as cur: + cur.execute(cur.mogrify(query, params)) + cur = cur.fetchone() + project_id = cur["project_id"] + api_key = cur["api_key"] telemetry.new_client(tenant_id=data["tenant_id"]) - return {"data": {"state": "success"}} + created_at = TimeUTC.now() + r = users.authenticate(email, password) + r["banner"] = False + r["limits"] = { + "teamMember": {"limit": 99, "remaining": 98, "count": 1}, + "projects": {"limit": 99, "remaining": 98, "count": 1}, + "metadata": [{ + "projectId": project_id, + "name": project_name, + "limit": 10, + "remaining": 10, + "count": 0 + }] + } + c = { + "tenantId": 1, + "name": company_name, + "apiKey": api_key, + "remainingTrial": 14, + "trialEnded": False, + "billingPeriodStartDate": created_at, + "hasActivePlan": True, + "projects": [ + { + "projectId": project_id, + "name": project_name, + "recorded": False, + "stackIntegrations": False, + "status": "red" + } + ] + } + return { + 'jwt': r.pop('jwt'), + 'data': { + "user": r, + "client": c, + } + } diff --git a/ee/api/chalicelib/ee/telemetry.py b/ee/api/chalicelib/ee/telemetry.py index 704bb390c..9ef8a7203 100644 --- a/ee/api/chalicelib/ee/telemetry.py +++ b/ee/api/chalicelib/ee/telemetry.py @@ -39,7 +39,7 @@ def compute(): RETURNING *,(SELECT email FROM users_ee WHERE role = 'owner' AND users_ee.tenant_id = tenants.tenant_id LIMIT 1);""" ) data = cur.fetchall() - requests.post('https://parrot.asayer.io/os/telemetry', + requests.post('https://parrot.openreplay.com/os/telemetry', json={"stats": [process_data(d, edition='ee') for d in data]}) @@ -51,4 +51,4 @@ def new_client(tenant_id): FROM public.tenants WHERE tenant_id=%(tenant_id)s;""", {"tenant_id": tenant_id})) data = cur.fetchone() - requests.post('https://parrot.asayer.io/os/signup', json=process_data(data, edition='ee')) + requests.post('https://parrot.openreplay.com/os/signup', json=process_data(data, edition='ee')) diff --git a/ee/api/chalicelib/ee/unlock.py b/ee/api/chalicelib/ee/unlock.py new file mode 100644 index 000000000..6e5bdf8b6 --- /dev/null +++ b/ee/api/chalicelib/ee/unlock.py @@ -0,0 +1,25 @@ +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 + + +def check(): + r = requests.post('https://parrot.openreplay.com/os/license', json={"mid": __get_mid(), "license": __get_license()}) + if r.status_code != 200 or not r.json().get("valid"): + environ["expiration"] = "-1" + else: + environ["expiration"] = r.json().get("expiration") + environ["lastCheck"] = TimeUTC.now() + + +def is_valid(): + return int(environ["lastCheck"]) + int(environ["expiration"]) - TimeUTC.now() > 0 diff --git a/ee/api/chalicelib/utils/dev.py b/ee/api/chalicelib/utils/dev.py index 3b350ce7e..c5996e42c 100644 --- a/ee/api/chalicelib/utils/dev.py +++ b/ee/api/chalicelib/utils/dev.py @@ -21,7 +21,7 @@ def timed(f): 'handle_request', '_generic_handle', 'handle', '_bootstrap_inner', 'run', '_bootstrap', '_main_rest_api_handler', '_user_handler', '_get_view_function_response', 'wrapped_event', 'handle_one_request', - '_global_error_handler', 'asayer_middleware']] + '_global_error_handler', 'openreplay_middleware']] print("DEBUG: %s > %s took %d s to finish" % (" > ".join(call_stack), f.__name__, elapsed)) return result diff --git a/ee/api/chalicelib/utils/email_helper.py b/ee/api/chalicelib/utils/email_helper.py index 3e5565f26..8afc84d02 100644 --- a/ee/api/chalicelib/utils/email_helper.py +++ b/ee/api/chalicelib/utils/email_helper.py @@ -7,7 +7,7 @@ def send_team_invitation(recipient, user_name, temp_password, client_id, sender_ formatting_variables={"userName": __escape_text_html(user_name), "password": temp_password, "clientId": client_id, "sender": sender_name}) - SUBJECT = "Welcome to Asayer" + SUBJECT = "Welcome to OpenReplay" send_html(BODY_HTML, SUBJECT, recipient) @@ -115,5 +115,5 @@ def weekly_report2(recipients, data):
- + @@ -154,7 +154,7 @@
- Asayer Metrics + OpenReplay Metrics Manage Notifications diff --git a/ee/api/chalicelib/utils/html/alert_notification.html b/ee/api/chalicelib/utils/html/alert_notification.html index 36f7a7614..881d6ffb0 100644 --- a/ee/api/chalicelib/utils/html/alert_notification.html +++ b/ee/api/chalicelib/utils/html/alert_notification.html @@ -11,7 +11,7 @@
@@ -38,9 +38,9 @@

- Sent with ♡ from Asayer © 2021 - All rights reserved.

- https://asayer.io/ + Sent with ♡ from OpenReplay © 2021 - All rights reserved.

+ https://openreplay.com/

diff --git a/ee/api/chalicelib/utils/html/assignment.html b/ee/api/chalicelib/utils/html/assignment.html index a6eacbfbf..64d40388b 100644 --- a/ee/api/chalicelib/utils/html/assignment.html +++ b/ee/api/chalicelib/utils/html/assignment.html @@ -385,7 +385,7 @@ width: 25%!important
- Asayer + OpenReplay
+ src="img/logo.png"/> @@ -401,7 +401,7 @@ width: 25%!important

Assigned session

@@ -514,10 +514,10 @@ width: 25%!important
diff --git a/ee/api/chalicelib/utils/html/img/asayer-logo.png b/ee/api/chalicelib/utils/html/img/logo.png similarity index 100% rename from ee/api/chalicelib/utils/html/img/asayer-logo.png rename to ee/api/chalicelib/utils/html/img/logo.png diff --git a/ee/api/chalicelib/utils/html/img/weekly/asayer-logo.png b/ee/api/chalicelib/utils/html/img/weekly/logo.png similarity index 100% rename from ee/api/chalicelib/utils/html/img/weekly/asayer-logo.png rename to ee/api/chalicelib/utils/html/img/weekly/logo.png diff --git a/ee/api/chalicelib/utils/html/invitation.html b/ee/api/chalicelib/utils/html/invitation.html index 9c8c1448f..76b7e2d61 100644 --- a/ee/api/chalicelib/utils/html/invitation.html +++ b/ee/api/chalicelib/utils/html/invitation.html @@ -378,7 +378,7 @@ width: 25%!important
- + @@ -394,7 +394,7 @@ width: 25%!important

- Welcome to Asayer! + Welcome to OpenReplay!

@@ -407,7 +407,7 @@ width: 25%!important

- You have been invited by %(sender)s to join %(clientId)s team on Asayer. + You have been invited by %(sender)s to join %(clientId)s team on OpenReplay.

@@ -450,7 +450,7 @@ width: 25%!important %(frontend_url)s%(frontend_url)s

@@ -553,10 +553,10 @@ width: 25%!important
diff --git a/ee/api/chalicelib/utils/html/reset_password.html b/ee/api/chalicelib/utils/html/reset_password.html index 68bb21e63..2f3d218cf 100644 --- a/ee/api/chalicelib/utils/html/reset_password.html +++ b/ee/api/chalicelib/utils/html/reset_password.html @@ -385,7 +385,7 @@ width: 25%!important
+ src="img/logo.png"/> diff --git a/ee/api/chalicelib/utils/s3.py b/ee/api/chalicelib/utils/s3.py index 544827001..3ee2ba621 100644 --- a/ee/api/chalicelib/utils/s3.py +++ b/ee/api/chalicelib/utils/s3.py @@ -1,9 +1,19 @@ from botocore.exceptions import ClientError +from chalicelib.utils.helper import environ +from chalicelib.utils import helper import boto3 -client = boto3.client('s3') -sts_client = boto3.client('sts') +if helper.is_free_open_source_edition() or helper.is_enterprise_edition(): + from botocore.client import Config + + client = boto3.client('s3', endpoint_url=environ["S3_HOST"], + aws_access_key_id=environ["S3_KEY"], + aws_secret_access_key=environ["S3_SECRET"], + config=Config(signature_version='s3v4'), + region_name='us-east-1') +else: + client = boto3.client('s3') def exists(bucket, key): diff --git a/ee/api/env_handler.py b/ee/api/env_handler.py new file mode 100644 index 000000000..2d338a486 --- /dev/null +++ b/ee/api/env_handler.py @@ -0,0 +1,17 @@ +from os import environ +import json + +with open('.chalice/config.json') as json_file: + data = json.load(json_file) + stages = data.get("stages", {}) + for s in stages.keys(): + target = f'chalicelib/.configs/{stages[s].get("environment_variables", {}).get("stage", s)}.json' + data = {} + try: + with open(target) as stage_vars: + data = json.load(stage_vars) + except IOError: + pass + with open(target, 'w') as outfile: + json.dump({**data, **environ}, outfile, indent=2, sort_keys=True) + print(f"injected env-vars to {target}")