Skip to content

rgw: handle http options CORS with v4 auth - #52673

Merged
cbodley merged 3 commits into
ceph:mainfrom
tobias-urdin:options-anon-auth-presigned
Aug 21, 2023
Merged

cbodley merged 3 commits into
ceph:mainfrom
tobias-urdin:options-anon-auth-presigned

Conversation

@tobias-urdin

@tobias-urdin tobias-urdin commented Jul 27, 2023 •

Copy link
Copy Markdown
Contributor

If we get a HTTP OPTIONS request we previously always allowed the anonymous engine to handle all the requests even if other auth was given in the request this meant that we couldn't get any context around for example presigned URLs to resolve the a "tenanted" bucket.

This changes so that the S3AnonymousEngine only handles OPTIONS requests that does not contain any authentication. If the request has auth data we pass it to the normal AWS strategy.

Inside the AWS strategy layer if it's a OPTIONS request we check for the access-control-request-method header so that we can properly generate the signature to compare with based on what client used when the presigned URL was generated.

Fixes: https://tracker.ceph.com/issues/62033

@tobias-urdin
tobias-urdin requested a review from a team as a code owner July 27, 2023 15:06
@github-actions github-actions Bot added the rgw label Jul 27, 2023
@tobias-urdin

Copy link
Copy Markdown
Contributor Author

related s3-tests patch, if we could get that tested in teuthology run with keystone auth engine ceph/s3-tests#523

@cbodley

cbodley commented Aug 3, 2023

Copy link
Copy Markdown
Contributor

if we could get that tested in teuthology run with keystone auth engine ceph/s3-tests#523

i have been tracking https://tracker.ceph.com/issues/59424 to run s3tests against the EC2 engine. i imagine we could just add the s3tests task under qa/suites/rgw/tempest/tasks/ but i'm not sure exactly what the config would look like. would that involve adding a access/secret key pair to keystone and using that as the 'main' user in s3tests?

@tobias-urdin

tobias-urdin commented Aug 4, 2023 •

Copy link
Copy Markdown
Contributor Author

if we could get that tested in teuthology run with keystone auth engine ceph/s3-tests#523

i have been tracking https://tracker.ceph.com/issues/59424 to run s3tests against the EC2 engine. i imagine we could just add the s3tests task under qa/suites/rgw/tempest/tasks/ but i'm not sure exactly what the config would look like. would that involve adding a access/secret key pair to keystone and using that as the 'main' user in s3tests?

for full integration in that case we'd need to run openstack ec2 credentials create (probably with --format json or what the option is called and then parse those from that) and then pass the access key and secret key from that command into s3tests config somehow

To just test this bug I think we can get away with just testing with a "tenanted user" that I think was already in s3tests after looking through there, not sure since i haven't tested yet though, i need to get main built with this patch and then figure out how to run s3tests locally on a vstart cluster.

@tobias-urdin
tobias-urdin force-pushed the options-anon-auth-presigned branch from bf08fd6 to 6a67931 Compare August 4, 2023 06:22
@cbodley

cbodley commented Aug 4, 2023

Copy link
Copy Markdown
Contributor

i need to get main built with this patch and then figure out how to run s3tests locally on a vstart cluster.

there's a qa/workunits/rgw/run-s3tests.sh script that will clone and run s3tests with all the right arguments. just run that from your build directory after starting up vstart.sh

@tobias-urdin
tobias-urdin force-pushed the options-anon-auth-presigned branch from 6a67931 to 7c666c2 Compare August 7, 2023 20:37
@tobias-urdin tobias-urdin changed the title [dnm] rgw: check auth for http options requests rgw: handle http options CORS with v4 auth Aug 7, 2023
@tobias-urdin

tobias-urdin commented Aug 7, 2023 •

Copy link
Copy Markdown
Contributor Author

@cbodley the s3tests patch now correctly tests the faulty behaviour and this patch solves those tests.

This is quite a rough patch on what is required to solve the linked tracker, this added it directly to the code path but it might not be acceptable (or elegant enough) so some alternatives is:

  • Moving the code inside a helper function to make it more clean
  • or, implement a whole separate Engine for the AWSStrategy and use that to handle HTTP OPTIONS requests with auth data specifically using is_applicable() (pretty much the reverse on how S3AnonymousEngine got changed with this patch) but that seemed like a daunting task for me as a first step

Looking forward to your feedback, thanks!

Comment thread src/rgw/rgw_rest_s3.cc Resolved
@tobias-urdin
tobias-urdin force-pushed the options-anon-auth-presigned branch from d8ff75e to a2f5d2b Compare August 17, 2023 11:45
If we get a HTTP OPTIONS request we previously always
allowed the anonymous engine to handle the request even
if other auth was given in the request.

Fixes: https://tracker.ceph.com/issues/62033
Signed-off-by: Tobias Urdin <[email protected]>
This adds code to properly verify the signature
for HTTP OPTIONS calls that is preflight CORS
requests passing the expected method in the
access-control-request-method header.

Fixes: https://tracker.ceph.com/issues/62033
Signed-off-by: Tobias Urdin <[email protected]>
@tobias-urdin
tobias-urdin force-pushed the options-anon-auth-presigned branch from a2f5d2b to dbc0a4e Compare August 17, 2023 11:47
@cbodley

cbodley commented Aug 17, 2023

Copy link
Copy Markdown
Contributor

sorry, centos builds in https://shaman.ceph.com/builds/ceph/pr-52673/dbc0a4ed2dd6a92d06e585dda25b1325464efefb/ are failing due to unrelated nfs-ganesha issues, so testing will be delayed

@cbodley

cbodley commented Aug 17, 2023

Copy link
Copy Markdown
Contributor

@tobias-urdin

Copy link
Copy Markdown
Contributor Author

@cbodley trying to understand those tests, most errors seems unrelated or am I missing something?

@cbodley

cbodley commented Aug 21, 2023

Copy link
Copy Markdown
Contributor

@cbodley trying to understand those tests, most errors seems unrelated or am I missing something?

they all look unrelated, yeah:

saw valgrind issues -> https://tracker.ceph.com/issues/62141

cluster [WRN] Health check failed: 1 pool(s) do not have an application enabled (POOL_APP_NOT_ENABLED) is a recent regression. i opened https://tracker.ceph.com/issues/62504 and #53074 with a fix

the s3test failure in rgw/dbstore is tracked in https://tracker.ceph.com/issues/62378

apt-get -y --force-yes install python-dev from rgw/crypt/kmip is tracked in https://tracker.ceph.com/issues/58751

the rgw/notifications failure looks new, i opened https://tracker.ceph.com/issues/62503 to track it

the multisite test failures are also known

overall good enough to merge 👍 i'll do the s3test at the same time

@cbodley
cbodley merged commit 100bb99 into ceph:main Aug 21, 2023
@tobias-urdin

Copy link
Copy Markdown
Contributor Author

cool, thanks @cbodley!

Any possibility we could backport this? or is it to be considered a behavior change

We have a customer that ran into this issue on Pacific

@cbodley

cbodley commented Aug 21, 2023

Copy link
Copy Markdown
Contributor

sure @tobias-urdin, i moved https://tracker.ceph.com/issues/62033 to Pending Backport for pacific quincy reef. we'll need to do the backport testing manually because of the s3test change

@pejotes

pejotes commented Sep 8, 2023

Copy link
Copy Markdown

hello!
Can you share build repo ref ? I can't find it on https://shaman.ceph.com/builds/ceph/pr-52673/40f6415977f0b4ab5c2cdfa0015943932c1a8fde/
I would love to test it out as well.

@cbodley

cbodley commented Sep 12, 2023

Copy link
Copy Markdown
Contributor

hello! Can you share build repo ref ? I can't find it on https://shaman.ceph.com/builds/ceph/pr-52673/40f6415977f0b4ab5c2cdfa0015943932c1a8fde/ I would love to test it out as well.

hey @pejotes, those builds get garbage-collected after a couple weeks. now that it's merged to main, you can test against a recent build from https://shaman.ceph.com/repos/ceph/main/

@pejotes

pejotes commented Sep 12, 2023

Copy link
Copy Markdown

Thanks Casey, for those tests I would like to stay with Q :-) I'm building one myself from backport PR.

tobias-urdin added a commit to tobias-urdin/ceph that referenced this pull request Feb 6, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Signed-off-by: Tobias Urdin <[email protected]>
cbodley pushed a commit to cbodley/ceph that referenced this pull request Feb 12, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Signed-off-by: Tobias Urdin <[email protected]>
(cherry picked from commit fe15b52)

Conflicts: missing 'rgw/keystone: use secret key from EC2 for sigv4 streaming mode'
	src/rgw/rgw_auth_keystone.cc
	src/rgw/rgw_auth_keystone.h
cbodley pushed a commit to cbodley/ceph that referenced this pull request Feb 12, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Signed-off-by: Tobias Urdin <[email protected]>
(cherry picked from commit fe15b52)

Conflicts: missing 'rgw/keystone: use secret key from EC2 for sigv4 streaming mode'
	src/rgw/rgw_auth_keystone.cc
	src/rgw/rgw_auth_keystone.h
TRYTOBE8TME pushed a commit to TRYTOBE8TME/ceph that referenced this pull request Mar 5, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Signed-off-by: Tobias Urdin <[email protected]>
mkogan1 pushed a commit to mkogan1/ceph that referenced this pull request Aug 13, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Resolves: rhbz#2302281

Signed-off-by: Tobias Urdin <[email protected]>
(cherry picked from commit fe15b52)
Signed-off-by: Matt Benjamin <[email protected]>
tobias-urdin added a commit to tobias-urdin/ceph that referenced this pull request Sep 25, 2024
If we get a HTTP OPTIONS request for a presigned URL that
contains credentials we need to compute the signature
using the method given in the access-control-request-method
http header.

This is the same as performed for v4 auth in [1].

[1] ceph#52673

Signed-off-by: Tobias Urdin <[email protected]>
cbodley pushed a commit to ceph/ceph-ci that referenced this pull request Oct 1, 2024
If we get a HTTP OPTIONS request for a presigned URL that
contains credentials we need to compute the signature
using the method given in the access-control-request-method
http header.

This is the same as performed for v4 auth in [1].

[1] ceph/ceph#52673

Signed-off-by: Tobias Urdin <[email protected]>
cbodley pushed a commit to ceph/ceph-ci that referenced this pull request Oct 4, 2024
If we get a HTTP OPTIONS request for a presigned URL that
contains credentials we need to compute the signature
using the method given in the access-control-request-method
http header.

This is the same as performed for v4 auth in [1].

[1] ceph/ceph#52673

Signed-off-by: Tobias Urdin <[email protected]>
mkogan1 pushed a commit to mkogan1/ceph that referenced this pull request Oct 22, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Signed-off-by: Tobias Urdin <[email protected]>
(cherry picked from commit fe15b52)
Signed-off-by: Matt Benjamin <[email protected]>
cbodley pushed a commit to cbodley/ceph that referenced this pull request Oct 23, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Signed-off-by: Tobias Urdin <[email protected]>
(cherry picked from commit fe15b52)

Conflicts: no optional_yield argument in quincy
	src/rgw/rgw_auth_keystone.cc
	src/rgw/rgw_auth_keystone.h
cbodley pushed a commit to cbodley/ceph that referenced this pull request Oct 23, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Signed-off-by: Tobias Urdin <[email protected]>
(cherry picked from commit fe15b52)

Conflicts: no optional_yield argument in reef
	src/rgw/rgw_auth_keystone.cc
	src/rgw/rgw_auth_keystone.h
gaudenz pushed a commit to cloudscale-ch/ceph that referenced this pull request Oct 24, 2024
Before [1] we always sent all HTTP OPTIONS requests to
the S3AnonymousEngine and ignored any provided AWSv4
credentials sent in the request.

That PR changed so that if we got credentials in the
request we instead sent it through the authentication
code in order to solve HTTP OPTIONS requests on tenanted
users to start working (because we need to resolve the
tenant, also called bucket tenant in the code, and we can't
only rely on the bucket name since it will not be found).

We solved this by modifying the canonical HTTP method used
when calculating the AWSv4 signature by instead using the
access-control-request-method header which worked good.

This change did not take into account that when you generated
a presigned URL for a put_object request you can also pass in
extra parameters like a canned ACL [2] to the Params variable
in for example boto3's generated_presigned_url().

Doing that will cause the client to add the x-amz-acl header
to x-amz-signedheaders and also use that in their signature
calculation.

When doing a HTTP OPTIONS calls for CORS on that presigned URL
the browser will never send a x-amz-acl header with the correct
data since that is something that the actual PUT request should
include later, so that HTTP OPTIONS call should pass even though
the signature can never be calculated correctly server-side like
verified against AWS S3 in tracker [3].

This patch as a result skips the signature calculation when doing
EC2 auth using the LocalEngine but we still need to pass the request
there in order to lookup the user to support buckets in a tenant.

For the Keystone EC2 auth we're pretty out of luck in the sense that
Keystone's API itself requires us to send the AWSv4 signature in the
request with the access_key in order to obtain a token, and we cannot
leave the signature out, we also cannot spoof the signature from
rgw -> keystone since we don't have access to the secret_key if it's
not in our cache.

For that approach we simply pass on to get_access_token() that if it's
an HTTP OPTIONS and we find the access_key in the cache we pull that
and ignore verifying signature and pass it on for validation. This means
that the cache must be warm if using Keystone auth and adding extra
params to a presigned URL.

This partly makes some of the commits in [1] redundant for EC2
LocalEngine auth but we still need it for tenanted bucket support.

[1] ceph#52673
[2] https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
[3] https://tracker.ceph.com/issues/64308

Fixes: https://tracker.ceph.com/issues/64308
Signed-off-by: Tobias Urdin <[email protected]>
(cherry picked from commit fe15b52)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants