javascript - restrict access to custom polymer element using domain name -


i trying achieve following using polymer custom element.

  • detect domain name request coming rendering custom element
  • if domain name matches [ - if authorized ] render custom element template
  • if domain name not matches / not authorized redirect error page polymer template

i have created custom html element - providing other sites; if other site/domain authorize site - should display custom polymer element / otherwise should display error template.

is possible ?

or moment adds my-custom-element site can use without restriction put in place ? please let me know if missing obvious here.

the following polymer elements not provide me capabilities achieve desired results well.

<app-route> <app-route-converter> 

for example :

let's using my-custom-element.html in site / html pages.

if my-custom-element.html being used in valid/authorized domain ; should serve custom polymer element; if my-custom-element.html being used in invalid / not authorized domain - in case should display error portion of element template.

valid uses-cases:

  • xyz.com/
  • subdomain.xyz.com/
  • xyz.com/*

invalid use-cases :

  • anyotherdomain.com

please note : authenticating domain owners using oauth providers. oauth tokens not passed along requests originating respective sites. way authorizing validity using "domain" [if it's registered site or not]

so want restrict custom elements create used?

i mean can simple

constructor() {   if (!this.location.href.match('https://stackoverflow.com') {      return false;    }   super(); } 

in of elements.

but yeah save preventing right click going prevent pictures being copied. (e.g. not @ all). still if goal prevent non techs might trick.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -