jQuery 唯一设备标识

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18738161/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 22:22:23  来源:igfitidea点击:

Unique device identification

javascriptjqueryhtml

提问by TauWich

We are developing in-house web-based application for viewing data reports while targeting on smartphones and tablets. Our customer asked us for possibility that only certain devices could access the content. Hence we use technologies based on javascript/HTML5 we are no capable of reading unique ID like IMEI or device uuid. The idea is to be able to automatically create time-independent fingerprint of device with above mentioned technologies.

我们正在开发基于网络的内部应用程序,用于在智能手机和平板电脑上查看数据报告。我们的客户询问我们是否有可能只有某些设备才能访问内容。因此,我们使用基于 javascript/HTML5 的技术,我们无法读取唯一 ID,如 IMEI 或设备 uuid。这个想法是能够使用上述技术自动创建与时间无关的设备指纹。

The question is are we able to create unique device fingerprint with javascript/HTML5?

问题是我们是否能够使用 javascript/HTML5 创建唯一的设备指纹?

The clue might be information available or known by browser (e.g. http://browserspy.dk/)

线索可能是浏览器可用或已知的信息(例如http://browserspy.dk/

回答by Paul S.

You can use the fingerprintJS2library, it helps a lot with calculating a browser fingerprint.

您可以使用fingerprintJS2库,它对计算浏览器指纹有很大帮助。

By the way, on Panopticlickyou can see how unique this usually is.

顺便说一下,在Panopticlick 上,您可以看到这通常是多么独特。

回答by RayLoveless

It looks like the phoneGap plugin will allow you to get the device's uid.

看起来 phoneGap 插件将允许您获取设备的 uid。

http://docs.phonegap.com/en/3.0.0/cordova_device_device.md.html#device.uuid

http://docs.phonegap.com/en/3.0.0/cordova_device_device.md.html#device.uuid

Update: This is dependent on running native code. We used this solution writing javascript that was being compiled to native code for a native phone application we were creating.

更新:这取决于运行本机代码。我们使用此解决方案编写 javascript,该 javascript 被编译为我们正在创建的本机电话应用程序的本机代码。

回答by Kamil Kie?czewski

I have following idea how you can deal with such access device id (ADID):

我有以下想法如何处理此类访问设备 ID (ADID):

Gen ADID

ADID 代

  • prepare web-page https://mypage.com/manager-loginwhere trusted user e.g. Manager can login from device - that page should show button "Give access to this device"
  • when user press button, page send request to server to generate ADID
  • server gen ADID, store it on whitelist and return to page
  • then page store it in device localstorage
  • trusted user now logout.
  • 准备网页https://mypage.com/manager-login其中受信任的用户(例如 Manager)可以从设备登录 - 该页面应显示按钮“授予对该设备的访问权限”
  • 当用户按下按钮时,页面向服务器发送请求以生成 ADID
  • server gen ADID,将其存储在白名单中并返回页面
  • 然后页面将其存储在设备本地存储中
  • 受信任的用户现在注销。

Use device

使用设备

  • Then other user e.g. Employee using same device go to https://mypage.com/statisticsand page send to server request for statistics including parameter ADID (previous stored in localstorage)
  • server checks if the ADID is on the whitelist, and if yes then return data
  • 然后其他用户(例如使用同一设备的员工)转到https://mypage.com/statistics并将页面发送到服务器请求统计信息,包括参数 ADID(以前存储在 localstorage 中)
  • 服务器检查ADID是否在白名单中,如果是则返回数据

In this approach, as long user use same browser and don't make device reset, the device has access to data. If someone made device-reset then again trusted user need to login and gen ADID.

在这种方法中,只要用户使用相同的浏览器并且不重置设备,设备就可以访问数据。如果有人进行了设备重置,那么受信任的用户需要登录并生成 ADID。

You can even create some ADID management system for trusted user where on generate ADID he can also input device serial-number and in future in case of device reset he can find this device and regenerate ADID for it (which not increase whitelist size) and he can also drop some ADID from whitelist for devices which he will not longer give access to server data.

您甚至可以为受信任的用户创建一些 ADID 管理系统,在生成 ADID 时,他还可以输入设备序列号,将来在设备重置的情况下,他可以找到该设备并为其重新生成 ADID(不会增加白名单大小),他也可以从设备的白名单中删除一些 ADID,他将不再允许访问服务器数据。

In case when sytem use many domains/subdomains te manager after login should see many "Give access from domain xyz.com to this device" buttons - each button will redirect device do proper domain, gent ADID and redirect back.

如果系统使用多个域/子域,登录后管理器应该会看到许多“从域 xyz.com 访问此设备”按钮 - 每个按钮将重定向设备做正确的域,代理 ADID 并重定向回来。

UPDATE

更新

Simpler approach based on links:

基于链接的更简单的方法:

  • Manager login to system using any device and generate ONE-TIME USE LINK https://mypage.com/access-link/ZD34jse24Sfses3J(which works e.g. 24h).
  • Then manager send this link to employee (or someone else; e.g. by email) which put that link into device and server returns ADID to device which store it in Local Storage. After that link above stops working - so only the system and device know ADID
  • Then employee using this device can read data from https://mypage.com/statisticsbecause it has ADID which is on servers whitelist
  • 经理使用任何设备登录系统并生成一次性使用链接https://mypage.com/access-link/ZD34jse24Sfses3J(例如 24 小时工作)。
  • 然后经理将此链接发送给员工(或其他人;例如通过电子邮件),该员工将该链接放入设备中,然后服务器将 ADID 返回到设备,并将其存储在本地存储中。在上面的链接停止工作之后 - 所以只有系统和设备知道 ADID
  • 然后使用此设备的员工可以从https://mypage.com/statistics读取数据,因为它具有服务器白名单上的 ADID