From e0f07ac92f4a4b0be4be54d42f10ab3b1ba9389f Mon Sep 17 00:00:00 2001 From: Tejas Rajopadhye <71188245+TejasRGitHub@users.noreply.github.com> Date: Fri, 25 Sep 2026 11:45:49 -0500 Subject: [PATCH 1/2] Use the front page discovery from dataall-core The discovery helper and the OidcBrowserAuth defaults now live in dataall-core 0.6.0 so the SDK can share them. Version 0.6.0. Co-Authored-By: Claude Fable 5.1 --- dataall_cli/cli.py | 8 +-- dataall_cli/utils/__init__.py | 3 +- dataall_cli/utils/discovery.py | 54 -------------------- pyproject.toml | 4 +- tests/unit/test_discovery.py | 93 ---------------------------------- 5 files changed, 9 insertions(+), 153 deletions(-) delete mode 100644 dataall_cli/utils/discovery.py delete mode 100644 tests/unit/test_discovery.py diff --git a/dataall_cli/cli.py b/dataall_cli/cli.py index 8a76cd6..692bba4 100644 --- a/dataall_cli/cli.py +++ b/dataall_cli/cli.py @@ -7,6 +7,11 @@ from typing import Any, Dict, List, Optional import click +from dataall_core.auth.oidc_browser_auth import ( + DEFAULT_FALLBACK_REDIRECT_URI, + DEFAULT_REDIRECT_URI, + DEFAULT_SCOPES, +) from dataall_core.dataall_client import DataallClient from dataall_core.profile import CONFIG_PATH @@ -52,9 +57,6 @@ def dataall_cli() -> None: AUTH_TYPES = ["CognitoAuth", "CustomAuth", "OidcBrowserAuth"] -DEFAULT_REDIRECT_URI = "http://localhost:8765/callback" -DEFAULT_FALLBACK_REDIRECT_URI = "http://localhost:8766/callback" -DEFAULT_SCOPES = "openid offline_access" DISCOVERED = "dataall_discovered" DISCOVERED_FOR = "dataall_discovered_for" diff --git a/dataall_cli/utils/__init__.py b/dataall_cli/utils/__init__.py index 12324e7..767629e 100644 --- a/dataall_cli/utils/__init__.py +++ b/dataall_cli/utils/__init__.py @@ -1,6 +1,7 @@ """data.all cli utils.""" +from dataall_core.discovery import discover_from_frontend, frontend_origin + from .config import load_config, save_config -from .discovery import discover_from_frontend, frontend_origin __all__ = ["discover_from_frontend", "frontend_origin", "load_config", "save_config"] diff --git a/dataall_cli/utils/discovery.py b/dataall_cli/utils/discovery.py deleted file mode 100644 index b623a52..0000000 --- a/dataall_cli/utils/discovery.py +++ /dev/null @@ -1,54 +0,0 @@ -"""Discover CLI settings from a deployed data.all front page.""" - -import re -from typing import Dict -from urllib.parse import urljoin, urlparse - -import httpx - -BUNDLE_PATTERN = re.compile(r'src="([^"]*static/js/main\.[^"]+\.js)"') -VALUE_PATTERN = re.compile(r'(REACT_APP_[A-Z_]+):"([^"]*)"') -API_SUFFIX = "/graphql/api" - - -def frontend_origin(dataall_url: str) -> str: - """Return ``scheme://host`` of a data.all URL.""" - parsed = urlparse(dataall_url) - return f"{parsed.scheme}://{parsed.netloc}" - - -def discover_from_frontend(dataall_url: str) -> Dict[str, str]: - """Read the auth type, identity provider, client id and API endpoint from the front page bundle. - - Returns ``frontend_url`` plus whichever values were found. - """ - found = {"frontend_url": frontend_origin(dataall_url)} - base = dataall_url.rstrip("/") + "/" - index = httpx.get(base, follow_redirects=True, timeout=30) - index.raise_for_status() - match = BUNDLE_PATTERN.search(index.text) - if not match: - return found - bundle = httpx.get(urljoin(base, match.group(1)), follow_redirects=True, timeout=60) - bundle.raise_for_status() - values = dict(VALUE_PATTERN.findall(bundle.text)) - - if values.get("REACT_APP_CUSTOM_AUTH") and values.get("REACT_APP_CUSTOM_AUTH_URL"): - found["auth_type"] = "OidcBrowserAuth" - found["idp_domain_url"] = values["REACT_APP_CUSTOM_AUTH_URL"] - if values.get("REACT_APP_CUSTOM_AUTH_CLIENT_ID"): - found["client_id"] = values["REACT_APP_CUSTOM_AUTH_CLIENT_ID"] - elif values.get("REACT_APP_COGNITO_APP_CLIENT_ID"): - found["auth_type"] = "CognitoAuth" - found["client_id"] = values["REACT_APP_COGNITO_APP_CLIENT_ID"] - domain = values.get("REACT_APP_COGNITO_DOMAIN", "") - if domain: - found["idp_domain_url"] = domain if "://" in domain else f"https://{domain}" - if values.get("REACT_APP_COGNITO_REDIRECT_SIGNIN"): - found["redirect_uri"] = values["REACT_APP_COGNITO_REDIRECT_SIGNIN"] - api = values.get("REACT_APP_GRAPHQL_API", "") - if api: - found["api_endpoint_url"] = ( - api[: -len(API_SUFFIX)] if api.endswith(API_SUFFIX) else api - ) - return found diff --git a/pyproject.toml b/pyproject.toml index 66ee184..f18ec39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "dataall-cli" -version = "0.5.0" +version = "0.6.0" description = "AWS data.all CLI" authors = [{ name = "Amazon Web Services" }] license = { text = "Apache License 2.0" } @@ -22,7 +22,7 @@ dependencies = [ "atomicfile>=1.0.1", "PyYAML>=6.0.1", "setuptools; python_version >= '3.12'", - "dataall-core>=0.5.0,<0.6.0", + "dataall-core>=0.6.0,<0.7.0", ] [project.scripts] diff --git a/tests/unit/test_discovery.py b/tests/unit/test_discovery.py deleted file mode 100644 index 9021aad..0000000 --- a/tests/unit/test_discovery.py +++ /dev/null @@ -1,93 +0,0 @@ -import httpx -import pytest - -from dataall_cli.utils import discover_from_frontend, frontend_origin - -FRONT = "https://dataall.example.com" -INDEX = ( - "data.all" - '' - '
' -) -OIDC_BUNDLE = ( - 'REACT_APP_GRAPHQL_API:"https://api.example.com/prod/graphql/api",' - 'REACT_APP_CUSTOM_AUTH:"okta",' - 'REACT_APP_CUSTOM_AUTH_URL:"https://idp.example.com/oauth2/aus1",' - 'REACT_APP_CUSTOM_AUTH_CLIENT_ID:"0oaCLIENT",' - 'REACT_APP_CUSTOM_AUTH_SCOPES:"openid"' -) -COGNITO_BUNDLE = ( - 'REACT_APP_GRAPHQL_API:"https://api.example.com/prod/graphql/api",' - 'REACT_APP_COGNITO_USER_POOL_ID:"us-east-1_abc",' - 'REACT_APP_COGNITO_APP_CLIENT_ID:"cognitoclient",' - 'REACT_APP_COGNITO_DOMAIN:"dataall-dev.auth.us-east-1.amazoncognito.com",' - 'REACT_APP_COGNITO_REDIRECT_SIGNIN:"https://dataall.example.com",' - 'REACT_APP_COGNITO_REDIRECT_SIGNOUT:"https://dataall.example.com"' -) - - -def serve(mocker, pages): - def fake_get(url, **kwargs): - status, text = pages.get(url, (404, "")) - return httpx.Response(status, text=text, request=httpx.Request("GET", url)) - - mocker.patch("dataall_cli.utils.discovery.httpx.get", side_effect=fake_get) - - -def pages(bundle): - return { - f"{FRONT}/": (200, INDEX), - f"{FRONT}/static/js/main.aaa1de7c.js": (200, bundle), - } - - -def test_discover_oidc_deployment(mocker): - serve(mocker, pages(OIDC_BUNDLE)) - assert discover_from_frontend(FRONT) == { - "frontend_url": FRONT, - "auth_type": "OidcBrowserAuth", - "idp_domain_url": "https://idp.example.com/oauth2/aus1", - "client_id": "0oaCLIENT", - "api_endpoint_url": "https://api.example.com/prod", - } - - -def test_discover_cognito_deployment(mocker): - serve(mocker, pages(COGNITO_BUNDLE)) - assert discover_from_frontend(f"{FRONT}/") == { - "frontend_url": FRONT, - "auth_type": "CognitoAuth", - "client_id": "cognitoclient", - "idp_domain_url": "https://dataall-dev.auth.us-east-1.amazoncognito.com", - "redirect_uri": "https://dataall.example.com", - "api_endpoint_url": "https://api.example.com/prod", - } - - -def test_discover_partial_bundle(mocker): - serve( - mocker, - pages( - 'REACT_APP_CUSTOM_AUTH:"okta",REACT_APP_CUSTOM_AUTH_URL:"https://idp.example.com/oauth2/aus1"' - ), - ) - assert discover_from_frontend(FRONT) == { - "frontend_url": FRONT, - "auth_type": "OidcBrowserAuth", - "idp_domain_url": "https://idp.example.com/oauth2/aus1", - } - - -def test_discover_without_bundle(mocker): - serve(mocker, {f"{FRONT}/": (200, "maintenance")}) - assert discover_from_frontend(FRONT) == {"frontend_url": FRONT} - - -def test_discover_http_error(mocker): - serve(mocker, {}) - with pytest.raises(httpx.HTTPStatusError): - discover_from_frontend(FRONT) - - -def test_frontend_origin(): - assert frontend_origin("https://dataall.example.com/console/") == FRONT From 8c6d30f2a7da62f2622d7a9e578026b161807cbe Mon Sep 17 00:00:00 2001 From: Tejas Rajopadhye <71188245+TejasRGitHub@users.noreply.github.com> Date: Fri, 25 Sep 2026 12:00:01 -0500 Subject: [PATCH 2/2] Lock dataall-core 0.6.0 Co-Authored-By: Claude Fable 5.1 --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 50597e7..95edd4d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1408,14 +1408,14 @@ test-randomorder = ["pytest-randomly"] [[package]] name = "dataall-core" -version = "0.5.0" +version = "0.6.0" description = "AWS data.all core" optional = false python-versions = "<4.0,>=3.9" groups = ["main"] files = [ - {file = "dataall_core-0.5.0-py3-none-any.whl", hash = "sha256:5edf4c7d2a0f0d8f176e232a8cb7c4020aa1a736456d33a30858f3a20335c40e"}, - {file = "dataall_core-0.5.0.tar.gz", hash = "sha256:2b9ee04bb2c84547e1d87aa83947e259131ac558013751a2aad0473facfa3736"}, + {file = "dataall_core-0.6.0-py3-none-any.whl", hash = "sha256:9ef1d560c4aea12e583e80b8b53d53f204edb14b5605db3f53f15cf10008ee98"}, + {file = "dataall_core-0.6.0.tar.gz", hash = "sha256:63e9c44b9c7ea2e8101cf9d3a10dc02bcf0cb83e9f031f79c268ff18403f820f"}, ] [package.dependencies] @@ -4991,4 +4991,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.9,<4.0" -content-hash = "02be3fe6cdd26745c036208f8973c9822282fb32d4a4c82c0c223ddecb8909d0" +content-hash = "f50f7e0561008664d95a17129319788a06db0c0011aa0ef57382e8c871d0b094"