How does LinkedIn know or keep track of where I embedded its widget?

陌路散爱 提交于 2019-12-04 22:26:04

The LinkedIn Javascript framework won't work if you make a local copy of in.js - the backend server (which in.'s calls) checks to make sure that the in.js is coming from the correct server as well as checking to make sure that the framework will only work on the specified domain(s).

This question was asked/answered here: https://developer.linkedin.com/forum/security-prevent-impersonations

in.js has a script which adds another script tag into the DOM. It passes the API key (probably as a GET parameter in the script's URL), then the server checks the HTTP referer (which is a standard HTTP header browsers send indicating the website which sent them to get that page) and checks if it matches the API key in the database.

A simpler version would contain something like this:

document.write('<script src="http://mysite.com/api.js?key="' + api_key + '></' + 'script>');

Then on the server, something like this pseudo-code:

var expectedDomain = queryTable('apikeys').equal('key', GET('key')).field('domain').run();
if (expectedDomain === parseDomain(http.referer)) {
    respond(myscript);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!