-
Notifications
You must be signed in to change notification settings - Fork 8
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
User-supplied credential callback #234
base: main
Are you sure you want to change the base?
Conversation
NASA earthdata also has a time limit on its S3 credentials. cc @chuckwondo maybe we can figure out a good example there (although those credentials are only valid for same-region requests IIRC) |
Sure, let me pull from something I experimented with a while back. |
@chuckwondo in I created #271 , where we can discuss Earthdata specifically more. |
"""Request updated credentials.""" | ||
resp = self.session.get(CREDENTIALS_API, allow_redirects=True, timeout=15) | ||
auth_resp = self.session.get(resp.url, allow_redirects=True, timeout=15) | ||
creds = auth_resp.json() |
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 don't think we should be using this as an example for 2 reasons:
- The session is never closed
- It is insecure because you're leaking EDL creds to the CREDENTIALS_API. The EDL creds should be supplied only to the URS (Earthdata Login) URL.
Although your original implementation is more verbose, it is secure, and does not leave dangling resources. (There's no strong motivation for using a session since auth occurs no more than once an hour, or more likely, only once it total for most use cases.)
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.
The original implementation didn't work, see #271 (comment). I'm not sure why it didn't work; the current implementation was suggested by Aimee in #271, and appears to be what the earthaccess
Python package is using.
Using a session seemed to make it easier to automatically manage cookies between the two requests, but it's not a requirement for me. In the async case I add a close()
method to the credential provider and document that it should be called after all obstore use has finished.
Perhaps this isn't a great use for an example, and we should find something simpler for the docs.
There's a myriad number of ways to handle credentials for each of these stores, and I don't want to be implementing every last one of these. Luckily,
object_store
allows for external credential providers, and we can allow users to implement their own totally custom authentication in Python!This is a proof of concept that is tested as working with both a synchronous or asynchronous credential provider! Here are a couple examples:
Notes:
credential_provider
toobstore.store.from_url
TokenCache
Expose fromobstore.store.google.auth
instead ofobstore.google.auth
?obstore.auth
, which is a module we can keep expanding. Soobstore.auth.earthdata
,obstore.auth.google
,obstore.auth.boto3
,AuthProvider
vsCredentialProvider
? Shorter might be better.Closes #232, closes #269