Jump to content

Can't import Polymer elements


Manaus
 Share

Recommended Posts

Hello,

I'm trying to import some polymer elements, but for some reason I get a 403

this is the code

<link rel="import" href="<? echo $config->urls->templates ?>bower_components/paper-input/paper-input.html" />

Is there a workaround?

Thanks!

  • Like 1
Link to comment
Share on other sites

For security reasons, you can't directly access files like that within the the PW templates directory (as well as others). Hmm...I always thought it's only PHP files that this restriction applies to but possibly HTML files as well? Somebody more knowledgeable will clarify :-)

Possible workarounds if restriction also applies to HTML files:

  1. use an include in a template file
  2. place the file outside PW directories and reference it from those locations
Edited by kongondo
  • Like 2
Link to comment
Share on other sites

This is the bit in .htaccess that blocks access to files in the templates directory:

  # Block access to any PHP or markup files in /site/templates/
  RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR]

Which is why css, js etc work, but php, html, tpl, inc etc don't.

  • Like 2
Link to comment
Share on other sites

  • 3 months later...

This might be a dumb question.

But what would be the solution to work with web components import links in a PW template and still maintain good security?

I guess that rewrite condition is there for a good reason. But also the use of polymers imports is probably going to increase in future. So it would be great to find a secure way of making them work together smoothly with PW.

Link to comment
Share on other sites

This might be a dumb question.

But what would be the solution to work with web components import links in a PW template and still maintain good security?

I guess that rewrite condition is there for a good reason. But also the use of polymers imports is probably going to increase in future. So it would be great to find a secure way of making them work together smoothly with PW.

I am not sure I understand why they can't be referenced to your site root - is it just a matter of keeping things all together?

<link rel="import" href="/bower_components/paper-input/paper-input.html" />

Actually looking into this more, I see that import is not supported in Firefox and apparently there are no plans to support it:

http://caniuse.com/#feat=imports

I guess the platform.js polyfill is making it functional across all browsers - is that what you guys are using?

  • Like 1
Link to comment
Share on other sites

But what would be the solution to work with web components import links in a PW template and still maintain good security?

It's not really a big security risk to allow access to html files, as that are static files. It's just that by now it wasn't a intended behavior to be able to access html files, therefore the rule. Also in the templates folders are maybe docs and such things in html format, which should probably be hidden. But if you use markdown this security is gone as well. Writing a custom .htaccess rule to allow access in the bower_components folder would probably be the best / most flexible bet.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...