Skip to content

Commit

Permalink
Docs and Client Update - Auth URLs (#12621)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 54b164321088020bcf245d58b84e26209b2d09cf
  • Loading branch information
mat-savage authored and Descartes Labs Build committed Jul 22, 2024
1 parent 8e20dfc commit d38f402
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ below.
- The `Config` exceptions `RuntimeError` and `KeyError` were changed to `ConfigError` exceptions
from `descarteslabs.exceptions`.
- `Auth` now retrieves its URL from the `Config` settings. If no valid configuration can be found,
it reverts to the commercial service (`https://iam.descarteslabs.com`).
it reverts to the commercial service (`https://app.descarteslabs.com`).

### General
- Dependencies for the descarteslabs library have been updated, but remain constrained to continue to support Python 3.7.
Expand Down
9 changes: 9 additions & 0 deletions descarteslabs/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ class DummyAuth:
return peek_settings().iam_url


def get_app_domain():
from descarteslabs.config import peek_settings

class DummyAuth:
payload = {}

return peek_settings().app_url


class Auth:
"""Client used to authenticate with all Descartes Labs service APIs."""

Expand Down
6 changes: 6 additions & 0 deletions descarteslabs/config/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ default_domain = ""
default_domain = "@format production.aws.{this.DOMAIN}"
platform_url = "@format https://platform.{this.DEFAULT_DOMAIN}"

app_url = "@format https://packaged-analytics.production.aws.{this.DOMAIN}"
catalog_v2_url = "@format {this.PLATFORM_URL}/metadata/v1/catalog/v2"
compute_url = "@format {this.PLATFORM_URL}/compute/v1"
iam_url = "@format https://iam.{this.DEFAULT_DOMAIN}"
Expand All @@ -21,6 +22,7 @@ yaas_url = "@format {this.PLATFORM_URL}/yaas/v1"
default_domain = "@format staging.aws.{this.DOMAIN}"
platform_url = "@format https://platform.{this.DEFAULT_DOMAIN}"

app_url = "@format https://packaged-analytics.production.aws.{this.DOMAIN}"
catalog_v2_url = "@format {this.PLATFORM_URL}/metadata/v1/catalog/v2"
compute_url = "@format {this.PLATFORM_URL}/compute/v1"
iam_url = "@format https://iam.{this.DEFAULT_DOMAIN}"
Expand All @@ -34,6 +36,7 @@ yaas_url = "@format {this.PLATFORM_URL}/yaas/v1"
default_domain = "@format dev.aws.{this.DOMAIN}"
platform_url = "@format https://platform.{this.DEFAULT_DOMAIN}"

app_url = "@format https://packaged-analytics.production.aws.{this.DOMAIN}"
catalog_v2_url = "@format {this.PLATFORM_URL}/metadata/v1/catalog/v2"
compute_url = "@format {this.PLATFORM_URL}/compute/v1"
iam_url = "@format https://iam.{this.DEFAULT_DOMAIN}"
Expand All @@ -47,6 +50,7 @@ yaas_url = "@format {this.PLATFORM_URL}/yaas/v1"
default_domain = "@format freemium.aws.{this.DOMAIN}"
platform_url = "@format https://platform.{this.DEFAULT_DOMAIN}"

app_url = "@format https://packaged-analytics.production.aws.{this.DOMAIN}"
catalog_v2_url = "@format {this.PLATFORM_URL}/metadata/v1/catalog/v2"
iam_url = "@format https://iam.{this.DEFAULT_DOMAIN}"
metadata_url = "@format {this.PLATFORM_URL}/metadata/v1"
Expand All @@ -58,6 +62,7 @@ default_domain = "@format dev.aws.{this.DOMAIN}"
platform_url = "@format https://platform.{this.DEFAULT_DOMAIN}"
testing = true

app_url = "@format https://packaged-analytics.production.aws.{this.DOMAIN}"
catalog_v2_url = "@format {this.PLATFORM_URL}/metadata/v1/catalog/v2"
compute_url = "@format {this.PLATFORM_URL}/compute/v1"
iam_url = "@format https://iam.{this.DEFAULT_DOMAIN}"
Expand All @@ -73,6 +78,7 @@ default_domain = "dev.localhost"
platform_url = "@format https://platform.dev.aws.descarteslabs.com"
testing = true

app_url = "@format https://packaged-analytics.production.aws.{this.DOMAIN}"
catalog_v2_url = "@format {this.PLATFORM_URL}/metadata/v1/catalog/v2"
compute_url = "@format {this.PLATFORM_URL}/compute/v1"
iam_url = "@format https://{this.DEFAULT_DOMAIN}:8000"
Expand Down
14 changes: 14 additions & 0 deletions descarteslabs/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def test_env(self):
class VerifyValues(unittest.TestCase):
configs = {
"aws-dev": {
"APP_URL": "https://packaged-analytics.production.aws.descarteslabs.com",
"CATALOG_V2_URL": "https://platform.dev.aws.descarteslabs.com/metadata/v1/catalog/v2",
"COMPUTE_URL": "https://platform.dev.aws.descarteslabs.com/compute/v1",
"IAM_URL": "https://iam.dev.aws.descarteslabs.com",
Expand All @@ -146,7 +147,18 @@ class VerifyValues(unittest.TestCase):
"VECTOR_URL": "https://platform.dev.aws.descarteslabs.com/vector/v1",
"YAAS_URL": "https://platform.dev.aws.descarteslabs.com/yaas/v1",
},
"aws-freemium": {
"APP_URL": "https://packaged-analytics.production.aws.descarteslabs.com",
"CATALOG_V2_URL": "https://platform.freemium.aws.descarteslabs.com/metadata/v1/catalog/v2",
"IAM_URL": "https://iam.freemium.aws.descarteslabs.com",
"LOG_LEVEL": "WARNING",
"METADATA_URL": "https://platform.freemium.aws.descarteslabs.com/metadata/v1",
"PLATFORM_URL": "https://platform.freemium.aws.descarteslabs.com",
"RASTER_URL": "https://platform.freemium.aws.descarteslabs.com/raster/v2",
"USAGE_URL": "https://platform.freemium.aws.descarteslabs.com/usage/v1",
},
"aws-production": {
"APP_URL": "https://packaged-analytics.production.aws.descarteslabs.com",
"CATALOG_V2_URL": "https://platform.production.aws.descarteslabs.com/metadata/v1/catalog/v2",
"COMPUTE_URL": "https://platform.production.aws.descarteslabs.com/compute/v1",
"IAM_URL": "https://iam.production.aws.descarteslabs.com",
Expand All @@ -159,6 +171,7 @@ class VerifyValues(unittest.TestCase):
"YAAS_URL": "https://platform.production.aws.descarteslabs.com/yaas/v1",
},
"aws-staging": {
"APP_URL": "https://packaged-analytics.production.aws.descarteslabs.com",
"CATALOG_V2_URL": "https://platform.staging.aws.descarteslabs.com/metadata/v1/catalog/v2",
"COMPUTE_URL": "https://platform.staging.aws.descarteslabs.com/compute/v1",
"IAM_URL": "https://iam.staging.aws.descarteslabs.com",
Expand All @@ -171,6 +184,7 @@ class VerifyValues(unittest.TestCase):
"YAAS_URL": "https://platform.staging.aws.descarteslabs.com/yaas/v1",
},
"testing": {
"APP_URL": "https://packaged-analytics.production.aws.descarteslabs.com",
"CATALOG_V2_URL": "https://platform.dev.aws.descarteslabs.com/metadata/v1/catalog/v2",
"COMPUTE_URL": "https://platform.dev.aws.descarteslabs.com/compute/v1",
"IAM_URL": "https://iam.dev.aws.descarteslabs.com",
Expand Down
4 changes: 2 additions & 2 deletions descarteslabs/core/client/auth/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
DESCARTESLABS_TOKEN_INFO_PATH,
Auth,
base64url_decode,
get_default_domain as get_auth_domain,
get_app_domain as get_auth_refresh_domain,
)


LOGIN_URL = f"{get_auth_domain()}/auth/refresh_token"
LOGIN_URL = f"{get_auth_refresh_domain()}/refresh_token"


# this is defined this way to support mocking in the tests
Expand Down

0 comments on commit d38f402

Please sign in to comment.