Skip to content

Commit b04221a

Browse files
committed
Debugging authentications
1 parent bd08c60 commit b04221a

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

zstash/globus.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from .settings import logger
1515
from .utils import GlobusInfo, ts_utc
1616

17+
ZSTASH_CLIENT_ID = "6c1629cf-446c-49e7-af95-323c6412397f"
18+
1719
HPSS_ENDPOINT_MAP = {
1820
"ALCF": "de463ec4-6d04-11e5-ba46-22000b92c6ec",
1921
"NERSC": "9cd89cfd-6d04-11e5-ba46-22000b92c6ec",
@@ -30,10 +32,43 @@
3032
r"perlmutter.*\.nersc\.gov": "6bdc7956-fc0f-4ad2-989c-7aa5ee643a79",
3133
}
3234

35+
# Last updated 2025-04-08
36+
ENDPOINT_TO_NAME_MAP = {
37+
"08925f04-569f-11e7-bef8-22000b9a448b": "Invalid, presumably Theta",
38+
"15288284-7006-4041-ba1a-6b52501e49f1": "LCRC Improv DTN",
39+
"68fbd2fa-83d7-11e9-8e63-029d279f7e24": "pic#compty-dtn",
40+
"6bdc7956-fc0f-4ad2-989c-7aa5ee643a79": "NERSC Perlmutter",
41+
"6c54cade-bde5-45c1-bdea-f4bd71dba2cc": "Globus Tutorial Collection 1", # The Unit test endpoint
42+
"9cd89cfd-6d04-11e5-ba46-22000b92c6ec": "NERSC HPSS",
43+
"de463ec4-6d04-11e5-ba46-22000b92c6ec": "Invalid, presumably ALCF HPSS",
44+
}
45+
46+
47+
def ep_to_name(endpoint_id: str) -> str:
48+
if endpoint_id in ENDPOINT_TO_NAME_MAP:
49+
return ENDPOINT_TO_NAME_MAP[endpoint_id]
50+
else:
51+
return endpoint_id # Just use the endpoint_id itself
52+
53+
54+
def log_current_endpoints(globus_info: GlobusInfo):
55+
if globus_info.local_endpoint:
56+
local = ep_to_name(globus_info.local_endpoint)
57+
else:
58+
local = "undefined"
59+
logger.debug(f"local endpoint={local}")
60+
if globus_info.remote_endpoint:
61+
remote = ep_to_name(globus_info.remote_endpoint)
62+
else:
63+
remote = "undefined"
64+
logger.debug(f"remote endpoint={remote}")
65+
3366

3467
def check_endpoint_version_5(globus_info: GlobusInfo, ep_id):
3568
if not globus_info.transfer_client:
3669
raise ValueError("transfer_client is undefined")
70+
log_current_endpoints(globus_info)
71+
logger.debug(f"check_endpoint_version_5. endpoint={ep_to_name(ep_id)}")
3772
output = globus_info.transfer_client.get_endpoint(ep_id)
3873
version = output.get("gcs_version", "0.0")
3974
if output["gcs_version"] is None:
@@ -55,8 +90,10 @@ def submit_transfer_with_checks(globus_info: GlobusInfo):
5590
if check_endpoint_version_5(globus_info, ep_id):
5691
scopes += f" *https://auth.globus.org/scopes/{ep_id}/data_access"
5792
scopes += " ]"
58-
native_client = NativeClient(
59-
client_id="6c1629cf-446c-49e7-af95-323c6412397f", app_name="Zstash"
93+
native_client = NativeClient(client_id=ZSTASH_CLIENT_ID, app_name="Zstash")
94+
log_current_endpoints(globus_info)
95+
logger.debug(
96+
"submit_transfer_with_checks. Calling login, which may print 'Please Paste your Auth Code Below:'"
6097
)
6198
native_client.login(requested_scopes=scopes)
6299
# Quit here and tell user to re-try
@@ -130,15 +167,25 @@ def globus_activate(globus_info: GlobusInfo, alt_hpss: str = ""):
130167
)
131168

132169
native_client = NativeClient(
133-
client_id="6c1629cf-446c-49e7-af95-323c6412397f",
170+
client_id=ZSTASH_CLIENT_ID,
134171
app_name="Zstash",
135172
default_scopes="openid urn:globus:auth:scope:transfer.api.globus.org:all",
136173
)
174+
log_current_endpoints(globus_info)
175+
logger.debug(
176+
"globus_activate. Calling login, which may print 'Please Paste your Auth Code Below:'"
177+
)
137178
native_client.login(no_local_server=True, refresh_tokens=True)
138179
transfer_authorizer = native_client.get_authorizers().get("transfer.api.globus.org")
139180
globus_info.transfer_client = TransferClient(authorizer=transfer_authorizer)
140181

182+
log_current_endpoints(globus_info)
141183
for ep_id in [globus_info.local_endpoint, globus_info.remote_endpoint]:
184+
if ep_id:
185+
ep_name = ep_to_name(ep_id)
186+
else:
187+
ep_name = "undefined"
188+
logger.debug(f"globus_activate. endpoint={ep_name}")
142189
r = globus_info.transfer_client.endpoint_autoactivate(ep_id, if_expires_in=600)
143190
if r.get("code") == "AutoActivationFailed":
144191
logger.error(

0 commit comments

Comments
 (0)