Home > Software design >  How to secure my web widget embedded from third party website
How to secure my web widget embedded from third party website

Time:01-11

I am creating web widget that can embed in other websites. Here is an example.

<script src="http://URL/searchWidget.js" type="text/javascript"></script>
<search-view name="search"></search-view>

I have some specific clients and only I am providing those widgets to those clients. So I need to secure those widgets from other third party websites. My Clients are using CMS, Joomla, Drupal.

If I give a widget(above script tag) to the client, only that client has access to that widget. If someone stolen that script, they cannot access that widget.

How can I do that ?
Is there any secure way to build widgets ?
can I do that using CMS plugin ?

CodePudding user response:

Use this script in your javacsript to get current domain.

var scripts = document.getElementsByTagName("script");
SiteHostUrl = scripts[scripts.length-1].src;
jsUrl = SiteHostUrl;

Or you need give unique id for your client. You can access that ID and pass in ajax call verify the domain. if ID is not valid mean do not show your widget

  •  Tags:  
  • Related