Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Adds ability to allow or deny being embedded based on the referrer domain #95

Closed
wants to merge 6 commits into from

Conversation

joaomilho
Copy link

Since ALLOW-FROM doesn't work properly on Chrome (and I heard Firefox), we need to be able to allow or deny being embedded based on the referrer domain. This PR adds this ability, and this is the interface of usage:

use Rack::Protection::FrameOptions, allow_if: ->(domain){
  domain == 'google.com'
}

This would allow the page to be on an iframe on google.com, and nowhere else.

WDYT?

@joaomilho
Copy link
Author

@joaomilho
Copy link
Author

All is well! :D

@nathanstitt
Copy link
Contributor

I just submitted #108 which adds allow_if to HttpOrigin for CORS. For my purposes I needed to filter on the request URL, so I pass the entire env to the proc.

Perhaps this PR should do the same? That would allow the proc's logic to be much more flexible and allow/deny the request based on more than just the domain.�

@zzak
Copy link
Member

zzak commented Jul 27, 2016

Closing this in favor of #108, thank you for the patch!

With that patch merged, you have access to the env (including referrer domain) which allows you to do any custom logic there in the :allow_if proc.

I'd rather have that and let people shoot their own feet, then trying to parse the HTTP_REFERER on our own. In any case, that's probably something that should be handled in a secure way which I'm not comfortable with.

@zzak zzak closed this Jul 27, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants