【发布时间】:2017-02-04 23:50:18
【问题描述】:
我正在尝试在我的 (cordova) 安卓应用程序中创建一种身份验证机制,允许我的用户使用密码和用户名登录,或者允许他们扫描手指以登录。
如何验证在客户端、服务器端注册的指纹?这甚至可能使用 Cordova 吗?我尝试将手指扫描的结果传输到我的服务器:这看起来像:
FingerprintAuth.isAvailable(function(result) {
if (result.isAvailable) {
if(result.hasEnrolledFingerprints){
FingerprintAuth.show({
clientId: client_id,
clientSecret: client_secret
}, function (result) {
alert(JSON.stringify(result));
$http.post('http://192.168.149.33:3000/authorize', result).then(
function(response) {}
);
if (result.withFingerprint) {
$scope.$parent.loggedIn = true;
alert("Successfully authenticated using a fingerprint");
$location.path( "/home" );
} else if (result.withPassword) {
alert("Authenticated with backup password");
}
}, function(error) {
console.log(error); // "Fingerprint authentication not available"
});
} else {
alert("Fingerprint auth available, but no fingerprint registered on the device");
}
}
}, function(message) {
alert("Cannot detect fingerprint device : "+ message);
});
服务器端我收到以下数据(3 次单独扫描):
{ withFingerprint: 't8haYq36fmBPUEPbVjiWOaBLjMPBeUNP/BTOkoVtZ2ZiX20eBVzZAs3dn6PW/R4E\n' }
{ withFingerprint: 'rA9H+MIoQR3au9pqgLAi/EOCRA9b0Wx1AvzC/taGIUc8cCeDfzfiDZkxNy5U4joB\n' }
{ withFingerprint: 'MMyJm46O8MTxsa9aofKUS9fZW3OZVG7ojD+XspO71LWVy4TZh2FtvPtfjJFnj7Sy\n' }
图案似乎每次都不同,有没有一种方法可以将指纹链接到例如数据库中用户名下保存的图案?
【问题讨论】:
-
我相信插件应该是这种实现的方式。请查看这个插件 - github.com/mjwheatley/cordova-plugin-android-fingerprint-auth
-
嗨,马克我有疑问?如何获取clientid和client_secret?
-
@HariKrishnan.P 我认为您将不得不为此深入研究本机代码。或者,您可以搜索具有该本机功能接口的 cordova 插件。
-
@Gandhi- 我已经使用了上面的插件,但是我们必须以哪种格式将指纹存储在 db like.string 或任何图像中?
标签: javascript android cordova fingerprint