Skip to content
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

Support for GDAL related assets #218

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ahuarte47
Copy link

This PR implements #217

It provides support for loading assets from GDAL Virtual File Systems keys.

@Samweli Samweli closed this Sep 23, 2022
@Samweli Samweli reopened this Sep 23, 2022
@@ -412,6 +412,18 @@ def sign_asset_href(self, asset_href):
signed_href = pc.sign(asset_href)
return signed_href

if asset_href.startswith("s3://"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahuarte47 can you put the code for with the new changes into its own function the sign_asset_href method is for signing planetary computer SAS based items hrefs with a SAS token.

Copy link
Author

@ahuarte47 ahuarte47 Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not the generation of signed urls the purpose of sign_asset_href? IMHO this function can manage all cases without modifying the current behavior or the existence of new future sign methods. Do you agree? Just chaning the description of the method?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make another function for the new changes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Samweli can't really understand. The plugin and the sign method are not named as microsoft or planetarycomputer dependent => because the plugin is a Common, have to be and remain general.

sign_asset_href is a enough general name that can refer to the signing action that is common to any cloud resource not only that from microsoft services.

In resume, what is the rationale to move a sign feature for only GC or AWS to a different method respect signing of microsoft cloud?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahuarte47 @luipir I prefer to have another function for the new changes, at some point I ll also rename the current sign_asset_href to a more specific PC related name.

Copy link
Collaborator

@Samweli Samweli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahuarte47 I tried your approach with a couple of STAC catalogs that use AWS S3 service for item assets hrefs but couldn't make them work. What catalogs are you using to test this functionality?

@@ -412,6 +412,18 @@ def sign_asset_href(self, asset_href):
signed_href = pc.sign(asset_href)
return signed_href

if asset_href.startswith("s3://"):
signed_href = gdal.GetSignedURL(f"/vsis3/{asset_href[5:]}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find documentation for the GetSignedURL https://gdal.org/api/python/osgeo.gdal.html?highlight=getsigned#osgeo.gdal.GetSignedURL, can you explain what it tries to achieve?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gdal.GetSignedURL tranforms a GDAL virtual file system path to one https signed url. Depending on the virtual file system type, GDAL reads its specific authentication settings from environment variables. This is an example:
https://github.com/OSGeo/gdal/blob/master/autotest/gcore/vsioss.py#L185

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"A signed URL is a URL that provides limited permission and time to make a request. Signed URLs contain authentication information in their query string, allowing users without credentials to perform specific actions on a resource" from https://cloud.google.com/storage/docs/access-control/signed-urls

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, GDAL reads several environment variables (AWS_NO_SIGN_REQUEST, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN...) to create the signed url. It is very useful custom way to auhenticate, apart from using the UI of authentication that your plugin provides.

Copy link
Author

@ahuarte47 ahuarte47 Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Samweli you can use the Collection Digital Earth Africa - s2l2a in the predefined Catalog. Before, You have to define this environment variable AWS_NO_SIGN_REQUEST=YES. Using gdal 3.5.1 it works.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these new changes will not work without user having to define the environment variable AWS_NO_SIGN_REQUEST?

Copy link
Author

@ahuarte47 ahuarte47 Oct 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. For other use cases, credentials will be configured defining AWS_PROFILE or AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY. It depends on how the STAC Catalog is deployed in the cloud-provider.

@ahuarte47
Copy link
Author

ahuarte47 commented Sep 23, 2022

Hi @Samweli I have uploaded more changes. I have noticed that original asset.href attribute is changed when the plugin wants to load the asset. if the authentication expires in a short time next invocations to load the asset again will fail.

@ahuarte47
Copy link
Author

Hi @Samweli do you need more info about last changes? Can I help with anything to get this PR merged? Thanks!!

@luipir
Copy link

luipir commented Oct 5, 2022

Any feedback @Samweli how to proceed ?

@Samweli
Copy link
Collaborator

Samweli commented Oct 5, 2022

Any feedback @Samweli how to proceed ?

@luipir I ll take a look at the new changes and get back to you guys later, Apologies for a slow reply, We currently don't have enough time to work on support and maintenance.

@Samweli
Copy link
Collaborator

Samweli commented Oct 12, 2022

Any feedback @Samweli how to proceed ?

@luipir @ahuarte47 I have added new comments on the review suggestions, In general I like these new changes to be implemented in a separate function, as I have plans to update the sign_asset_href in the future.

@luipir
Copy link

luipir commented Oct 12, 2022

@Samweli reasonable your proposed changes if you are planning to move the code to be more agnostic an not only PC oriented :)

@Samweli
Copy link
Collaborator

Samweli commented Oct 12, 2022

@Samweli reasonable your proposed changes if you are planning to move the code to be more agnostic an not only PC oriented :)

yes @luipir in the future we ll have a sign_asset_href that will support all the url sign based operations.

@luipir
Copy link

luipir commented Nov 9, 2022

please @Samweli give us a feedback regarding latest modification done by @ahuarte47, thank you

@remicres
Copy link

remicres commented Mar 3, 2023

Just gave a try with private S3 endpoint: it is working great.

The only cumbersome thing is to define the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_S3_ENDPOINT environment variables

@remicres
Copy link

remicres commented Mar 3, 2023

Just saw that GDAL GetSignedURL() returns an URL valid only for 1 hour (however that is not related to this PR)

@slesaad
Copy link

slesaad commented Sep 15, 2023

Any updates on when this PR will be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants