-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add us-west-2 check to API and improve auth repr #424
base: main
Are you sure you want to change the base?
Conversation
We can probably change the print statement to raise a ValueError with the same message. That way, it is a formal error message that will interrupt the library from opening the bucket out-of-region with a long, cryptic error message. |
Thanks to @battistowx during today's earthaccess cowork session for moving this forward with me! @andypbarrett @betolink Any thoughts on what info we want to be in the auth repr? I'm happy to move that to a separate PR if we want to move forward with the s3check portion of this one. |
"login", | ||
"search_datasets", | ||
"search_data", | ||
"get_requests_https_session", | ||
"get_fsspec_https_session", | ||
"get_s3fs_session", | ||
"get_s3_credentials", | ||
"granule_query", | ||
"get_edl_token" "granule_query", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning: these strings will concatenate :)
def __repr__(self) -> str: | ||
print_str = "Authentication Info\n" + "-------------------\n" | ||
for k, v in self.auth_info.items(): | ||
print_str += str("{}: {}\n".format(k, v)) | ||
|
||
return print_str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly discourage this implementation of __repr__
for at least 2 reasons:
- (minor) this is arguably an "abuse" of
__repr__
, which should generally be: "If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment)." (see https://docs.python.org/3/reference/datamodel.html#object.__repr__) - (very important) this can lead to inadvertent leaking of the user's token(s) during logging since
auth_info
includes those tokens
Per #231, we've added API access to
store._running_in_us_west_2()
in the form of a printed statement that the user is (or is not) running in AWS region us-west-2. In the process of implementing this, it became clear thatget_edl_token()
had not been added to__init__.py
, so that was added as well. It also adds a repr for theauth
object via aauth.auth_info()
property.I'm seeking input on:
earthaccess.region()
function instead.auth.__repr__
? Currently it's not much better than the object ID:store._running_in_us_west_2()
isn't tested. Shouldauth.auth_info()
have a dictionary typing/keyword matching test?