Skip to content

Commit 0492e58

Browse files
committed
checkpoint for experimental Gateway Service
1 parent a064905 commit 0492e58

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

netfoundry/ctl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,7 @@ def use_organization(cli, spinner: object = None, prompt: bool = True):
11531153
expiry_minimum=0,
11541154
proxy=cli.config.general.proxy,
11551155
logger=cli.log,
1156+
gateway="gatewayv2",
11561157
)
11571158
except NFAPINoCredentials:
11581159
if prompt:
@@ -1177,6 +1178,7 @@ def use_organization(cli, spinner: object = None, prompt: bool = True):
11771178
expiry_minimum=0,
11781179
proxy=cli.config.general.proxy,
11791180
logger=cli.log,
1181+
gateway="gatewayv2",
11801182
)
11811183
except PyJWTError:
11821184
spinner.fail("Not a valid token")

netfoundry/network_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def find_latest_network_version(self, network_versions: list = list(), is_active
149149

150150
find_latest_product_version = find_latest_network_version
151151

152-
def create_network(self, name: str, network_group_id: str = None, location: str = "us-ashburn-1", provider: str = "OCI", version: str = None, size: str = "medium", wait: int = 1200, sleep: int = 10, **kwargs):
152+
def create_network(self, name: str, network_group_id: str = None, location: str = "eu-amsterdam-1", provider: str = "OCI", version: str = None, size: str = "medium", wait: int = 1200, sleep: int = 10, **kwargs):
153153
"""
154154
Create a network in this network group.
155155

netfoundry/organization.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def __init__(self,
4343
log_file: str = None,
4444
debug: bool = False,
4545
logger: logging.Logger = None,
46-
proxy: str = None):
46+
proxy: str = None,
47+
gateway: str = "gateway"):
4748
"""Initialize an instance of organization."""
49+
self.gateway = gateway
4850
# set debug and file if specified and let the calling application dictate logging handlers
4951
self.log_file = log_file
5052
self.debug = debug
@@ -249,7 +251,8 @@ def __init__(self,
249251
self.logger.warning(f"unexpected environment '{self.environment}'")
250252

251253
if self.environment and not self.audience:
252-
self.audience = f'https://gateway.{self.environment}.netfoundry.io/'
254+
self.audience = f'https://{self.gateway}.{self.environment}.netfoundry.io/'
255+
self.logger.debug(f"computed audience URL from gateway and environment: {self.audience}")
253256

254257
if self.environment and self.audience:
255258
if not re.search(self.environment, self.audience):
@@ -284,15 +287,15 @@ def __init__(self,
284287
# extract the environment name from the authorization URL aka token API endpoint
285288
if self.environment is None:
286289
self.environment = re.sub(r'https://netfoundry-([^-]+)-.*', r'\1', token_endpoint, re.IGNORECASE)
287-
self.logger.debug(f"using environment parsed from token_endpoint URL {self.environment}")
290+
self.logger.debug(f"using environment parsed from authenticationUrl: {self.environment}")
288291
# re: scope: we're not using scopes with Cognito, but a non-empty value is required;
289292
# hence "/ignore-scope"
290-
scope = "https://gateway."+self.environment+".netfoundry.io//ignore-scope"
293+
scope = f"https://{self.gateway}.{self.environment}.netfoundry.io//ignore-scope"
294+
self.logger.debug(f"computed scope URL from gateway and environment: {scope}")
291295
# we can gather the URL of the API from the first part of the scope string by
292296
# dropping the scope suffix
293297
self.audience = scope.replace(r'/ignore-scope', '')
294-
self.logger.debug(f"using audience parsed from token_endpoint URL {self.audience}")
295-
# e.g. https://gateway.production.netfoundry.io/
298+
self.logger.debug(f"using audience parsed from authenticationUrl: {self.audience}")
296299
assertion = {
297300
"scope": scope,
298301
"grant_type": "client_credentials"

netfoundry/utility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def jwt_environment(setup: object):
185185

186186
else:
187187
if re.match(r'https://cognito-', iss):
188-
environment = re.sub(r'https://gateway\.([^.]+)\.netfoundry\.io.*', r'\1', claim['scope'])
188+
environment = re.sub(f'https://{setup.gateway}\.([^.]+)\.netfoundry\.io.*', r'\1', claim['scope'])
189189
setup.logger.debug(f"matched Cognito issuer URL convention, found environment '{environment}'")
190190
elif re.match(r'.*\.auth0\.com', iss):
191191
environment = re.sub(r'https://netfoundry-([^.]+)\.auth0\.com.*', r'\1', claim['iss'])

0 commit comments

Comments
 (0)