1
0
mirror of https://github.com/bitwarden/browser synced 2024-12-12 09:17:47 +01:00

fido u2f login flow

This commit is contained in:
Kyle Spearrin 2017-06-22 23:16:02 -04:00
parent 0135476b68
commit c55d0449cb
2 changed files with 42 additions and 1 deletions

View File

@ -2,7 +2,7 @@ angular
.module('bit.accounts') .module('bit.accounts')
.controller('accountsLoginController', function ($scope, $rootScope, $cookies, apiService, cryptoService, authService, .controller('accountsLoginController', function ($scope, $rootScope, $cookies, apiService, cryptoService, authService,
$state, constants, $analytics, $uibModal, $timeout) { $state, constants, $analytics, $uibModal, $timeout, $window) {
$scope.state = $state; $scope.state = $state;
var returnState; 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));
});
}
} }
}); });

View File

@ -84,3 +84,28 @@
</div> </div>
</form> </form>
</div> </div>
<div ng-if="twoFactorProvider === 4">
<p class="login-box-msg">
Complete logging in with U2F.
</p>
<form name="twoFactorForm" ng-submit="twoFactorForm.$valid && twoFactor(token)" api-form="twoFactorPromise">
<div class="callout callout-danger validation-errors" ng-show="twoFactorForm.$errors">
<h4>Errors have occurred</h4>
<ul>
<li ng-repeat="e in twoFactorForm.$errors">{{e}}</li>
</ul>
</div>
<p>Press the button on your security key to continue.</p>
<div class="row">
<div class="col-xs-7">
<a stop-click href="#" ng-click="anotherMethod()">Use another method?</a>
</div>
<div class="col-xs-5">
<button type="submit" class="btn btn-primary btn-block btn-flat" ng-disabled="twoFactorForm.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="twoFactorForm.$loading"></i>Log In
</button>
</div>
</div>
</form>
</div>