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

API Sign: Change the S3 Provider into a signer #1698

Merged
merged 20 commits into from
Nov 18, 2024

Conversation

AlexanderGeere
Copy link
Contributor

Description

Provides an api endpoint api/sign/s3 Which returns a signed URL.

GitHub Issue

#1607

Type of Change

  • ✅ New feature (non-breaking change which adds functionality)
  • ✅ Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • ✅ Documentation

How have you tested this?

Tested with bugs_testing/sign/s3_workspace.json

Testing Checklist

  • ✅ Existing Tests still pass
  • ✅ Ran locally on my machine

Code Quality Checklist

  • ✅ My code follows the guidelines of XYZ
  • ✅ My code has been commented
  • ✅ Documentation has been updated
  • ✅ New and existing unit tests pass locally with my changes
  • ✅ Main has been merged into this PR

@AlexanderGeere AlexanderGeere added Feature New feature requests or changes to the behaviour or look of existing application features. Code Issues related to the code structure and performance. v4.13.0 labels Nov 12, 2024
@AlexanderGeere AlexanderGeere self-assigned this Nov 12, 2024
@AlexanderGeere AlexanderGeere linked an issue Nov 12, 2024 that may be closed by this pull request
@AlexanderGeere AlexanderGeere marked this pull request as ready for review November 12, 2024 08:26
mod/sign/s3.js Outdated Show resolved Hide resolved
mod/provider/s3.js Show resolved Hide resolved
Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

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

The S3 library should be installed as an optional dependency. The module should export null if the dependency is not available using npm install --no-optional.

@dbauszus-glx
Copy link
Member

How are requests handled where signing fails? eg. missing resource, missing credentials.

@AlexanderGeere
Copy link
Contributor Author

AlexanderGeere commented Nov 13, 2024

@dbauszus-glx

How are requests handled where signing fails? eg. missing resource, missing credentials.

Signing will always succeed even if the credentials are wrong, calling the signed url will return a 403.

mod/sign/s3.js Outdated
getSignedUrl;

//Check for credentials
if (!process.env?.AWS_S3_CLIENT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we handle public buckets that don't require any credentials?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll test what happens with public buckets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Public buckets can just be hit on the url. 7071f1b provides a function that returns the public url if no credentials are supplied

@dbauszus-glx
Copy link
Member

I don't understand this bit. Can you comment on this for me to test.

  if (provider[req.params.provider]?.deprecated){
    return await provider[req.params.provider].fn(req, res)
  }

@dbauszus-glx
Copy link
Member

I added S3 to requires of the sign module and updated the docs in regards to exports null from signer modules. 90bc15e

@dbauszus-glx
Copy link
Member

I have updated the S3 module docs with reference to the credentials required from AWS and optional dependencies.

image

@AlexanderGeere
Copy link
Contributor Author

I don't understand this bit. Can you comment on this for me to test.

  if (provider[req.params.provider]?.deprecated){
    return await provider[req.params.provider].fn(req, res)
  }

@dbauszus-glx Turns out this is no longer necessary

@dbauszus-glx
Copy link
Member

@AlexanderGeere

The s3_provider doesn't have to be async or deprecated. We can just require the s3_signer and exports null or s3_provider dependent on the avilability of the s3 signer.

2a85231

The idea is that eventually the s3 provider will sign a request and return the payload as this might be used inside the process. ie the workspace could be stored in an s3 bucket.

For now the s3_provider works exactly as the s3 signer.

@AlexanderGeere
Copy link
Contributor Author

@RobAndrewHurst After a quick chat with @dbauszus-glx public url are not signed so these should just be handled in the plugin. Could Maybe do a public: true or similar

@RobAndrewHurst
Copy link
Contributor

Happy with that! :)

@dbauszus-glx
Copy link
Member

dbauszus-glx commented Nov 14, 2024

I bumped the optional dependencies to their current versions 3.691.0

AWS recommends to use ListObjectsV2Command in development. The ListObjectsCommand is only kept for legacy purposes.

I also changed the s3 signer to return the signed URL as a text which it is.

@dbauszus-glx
Copy link
Member

Rather than providing command maps, and action dictionaries to translate commands and properties back and forth it will be much easier to talk directly with the SDK using the commands as documented in the S3 documentation.

9cce4f1

Copy link
Contributor

@RobAndrewHurst RobAndrewHurst left a comment

Choose a reason for hiding this comment

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

Nice I am happy with this!

I added in a note for developers that they must not use this sign if they are interacting with a public bucket, and gave them an example of how they could use it.

@simon-leech simon-leech removed their request for review November 15, 2024 17:15
@simon-leech
Copy link
Contributor

Don't feel like I'm best placed to review this one so removed my request. If you two @dbauszus-glx and @RobAndrewHurst are happy, that's great with me!

@RobAndrewHurst RobAndrewHurst merged commit dc83deb into GEOLYTIX:minor Nov 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Issues related to the code structure and performance. Feature New feature requests or changes to the behaviour or look of existing application features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

S3 provider/signing module
4 participants