Giter Club home page Giter Club logo

protected-embeds's Introduction

Protected Embeds

A drop-in replacement for WordPress.com protected embeds
A Human Made project. Maintained by @roborourke.

Installation

  1. Install the plugin as normal.
  2. Define PROTECTED_EMBEDS_DOMAIN in your wp-config.php as another domain that points to the same WordPress site. For example myembeds.com.
define( 'PROTECTED_EMBEDS_DOMAIN', 'myembeds.com' );

Dealing with early redirects

In WordPress multisite with a domain mapping solution such as Mercator running you may find requests to your embed domain get redirected too early and adding the domain as a site on the network will negate the benefits of a separate domain if you have SSO enabled. You can work around it by adding the following to your sunrise.php file:

// Create a dummy site object pointing the protected embeds domain
// to the primary site
add_filter( 'pre_get_site_by_path', function( $site, $domain, $path ) {
	if ( PROTECTED_EMBEDS_DOMAIN === $domain ) {
		$site          = new stdClass;
		$site->id      = 1;
		$site->blog_id = 1;
		$site->site_id = 1;
		$site->domain  = $domain;
		$site->path    = $path;
		$site->public  = 1;
	}
	return $site;
}, 10, 3 );

protected-embeds's People

Contributors

goldenapples avatar joehoyle avatar mslinnea avatar rmccue avatar roborourke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protected-embeds's Issues

Protected embed iframes should be requested from PROTECTED_EMBEDS_DOMAIN

Currently the iframe serving a protected embed is served from site_url( '/protected-iframe/' . $embed->get_id() ). This seems wrong, as the point of this plugin is to be sure to serve these iframes from a separate domain from the site.

This also causes the postmessages being used to resize the iframes to fail, because the target origin specified in the postMessage call doesn't match the actual document origin of the iframe. As a result, frames are not resizing correctly and are cut off at 150px height.

The offending line seems to be here:
https://github.com/humanmade/protected-embeds/blob/master/protected-embeds.php#L77

I don't see a button in my editor

Hi Team,

I've followed instructions and installed this plugin but I don't see the Add Embedded button added to the Wordpress Editor like in the attached screenshot. Please suggest

Thanks,
Amar
Screen Shot 2019-12-13 at 1 08 32 PM

Responsive iframes

Would be good to look into making the iframes resize nicely for small/larger screens etc... there's a vanilla js version of fitvids that might be usable in conjunction with the postmessage code.

Is Shortcake required?

Appears that Shortcake / ShortcodeUI is required when not running on WordPress.com.

Is shortcake included in WordPress.com / VIP? It might be that we need to change the description to reflect what is required to add this to a project.

Should requests for PROTECTED_EMBEDS_DOMAIN that aren't for embeds be killed early?

Hi Joe,

VIP brought the following issue to my attention:

We just noticed that PROTECTED_EMBEDS_DOMAIN will load the site homepage. As you probably know, the point of using an alternate domain to host embeds is to protect login cookies from XSS attacks. While it's probably not possible to get a login cookie from the protected embeds domain right now, it would be best to protect against some future bug that does make it possible. Do you think we could either wp_die() or wp_redirect() to the site homepage when that domain isn't serving a protected embed?

This seems like a general concern when implementing a protected embeds solution like this. What do you think about adding a check on init or parse_request that bails early for requests on the protected embeds domain that don't have have the "protected-iframe" query var set?

DB queries on admin_init.

The code is currently running a query to create a DB table if doesn't already exist on admin_init.

add_action( 'admin_init', __NAMESPACE__ . '\\create_database_table' );

Due to how often admin_init is triggered this is potentially creating a large number of unnecessary queries, for instance we have literally seen the create_database_table() function called millions of times in a single day on one of our big sites.

It would be more efficient to check the table exists on activation and upgrade rather than on every admin action.

Please give me a shout if you would like me to work on this with you.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.