Skip to content

Commit

Permalink
Merge pull request #1 from gfenoy/patch-1
Browse files Browse the repository at this point in the history
Set the value for `domain` and `workspace_prefix` using a dedicated `eoepca` section from the main.cfg.

Fix a typo for accessing the username from the parsed JWT.
  • Loading branch information
gfenoy authored Jan 16, 2024
2 parents a9e7771 + 98db414 commit 8eb2460
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions {{cookiecutter.service_name}}/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class EoepcaCalrissianRunnerExecutionHandler(ExecutionHandler):
def __init__(self, conf):
super().__init__()
self.conf = conf
self.domain = "demo.eoepca.org"
self.workspace_prefix = "demo-user"
self.domain = self.conf["eoepca"]["domain"]
self.workspace_prefix = self.conf["eoepca"]["workspace_prefix"]
self.ades_rx_token = self.conf["auth_env"]["jwt"]
self.feature_collection = None

Expand All @@ -101,7 +101,7 @@ def pre_execution_hook(self):
logger.info("Pre execution hook")

# Workspace API endpoint
uri_for_request = f"workspaces/{self.workspace_prefix}-{decoded['user_name']}"
uri_for_request = f"workspaces/{self.workspace_prefix}-{decoded['username']}"

workspace_api_endpoint = os.path.join(
f"https://workspace-api.{self.domain}", uri_for_request
Expand Down Expand Up @@ -137,7 +137,7 @@ def post_execution_hook(self, log, output, usage_report, tool_logs):
decoded = jwt.decode(self.ades_rx_token, options={"verify_signature": False})

# Workspace API endpoint
uri_for_request = f"/workspaces/{self.workspace_prefix}-{decoded['user_name']}"
uri_for_request = f"/workspaces/{self.workspace_prefix}-{decoded['username']}"
workspace_api_endpoint = f"https://workspace-api.{self.domain}{uri_for_request}"

# Request: Get Workspace Details
Expand All @@ -162,7 +162,7 @@ def post_execution_hook(self, log, output, usage_report, tool_logs):
logger.info(f"STAC Catalog URI: {output['StacCatalogUri']}")

try:
cat = read_file(output["StacCatalogUri"])
cat = read_file( output["StacCatalogUri"] )
cat.describe()
except Exception as e:
logger.error(f"Exception: {e}")
Expand All @@ -172,10 +172,10 @@ def post_execution_hook(self, log, output, usage_report, tool_logs):
"Authorization": f"Bearer {self.ades_rx_token}",
}

api_endpoint = f"https://workspace-api.{self.domain}/workspaces/{self.workspace_prefix}-{decoded['user_name']}"
api_endpoint = f"https://workspace-api.{self.domain}/workspaces/{self.workspace_prefix}-{decoded['username']}"

logger.info(
f"Register collection in workspace {self.workspace_prefix}-{decoded['user_name']}"
f"Register collection in workspace {self.workspace_prefix}-{decoded['username']}"
)
collection = next(cat.get_all_collections())

Expand Down

0 comments on commit 8eb2460

Please sign in to comment.