From c55d0449cb9c255faa9b0a17c8bf84eaee22c646 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 22 Jun 2017 23:16:02 -0400 Subject: [PATCH] fido u2f login flow --- src/app/accounts/accountsLoginController.js | 18 ++++++++++++- .../views/accountsLoginTwoFactor.html | 25 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/app/accounts/accountsLoginController.js b/src/app/accounts/accountsLoginController.js index cc25604c2a..dd21e10c21 100644 --- a/src/app/accounts/accountsLoginController.js +++ b/src/app/accounts/accountsLoginController.js @@ -2,7 +2,7 @@ angular .module('bit.accounts') .controller('accountsLoginController', function ($scope, $rootScope, $cookies, apiService, cryptoService, authService, - $state, constants, $analytics, $uibModal, $timeout) { + $state, constants, $analytics, $uibModal, $timeout, $window) { $scope.state = $state; var returnState; @@ -118,5 +118,21 @@ angular } }); } + else if ($scope.twoFactorProvider === constants.twoFactorProvider.u2f) { + var params = $scope.twoFactorProviders[constants.twoFactorProvider.u2f]; + var challenges = JSON.parse(params.Challenges); + if (challenges.length < 1) { + return; + } + + $window.u2f.sign(challenges[0].appId, challenges[0].challenge, [{ + version: challenges[0].version, + keyHandle: challenges[0].keyHandle + }], function (data) { + console.log('call back data:'); + console.log(data); + $scope.twoFactor(JSON.stringify(data)); + }); + } } }); diff --git a/src/app/accounts/views/accountsLoginTwoFactor.html b/src/app/accounts/views/accountsLoginTwoFactor.html index aef91aadf5..90b4804b58 100644 --- a/src/app/accounts/views/accountsLoginTwoFactor.html +++ b/src/app/accounts/views/accountsLoginTwoFactor.html @@ -84,3 +84,28 @@ + +
+ +
+
+

Errors have occurred

+
    +
  • {{e}}
  • +
+
+

Press the button on your security key to continue.

+
+ +
+ +
+
+
+