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

rgw: set Access-Control-Allow-Origin to an asterisk if allowed in a rule #8528

Merged
merged 1 commit into from Jul 29, 2016

Conversation

wido
Copy link
Member

@wido wido commented Apr 11, 2016

http://tracker.ceph.com/issues/15839

Before this patch the RGW would respond with the Origin send by the client in the request
if a wildcard/asterisk was specified as a valid Origin.

This patch makes sure we respond with a header like this:

Access-Control-Allow-Origin: *

This way a resource can be used on different Origins by the same browser and that browser
will use the content as the asterisk.

We also keep in mind that when Authorization is send by the client different rules apply.
In the case of Authorization we may not respond with an Asterisk, but we do have to
add the Vary header with 'Origin' as a value to let the browser know that for different
Origins it has to perform a new request.

More information: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

Fixes: #15348

Signed-off-by: Wido den Hollander wido@42on.com

Conflicts:
src/rgw/rgw_rest.cc

This is the backport fix for #8441

@wido
Copy link
Member Author

wido commented Apr 19, 2016

There were some failures on #8441 with the tests.

Fixed the same things in this PR.

@smithfarm
Copy link
Contributor

@wido: Please describe the conflicts in the commit message.

@smithfarm
Copy link
Contributor

@wido There are some useful pointers on describing conflicts in http://tracker.ceph.com/projects/ceph-releases/wiki/HOWTO_backport_commits

@wido wido force-pushed the hammer-issue-15348 branch 2 times, most recently from 7f39d70 to b474ab3 Compare May 11, 2016 08:45
@wido
Copy link
Member Author

wido commented May 11, 2016

@smithfarm Done! I updated the commit and force pushed

@smithfarm
Copy link
Contributor

Changelog:

  • added backport tracker URL to PR description

@smithfarm smithfarm self-assigned this Jun 1, 2016
@smithfarm
Copy link
Contributor

@wido Would you care to stage the jewel backport as well? The tracker URL is http://tracker.ceph.com/issues/16112

smithfarm added a commit that referenced this pull request Jun 1, 2016
…sterisk if allowed in a rule

Reviewed-by: Nathan Cutler <ncutler@suse.com>
@wido
Copy link
Member Author

wido commented Jun 2, 2016

@smithfarm Done, please see #9453

It merged cleanly into the Jewel branch on my local testing

@smithfarm
Copy link
Contributor

@wido Thanks, http://tracker.ceph.com/issues/16112 assigned to you ;-)

@oritwas
Copy link
Member

oritwas commented Jun 8, 2016

@wido, can you add the cherry-picked commit to the commit message?

@wido
Copy link
Member Author

wido commented Jun 8, 2016

@oritwas Yes! Just did

@oritwas
Copy link
Member

oritwas commented Jun 22, 2016

@wido , I noticed this is very different from the upstream pr #8441 which may cause crashes http://tracker.ceph.com/issues/16323.
I am changing it to DNM in the mean time.

@oritwas oritwas changed the title rgw: Set Access-Control-Allow-Origin to a Asterisk if allowed in a rule [DNM] rgw: Set Access-Control-Allow-Origin to a Asterisk if allowed in a rule Jun 22, 2016
@wido
Copy link
Member Author

wido commented Jul 2, 2016

@oritwas Yes, I must have pushed a old branch. I just did a force push for Hammer. Could you review it again?

@smithfarm
Copy link
Contributor

@wido Sorry if this is tiresome, but could you re-do the patch using "git cherry-pick -x" ?

@wido
Copy link
Member Author

wido commented Jul 2, 2016

Just did @smithfarm :)

@smithfarm
Copy link
Contributor

@wido Which version of git are you using? When I do git cherry-pick -x on my computer, the -x
appends a line that says "(cherry picked from commit ...)" to the original commit message.

Whatever you add to the original commit message should come after that line and should be limited to a description of the conflicts.

@wido
Copy link
Member Author

wido commented Jul 2, 2016

@smithfarm I have git 1.9. I think this is because I manually edited the commit message with a copy-paste of the message I already had.

So you want to conflicts first? I thought this message was OK.

@smithfarm
Copy link
Contributor

@wido Please try "git cherry-pick -x 0021e22" - this, I believe, is the commit you are cherry-picking, not 7cf5d1d.

Before this patch the RGW would respond with the Origin send by the client in the request
if a wildcard/asterisk was specified as a valid Origin.

This patch makes sure we respond with a header like this:

  Access-Control-Allow-Origin: *

This way a resource can be used on different Origins by the same browser and that browser
will use the content as the asterisk.

We also keep in mind that when Authorization is send by the client different rules apply.
In the case of Authorization we may not respond with an Asterisk, but we do have to
add the Vary header with 'Origin' as a value to let the browser know that for different
Origins it has to perform a new request.

More information: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

Fixes: ceph#15348

Signed-off-by: Wido den Hollander <wido@42on.com>
(cherry picked from commit 0021e22)

Conflicts:
	src/rgw/rgw_rest.cc
		hammer still uses s->cio->print() where master uses STREAM_IO(s)->print()
@wido
Copy link
Member Author

wido commented Jul 3, 2016

Ah, yes! My bad @smithfarm , thanks for the pointer. I was somehow cherry-picking the wrong commit.

@smithfarm
Copy link
Contributor

@wido Thanks, looks good now.

@wido wido changed the title [DNM] rgw: Set Access-Control-Allow-Origin to a Asterisk if allowed in a rule rgw: Set Access-Control-Allow-Origin to a Asterisk if allowed in a rule Jul 6, 2016
@wido
Copy link
Member Author

wido commented Jul 12, 2016

@smithfarm How far are we with this one? I would like to see it in 0.94.8 :)

smithfarm added a commit that referenced this pull request Jul 18, 2016
…sterisk if allowed in a rule

Reviewed-by: Nathan Cutler <ncutler@suse.com>
smithfarm added a commit that referenced this pull request Jul 24, 2016
…sterisk if allowed in a rule

Reviewed-by: Nathan Cutler <ncutler@suse.com>
@smithfarm
Copy link
Contributor

@oritwas This PR passed an rgw suite with some valgrind-related failures that appear harmless - see http://tracker.ceph.com/issues/15895#note-19

Do you think this PR is ready to merge?

@oritwas
Copy link
Member

oritwas commented Jul 28, 2016

lgtm

@smithfarm smithfarm merged commit ba8de3a into ceph:hammer Jul 29, 2016
@smithfarm smithfarm changed the title rgw: Set Access-Control-Allow-Origin to a Asterisk if allowed in a rule rgw: set Access-Control-Allow-Origin to an asterisk if allowed in a rule Aug 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants