Javascript 服务器上的Cordova指纹验证
我正在尝试在我的android(cordova)应用程序中创建一种身份验证机制,允许我的用户使用密码和用户名登录,或者允许他们扫描手指以便登录 如何验证在客户端、服务器端注册的指纹?使用Cordova是否有可能做到这一点?我尝试将手指扫描结果传输到我的服务器:如下所示:Javascript 服务器上的Cordova指纹验证,javascript,android,cordova,fingerprint,Javascript,Android,Cordova,Fingerprint,我正在尝试在我的android(cordova)应用程序中创建一种身份验证机制,允许我的用户使用密码和用户名登录,或者允许他们扫描手指以便登录 如何验证在客户端、服务器端注册的指纹?使用Cordova是否有可能做到这一点?我尝试将手指扫描结果传输到我的服务器:如下所示: FingerprintAuth.isAvailable(function(result) { if (result.isAvailable) { if(result.hasEnrolledFingerprints){
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次单独扫描):
模式似乎每次都不同,是否有一种方法可以将指纹链接到例如数据库中用户下保存的模式 使用cordova插件指纹aio进行指纹身份验证
有关更多信息,您可以咨询。您无法在服务器上验证指纹,指纹将使用
实时扫描/生物识别模板进行存储或验证。通过将当前扫描模板与以前存储的模板进行比较来完成身份验证
首先,您无法访问这些存储的模板(操作系统提供商/手机制造商未提供),如果我们假设您可以访问这些模板,则需要一种高效的算法(基于图像/基于模式)将当前模板与以前存储的模板进行比较。不能简单地通过字符串比较对其进行身份验证 简短回答
此API返回的字符串不是“指纹模式”。所以你无法验证你的想法
长答案
让我们先看看您正在使用的API的外观
看看这些方法:
public static void onAuthenticated(boolean withFingerprint) {
JSONObject resultJson = new JSONObject();
String errorMessage = "";
boolean createdResultJson = false;
try {
if (withFingerprint) {
// If the user has authenticated with fingerprint, verify that using cryptography and
// then return the encrypted token
byte[] encrypted = tryEncrypt();
resultJson.put("withFingerprint", Base64.encodeToString(encrypted, 0 /* flags */));
} else {
// Authentication happened with backup password.
resultJson.put("withPassword", true);
// if failed to init cipher because of InvalidKeyException, create new key
if (!initCipher()) {
createKey();
}
}
createdResultJson = true;
// ...
/**
* Tries to encrypt some data with the generated key in {@link #createKey} which is
* only works if the user has just authenticated via fingerprint.
*/
private static byte[] tryEncrypt() throws BadPaddingException, IllegalBlockSizeException {
return mCipher.doFinal(mClientSecret.getBytes());
}
查看“withFingerprint”
中的内容。这是加密的客户机机密的Base64编码。从技术上讲,这是您的身份验证。您将使用此令牌对请求进行身份验证,服务器将解密并验证客户端密码
摘要
指纹识别增加了安全性,但它不是唯一的安全手段。需要事先与设备和服务器建立关系
我发现这个图表有助于理解android指纹认证的意图(参考:)
我认为插件应该是实现这类功能的方式。请检查这个插件-嗨,马克,我有疑问吗?。如何获取clientid和client_的秘密?@HariKrishnan.P我想你必须深入到本地代码中。或者你也可以搜索一个cordova插件,该插件具有该本地功能的接口。@Gandhi-我已经使用了上述插件,但我们必须以什么格式将指纹存储在db like.string或任何图像中?非常感谢@甚至没问题!我也学到了一些关于指纹的知识:)有用的信息。谢谢只需为上图添加android博客链接:
public static void onAuthenticated(boolean withFingerprint) {
JSONObject resultJson = new JSONObject();
String errorMessage = "";
boolean createdResultJson = false;
try {
if (withFingerprint) {
// If the user has authenticated with fingerprint, verify that using cryptography and
// then return the encrypted token
byte[] encrypted = tryEncrypt();
resultJson.put("withFingerprint", Base64.encodeToString(encrypted, 0 /* flags */));
} else {
// Authentication happened with backup password.
resultJson.put("withPassword", true);
// if failed to init cipher because of InvalidKeyException, create new key
if (!initCipher()) {
createKey();
}
}
createdResultJson = true;
// ...
/**
* Tries to encrypt some data with the generated key in {@link #createKey} which is
* only works if the user has just authenticated via fingerprint.
*/
private static byte[] tryEncrypt() throws BadPaddingException, IllegalBlockSizeException {
return mCipher.doFinal(mClientSecret.getBytes());
}