mirror of
https://github.com/bitwarden/web
synced 2025-12-28 06:03:48 +00:00
duo 2fa config and login with web sdk
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
var _issuer = 'bitwarden',
|
||||
_profile = null,
|
||||
_masterPasswordHash
|
||||
_key = null;
|
||||
_key = null;
|
||||
|
||||
$scope.auth = function (model) {
|
||||
_masterPasswordHash = cryptoService.hashPassword(model.masterPassword);
|
||||
@@ -69,6 +69,7 @@
|
||||
}, function (response) {
|
||||
$analytics.eventTrack('Disabled Two-step Authenticator');
|
||||
toastr.success('Authenticator app has been disabled.');
|
||||
$scope.enabled = response.Enabled;
|
||||
$scope.close();
|
||||
}).$promise;
|
||||
}
|
||||
@@ -86,6 +87,6 @@
|
||||
}
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.close();
|
||||
$uibModalInstance.close($scope.enabled);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
authenticatorModal.result.then(function () {
|
||||
|
||||
authenticatorModal.result.then(function (enabled) {
|
||||
provider.enabled = enabled;
|
||||
});
|
||||
}
|
||||
else if(provider.type === constants.twoFactorProvider.email) {
|
||||
@@ -79,8 +79,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
emailModal.result.then(function () {
|
||||
|
||||
emailModal.result.then(function (enabled) {
|
||||
provider.enabled = enabled;
|
||||
});
|
||||
}
|
||||
else if (provider.type === constants.twoFactorProvider.yubikey) {
|
||||
@@ -93,8 +93,22 @@
|
||||
}
|
||||
});
|
||||
|
||||
yubiModal.result.then(function () {
|
||||
yubiModal.result.then(function (enabled) {
|
||||
provider.enabled = enabled;
|
||||
});
|
||||
}
|
||||
else if (provider.type === constants.twoFactorProvider.duo) {
|
||||
var yubiModal = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/settings/views/settingsTwoStepDuo.html',
|
||||
controller: 'settingsTwoStepDuoController',
|
||||
resolve: {
|
||||
enabled: function () { return provider.enabled; }
|
||||
}
|
||||
});
|
||||
|
||||
yubiModal.result.then(function (enabled) {
|
||||
provider.enabled = enabled;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
75
src/app/settings/settingsTwoStepDuoController.js
Normal file
75
src/app/settings/settingsTwoStepDuoController.js
Normal file
@@ -0,0 +1,75 @@
|
||||
angular
|
||||
.module('bit.settings')
|
||||
|
||||
.controller('settingsTwoStepDuoController', function ($scope, apiService, $uibModalInstance, cryptoService,
|
||||
toastr, $analytics, constants) {
|
||||
$analytics.eventTrack('settingsTwoStepDuoController', { category: 'Modal' });
|
||||
var _masterPasswordHash;
|
||||
|
||||
$scope.updateModel = {
|
||||
token: null,
|
||||
host: null,
|
||||
ikey: null,
|
||||
skey: null
|
||||
};
|
||||
|
||||
$scope.auth = function (model) {
|
||||
_masterPasswordHash = cryptoService.hashPassword(model.masterPassword);
|
||||
$scope.authPromise = apiService.twoFactor.getDuo({}, {
|
||||
masterPasswordHash: _masterPasswordHash
|
||||
}).$promise.then(function (apiResponse) {
|
||||
processResult(apiResponse);
|
||||
$scope.authed = true;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.submit = function (model) {
|
||||
if ($scope.enabled) {
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
|
||||
update(model);
|
||||
};
|
||||
|
||||
function disable() {
|
||||
if (!confirm('Are you sure you want to disable the Duo provider?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.submitPromise = apiService.twoFactor.disable({}, {
|
||||
masterPasswordHash: _masterPasswordHash,
|
||||
type: constants.twoFactorProvider.duo
|
||||
}, function (response) {
|
||||
$analytics.eventTrack('Disabled Two-step Duo');
|
||||
toastr.success('Duo has been disabled.');
|
||||
$scope.enabled = response.Enabled;
|
||||
$scope.close();
|
||||
}).$promise;
|
||||
}
|
||||
|
||||
function update(model) {
|
||||
$scope.submitPromise = apiService.twoFactor.putDuo({}, {
|
||||
integrationKey: model.ikey,
|
||||
secretKey: model.skey,
|
||||
host: model.host,
|
||||
masterPasswordHash: _masterPasswordHash
|
||||
}, function (response) {
|
||||
$analytics.eventTrack('Enabled Two-step Duo');
|
||||
processResult(response);
|
||||
}).$promise;
|
||||
}
|
||||
|
||||
function processResult(response) {
|
||||
$scope.enabled = response.Enabled;
|
||||
$scope.updateModel = {
|
||||
ikey: response.IntegrationKey,
|
||||
skey: response.SecretKey,
|
||||
host: response.Host
|
||||
};
|
||||
}
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.close($scope.enabled);
|
||||
};
|
||||
});
|
||||
@@ -74,6 +74,7 @@
|
||||
}, function (response) {
|
||||
$analytics.eventTrack('Disabled Two-step Email');
|
||||
toastr.success('Email has been disabled.');
|
||||
$scope.enabled = response.Enabled;
|
||||
$scope.close();
|
||||
}).$promise;
|
||||
}
|
||||
@@ -92,6 +93,6 @@
|
||||
}
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.close();
|
||||
$uibModalInstance.close($scope.enabled);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
$scope.disableLoading = false;
|
||||
$analytics.eventTrack('Disabled Two-step YubiKey');
|
||||
toastr.success('YubiKey has been disabled.');
|
||||
$scope.enabled = response.Enabled;
|
||||
$scope.close();
|
||||
}, function (response) {
|
||||
toastr.error('Failed to disable.');
|
||||
@@ -102,6 +103,6 @@
|
||||
}
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.close();
|
||||
$uibModalInstance.close($scope.enabled);
|
||||
};
|
||||
});
|
||||
|
||||
76
src/app/settings/views/settingsTwoStepDuo.html
Normal file
76
src/app/settings/views/settingsTwoStepDuo.html
Normal file
@@ -0,0 +1,76 @@
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">
|
||||
<i class="fa fa-key"></i> Two-step Login <small>duo</small>
|
||||
</h4>
|
||||
</div>
|
||||
<form name="authTwoStepForm" ng-submit="authTwoStepForm.$valid && auth(authModel)" api-form="authPromise"
|
||||
ng-if="!authed">
|
||||
<div class="modal-body">
|
||||
<p>Enter your master password to modify two-step login settings.</p>
|
||||
<div class="callout callout-danger validation-errors" ng-show="authTwoStepForm.$errors">
|
||||
<h4>Errors have occurred</h4>
|
||||
<ul>
|
||||
<li ng-repeat="e in authTwoStepForm.$errors">{{e}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="form-group" show-errors>
|
||||
<label for="masterPassword">Master Password</label>
|
||||
<input type="password" id="masterPassword" name="MasterPasswordHash" ng-model="authModel.masterPassword"
|
||||
class="form-control" required api-field />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="authTwoStepForm.$loading">
|
||||
<i class="fa fa-refresh fa-spin loading-icon" ng-show="authTwoStepForm.$loading"></i>Continue
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
<form name="submitTwoStepForm" ng-submit="submitTwoStepForm.$valid && submit(updateModel)" api-form="submitPromise"
|
||||
ng-if="authed">
|
||||
<div class="modal-body">
|
||||
<div ng-if="enabled">
|
||||
<div class="callout callout-success">
|
||||
<h4><i class="fa fa-check-circle"></i> Enabled</h4>
|
||||
<p>Two-step log via Duo is enabled on your account.</p>
|
||||
</div>
|
||||
<ul class="list-unstyled">
|
||||
<li><strong>Integration Key:</strong> {{updateModel.ikey}}</li>
|
||||
<li><strong>Secret Key:</strong> ************</li>
|
||||
<li><strong>API Hostname:</strong> {{updateModel.host}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div ng-if="!enabled">
|
||||
<div class="callout callout-danger validation-errors" ng-show="submitTwoStepForm.$errors">
|
||||
<h4>Errors have occurred</h4>
|
||||
<ul>
|
||||
<li ng-repeat="e in submitTwoStepForm.$errors">{{e}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>Setting up two-step login with Duo is easy, just enter the Duo application information below:</p>
|
||||
<div class="form-group" show-errors>
|
||||
<label for="ikey">Integration Key</label>
|
||||
<input type="text" id="ikey" name="IntegrationKey" ng-model="updateModel.ikey" class="form-control"
|
||||
required api-field />
|
||||
</div>
|
||||
<div class="form-group" show-errors>
|
||||
<label for="skey">Secret Key</label>
|
||||
<input type="password" id="skey" name="SecretKey" ng-model="updateModel.skey" class="form-control"
|
||||
required api-field />
|
||||
</div>
|
||||
<div class="form-group" show-errors>
|
||||
<label for="host">API Hostname</label>
|
||||
<input type="text" id="host" name="Host" placeholder="ex. api-xxxxxxxx.duosecurity.com"
|
||||
ng-model="updateModel.host" class="form-control" required api-field />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="submitTwoStepForm.$loading">
|
||||
<i class="fa fa-refresh fa-spin loading-icon" ng-show="submitTwoStepForm.$loading"></i>
|
||||
{{enabled ? 'Disable' : 'Enable'}}
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
Reference in New Issue
Block a user