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

Beginnings of S3 request proxying #11

Merged
merged 2 commits into from
May 23, 2024
Merged

Conversation

Randgalt
Copy link
Member

@Randgalt Randgalt commented May 16, 2024

See ReadMe for details: https://github.com/trinodb/s3-proxy/blob/jordanz/initial-proxied-request/README.md

E.g.

~/dev/starburst/trino-s3-proxy (jordanz/initial-proxied-request)$ aws --endpoint-url http://localhost:53893/api/v1/s3Proxy/s3 s3 ls s3://galaxy-cur/     
                           PRE demo/
                           PRE dev/
                           PRE prod/
                           PRE staging/
2024-05-16 11:41:31          4 aws-programmatic-access-test-object

Closes #8
Closes #10

@cla-bot cla-bot bot added the cla-signed label May 16, 2024
@Randgalt Randgalt requested review from dain and vagaerg May 16, 2024 16:02
@Randgalt Randgalt changed the base branch from main to jordanz/initial-s3-rest-endpoint May 16, 2024 16:04
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from 7e98ecf to d7eccf9 Compare May 16, 2024 16:15
@Randgalt Randgalt force-pushed the jordanz/initial-s3-rest-endpoint branch from 56ad313 to 51a21e9 Compare May 16, 2024 16:19
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch 8 times, most recently from 320be0e to 362b3da Compare May 17, 2024 05:36
@Randgalt Randgalt changed the base branch from jordanz/initial-s3-rest-endpoint to main May 17, 2024 05:37
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from 362b3da to 0a76a50 Compare May 17, 2024 05:38
@Randgalt Randgalt changed the base branch from main to jordanz/initial-s3-rest-endpoint May 17, 2024 05:39
@Randgalt Randgalt changed the base branch from jordanz/initial-s3-rest-endpoint to jordanz/initial-minio-signer-import May 17, 2024 06:09
@Randgalt Randgalt force-pushed the jordanz/initial-minio-signer-import branch 2 times, most recently from 3d80dcf to 4245318 Compare May 17, 2024 06:15
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from 0a76a50 to f5dd859 Compare May 17, 2024 06:24
@Randgalt Randgalt force-pushed the jordanz/initial-minio-signer-import branch 2 times, most recently from 44b8194 to d535abb Compare May 17, 2024 08:17
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch 2 times, most recently from 588cd85 to 5d80432 Compare May 17, 2024 08:30
@Randgalt Randgalt requested a review from mosiac1 May 17, 2024 08:31
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch 4 times, most recently from 31cee7d to 3444d91 Compare May 17, 2024 09:02
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from 7dd1e70 to 6dacc83 Compare May 17, 2024 10:30
@Randgalt Randgalt force-pushed the jordanz/initial-minio-signer-import branch 2 times, most recently from 94fa65c to 0287a5f Compare May 19, 2024 12:33
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from 6dacc83 to 0e46571 Compare May 19, 2024 13:13
@Randgalt Randgalt force-pushed the jordanz/initial-minio-signer-import branch from 0287a5f to f61ca24 Compare May 19, 2024 14:05
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from 0e46571 to d617549 Compare May 19, 2024 14:07
@Randgalt Randgalt force-pushed the jordanz/initial-minio-signer-import branch from f61ca24 to ec39d06 Compare May 19, 2024 14:10
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from d617549 to be09fa0 Compare May 19, 2024 14:10
@Randgalt Randgalt force-pushed the jordanz/initial-minio-signer-import branch from ec39d06 to 5787e06 Compare May 20, 2024 08:44
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from be09fa0 to 89953b2 Compare May 20, 2024 08:47
@Randgalt Randgalt force-pushed the jordanz/initial-minio-signer-import branch from 5787e06 to fa2de77 Compare May 20, 2024 14:36
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from 89953b2 to 824bc0c Compare May 20, 2024 14:39
Base automatically changed from jordanz/initial-minio-signer-import to main May 21, 2024 05:43
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch 2 times, most recently from 367da6b to ee3d24d Compare May 21, 2024 05:50
@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch 4 times, most recently from 3497048 to 6af50b0 Compare May 22, 2024 10:57
@@ -36,17 +37,56 @@ public SigningController(CredentialsController credentialsController, SigningCon
maxClockDrift = signingControllerConfig.getMaxClockDrift().toJavaTime();
}

public Optional<SigningMetadata> signingMetadataFromRequest(
Function<Credentials, Credentials.Credential> credentialsSupplier,
Copy link
Member

Choose a reason for hiding this comment

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

I understand that this is to support us obtaining the metadata in the same way whether this is using the emulated access key or the external one. Is the idea that we may want to proxy requests signed with the real access key?

However, we currently never use this argument. Even if we were to use it, we would need to somehow pass it onto isValidAuthorization and we should have a way to retrieve a Credentials pair from a real key in the same way we do for emulated ones right?

Copy link
Member Author

@Randgalt Randgalt May 22, 2024

Choose a reason for hiding this comment

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

Is the idea that we may want to proxy requests signed with the real access key?

We need to sign the real request being sent to AWS (or whatever real object store we're using). The signing mechanism is the same. However, for the real request we must use the real AccessKey/Secret.

However, we currently never use this argument

It's used by TrinoS3ProxyClient. See here: https://github.com/trinodb/s3-proxy/pull/11/files#diff-86567ef27fb9d1f3e89e0d28033e383903d06ae883810cb03d45ca40400bb665R104

Copy link
Member

Choose a reason for hiding this comment

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

It is used for the sign method but not for the signingMetadataFromRequest right? I completely agree with needing this for the sign method, just wondering its purpose for this one

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. signingMetadataFromRequest always uses the emulated credentials. I find it easier to reason about when SigningController is agnostic about which credentials are used. I'd prefer to leave as is unless you feel strongly about it.

Copy link
Member

Choose a reason for hiding this comment

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

SigningController can be agnostic as to what credentials are used, I agree that's good. But this method is taking an argument that is unused, so it is misleading for a caller as it gives the impression you can ask it to use the real credentials, but it won't.

If we want to make it explicit that this method (unlike the others in SigningController) only deals with emulated credentials, should we rename to validateEmulatedCredentialsAndGetMetadata?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK - it's fixed now. PTAL. Thanks for your persistence.

Copy link
Member Author

@Randgalt Randgalt May 23, 2024

Choose a reason for hiding this comment

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

Also, now that I look at it fresh, we can change signRequest() to just take a region and a Credential and not have it take the SigningMetadata. wdyt? However, we may want that metadata object in the future. I'm 50/50

Copy link
Member

Choose a reason for hiding this comment

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

No worries! I originally had this design in mind, but at present there is no way to allow users to pass in Credentials::real to this method (as our credential store doesn't store a mapping from real credential to emulated ones, only the other way around)

However, that is personal preference - and in any case, we could tweak the CredentialsController later if we wanted to make this possible for any reason.

Looks good!

Copy link
Member

Choose a reason for hiding this comment

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

Whoops just saw your last comment. If we did that we'd need to also pass in the session, if any - right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes ^^^ - we should leave it due to that.

@Randgalt Randgalt force-pushed the jordanz/initial-proxied-request branch from 1438e19 to b7caafc Compare May 23, 2024 16:53
Copy link
Member

@vagaerg vagaerg left a comment

Choose a reason for hiding this comment

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

LGTM!

@Randgalt Randgalt merged commit e029ef0 into main May 23, 2024
2 checks passed
@Randgalt Randgalt deleted the jordanz/initial-proxied-request branch May 23, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Create initial proxied request to real S3 Create initial endpoints for S3
2 participants