altasigma 3.18.0__tar.gz → 3.19.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {altasigma-3.18.0/altasigma.egg-info → altasigma-3.19.0.dev1}/PKG-INFO +1 -1
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/__init__.py +2 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/credentials/credential_utils.py +66 -5
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/git_helper.py +3 -2
- {altasigma-3.18.0 → altasigma-3.19.0.dev1/altasigma.egg-info}/PKG-INFO +1 -1
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/setup.py +1 -1
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/LICENSE +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/MANIFEST.in +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/README_pypi.md +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/config/__init__.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/config/config.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/config/http_session.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/credentials/__init__.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/credentials/token_refresher.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/initialize.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/io/__init__.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/io/augurdata.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/io/data_management.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/io/files.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/io/inputs.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/io/outputs.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/io/shared.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/__init__.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/job_supervisor_abstract.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/job_supervisor_dev_mock.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/job_supervisor_helpers.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/job_supervisor_http.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/reports.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/progress_reporter/__init__.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/progress_reporter/progress_reporter.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/py.typed +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/spark_session/__init__.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/spark_session/spark_session_util.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/utils/__init__.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/utils/notebook.py +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma.egg-info/SOURCES.txt +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma.egg-info/dependency_links.txt +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma.egg-info/entry_points.txt +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma.egg-info/not-zip-safe +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma.egg-info/requires.txt +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma.egg-info/top_level.txt +0 -0
- {altasigma-3.18.0 → altasigma-3.19.0.dev1}/setup.cfg +0 -0
|
@@ -35,6 +35,7 @@ from altasigma.credentials.credential_utils import (
|
|
|
35
35
|
TokenSidecarDenied,
|
|
36
36
|
TokenSidecarError,
|
|
37
37
|
TokenSidecarUnavailable,
|
|
38
|
+
get_access_token,
|
|
38
39
|
)
|
|
39
40
|
from altasigma.initialize import AltaSigma, initialize
|
|
40
41
|
from altasigma.io import inputs, outputs
|
|
@@ -78,6 +79,7 @@ __all__ = [
|
|
|
78
79
|
"TokenSidecarError",
|
|
79
80
|
"TokenSidecarUnavailable",
|
|
80
81
|
"dataframe_to_table_report_data",
|
|
82
|
+
"get_access_token",
|
|
81
83
|
"get_datasource",
|
|
82
84
|
"initialize",
|
|
83
85
|
"inputs",
|
|
@@ -416,11 +416,13 @@ def _fetch_git_credentials(host_url: str, access_token: str) -> tuple[str, str]:
|
|
|
416
416
|
raise ReauthRequired(response.json()["details"]["authorizeUrl"])
|
|
417
417
|
|
|
418
418
|
if response.status_code == 200:
|
|
419
|
-
#
|
|
420
|
-
#
|
|
421
|
-
#
|
|
422
|
-
#
|
|
423
|
-
|
|
419
|
+
# The token goes in the password field. The dashboard also returns the
|
|
420
|
+
# git server username behind the grant when it knows it - forward it as
|
|
421
|
+
# the Basic-auth user (required convention on Bitbucket; any non-empty
|
|
422
|
+
# username works on Gitea). Fall back to a placeholder for older
|
|
423
|
+
# dashboards or when the dashboard could not resolve the username.
|
|
424
|
+
data = response.json()
|
|
425
|
+
return data.get("username") or "oauth2", data["accessToken"]
|
|
424
426
|
|
|
425
427
|
raise Exception(
|
|
426
428
|
f"ERROR: Unexpected response from dashboard: {response.status_code}, {response.text}")
|
|
@@ -580,6 +582,12 @@ class CredentialUtils:
|
|
|
580
582
|
"""
|
|
581
583
|
Refresh an existing authentication token.
|
|
582
584
|
|
|
585
|
+
Called from outside this package as well: dashboard versions that predate the
|
|
586
|
+
token sidecar substitute a refresh token into the Python snippet code they
|
|
587
|
+
generate, and that generated code calls this method directly. Those call sites
|
|
588
|
+
live in user code on installations that were never upgraded, so no search of
|
|
589
|
+
this repository finds them.
|
|
590
|
+
|
|
583
591
|
Uses the refresh token to obtain a new access token and refresh token pair
|
|
584
592
|
from the authentication server.
|
|
585
593
|
|
|
@@ -906,3 +914,56 @@ def _credential_utils():
|
|
|
906
914
|
else:
|
|
907
915
|
_credential_utils_instance = CredentialUtils()
|
|
908
916
|
return _credential_utils_instance
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
def get_access_token() -> str:
|
|
920
|
+
"""Return the access token for the current user.
|
|
921
|
+
|
|
922
|
+
The token authenticates requests against AltaSigma APIs on behalf of the user
|
|
923
|
+
the current job or workbench belongs to. It is short-lived and is renewed
|
|
924
|
+
elsewhere, so callers request one when they need it and neither cache nor
|
|
925
|
+
persist the value.
|
|
926
|
+
|
|
927
|
+
Returns:
|
|
928
|
+
str: The access token, to be sent as ``Authorization: Bearer <token>``.
|
|
929
|
+
|
|
930
|
+
Raises:
|
|
931
|
+
TokenSidecarUnavailable: If no token could be obtained for a reason that says
|
|
932
|
+
nothing about this user -- the service could not be reached, did not
|
|
933
|
+
answer in time, reported that it could not reach what it needs upstream,
|
|
934
|
+
or reported an error in a way that could not be understood. Retrying
|
|
935
|
+
later is the sensible response. Subclass of ``TokenSidecarError``.
|
|
936
|
+
TokenSidecarDenied: If the token service answered with a coded refusal that
|
|
937
|
+
will not change by retrying. A refusal concerning this user is the
|
|
938
|
+
typical case, but any coded terminal answer other than an upstream
|
|
939
|
+
failure is reported this way, so read the code rather than assuming the
|
|
940
|
+
user was rejected. Subclass of ``TokenSidecarError``.
|
|
941
|
+
TokenSidecarError: If a token service is in use and the token could not be
|
|
942
|
+
obtained for any other reason. Catch this one to catch all three.
|
|
943
|
+
KeyError: If ``HOST_URL`` is unset. This one applies everywhere, because it
|
|
944
|
+
is read when the credential handling is initialised -- before any of the
|
|
945
|
+
paths below is chosen -- on the first call that does so rather than on
|
|
946
|
+
every call. A ``KeyError`` can also arrive from those paths naming
|
|
947
|
+
something else, so read the missing name off the exception.
|
|
948
|
+
|
|
949
|
+
Note:
|
|
950
|
+
Apart from the ``KeyError`` above, only the ``TokenSidecar*`` exceptions are
|
|
951
|
+
a contract. They apply where a token service provides the token, which is
|
|
952
|
+
every installation running one.
|
|
953
|
+
Where none is present the token is obtained by other means, and a failure
|
|
954
|
+
then surfaces as whatever those paths raise: the types are unspecified,
|
|
955
|
+
they are not limited to the ones above, and the same type can arrive for an
|
|
956
|
+
unrelated reason.
|
|
957
|
+
|
|
958
|
+
Two further properties of that case are worth knowing before calling this
|
|
959
|
+
in a loop. Where a stored credential is available, each call spends a full
|
|
960
|
+
token refresh on it rather than reading a cached value, so asking for a
|
|
961
|
+
token per use is cheaper where a token service is present than where it is
|
|
962
|
+
not. Where none is available, the call may instead fall back to an
|
|
963
|
+
interactive authorisation flow: it then prints a URL and waits until the
|
|
964
|
+
user has confirmed access there, rather than returning promptly.
|
|
965
|
+
|
|
966
|
+
Where a token service is present but still starting up, a single call can
|
|
967
|
+
wait up to about two minutes before raising.
|
|
968
|
+
"""
|
|
969
|
+
return _credential_utils()._existing_token()
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Git credential helper for the AltaSigma workbench.
|
|
3
3
|
|
|
4
4
|
Implements the git-credential-helper protocol (see `gitcredentials(7)`) so that
|
|
5
|
-
git can authenticate against
|
|
6
|
-
demand from the
|
|
5
|
+
git can authenticate against the git host of the AltaSigma installation — whichever
|
|
6
|
+
provider it is backed by — using per-user credentials fetched on demand from the
|
|
7
|
+
AltaSigma dashboard.
|
|
7
8
|
|
|
8
9
|
Installed as the console script `git-credential-altasigma`. Once a user runs
|
|
9
10
|
`git config credential.helper altasigma`, git will resolve that to this script
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/job_supervisor_abstract.py
RENAMED
|
File without changes
|
{altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/job_supervisor_dev_mock.py
RENAMED
|
File without changes
|
{altasigma-3.18.0 → altasigma-3.19.0.dev1}/altasigma/jobsupervisor/job_supervisor_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|