web vault url environment for U2F

This commit is contained in:
Kyle Spearrin 2017-08-28 18:08:08 -04:00
parent ad544e5240
commit c66803ce1f
6 changed files with 35 additions and 4 deletions

View File

@ -724,6 +724,9 @@
"apiUrl": {
"message": "API Server URL"
},
"webVaultUrl": {
"message": "Web Vault Server URL"
},
"identityUrl": {
"message": "Identity Server URL"
},

View File

@ -2,11 +2,24 @@
.module('bit.accounts')
.controller('accountsLoginTwoFactorController', function ($scope, $state, authService, toastr, utilsService, SweetAlert,
$analytics, i18nService, $stateParams, $filter, constantsService, $timeout, $window, cryptoService, apiService) {
$analytics, i18nService, $stateParams, $filter, constantsService, $timeout, $window, cryptoService, apiService,
$window) {
$scope.i18n = i18nService;
utilsService.initListSectionItemListeners($(document), angular);
var u2f = new U2f(function (data) {
var customWebVaultUrl = null;
var storedBaseUrl = $window.localStorage.getItem(constantsService.baseUrlKey);
if (storedBaseUrl) {
customWebVaultUrl = storedBaseUrl;
}
else {
var storedWebVaultUrl = $window.localStorage.getItem(constantsService.webVaultUrlKey);
if (storedWebVaultUrl) {
customWebVaultUrl = storedWebVaultUrl;
}
}
var u2f = new U2f(customWebVaultUrl, function (data) {
$timeout(function () {
$scope.login(data);
});

View File

@ -8,6 +8,7 @@
utilsService.initListSectionItemListeners($(document), angular);
$scope.baseUrl = $window.localStorage.getItem(constantsService.baseUrlKey) || '';
$scope.webVaultUrl = $window.localStorage.getItem(constantsService.webVaultUrlKey) || '';
$scope.apiUrl = $window.localStorage.getItem(constantsService.apiUrlKey) || '';
$scope.identityUrl = $window.localStorage.getItem(constantsService.identityUrlKey) || '';
@ -20,6 +21,14 @@
$window.localStorage.removeItem(constantsService.baseUrlKey);
}
if ($scope.webVaultUrl && $scope.webVaultUrl !== '') {
$scope.webVaultUrl = formatUrl($scope.webVaultUrl);
$window.localStorage.setItem(constantsService.webVaultUrlKey, $scope.webVaultUrl);
}
else {
$window.localStorage.removeItem(constantsService.webVaultUrlKey);
}
if ($scope.apiUrl && $scope.apiUrl !== '') {
$scope.apiUrl = formatUrl($scope.apiUrl);
$window.localStorage.setItem(constantsService.apiUrlKey, $scope.apiUrl);

View File

@ -30,6 +30,10 @@
{{i18n.customEnvironment}}
</div>
<div class="list-section-items">
<div class="list-section-item">
<label for="webVaultUrl" class="item-label">{{i18n.webVaultUrl}}</label>
<input id="webVaultUrl" type="text" name="WebVaultUrl" ng-model="webVaultUrl">
</div>
<div class="list-section-item">
<label for="apiUrl" class="item-label">{{i18n.apiUrl}}</label>
<input id="apiUrl" type="text" name="ApiUrl" ng-model="apiUrl">

View File

@ -1,9 +1,10 @@
function U2f(successCallback, errorCallback, infoCallback) {
function U2f(webVaultUrl, successCallback, errorCallback, infoCallback) {
this.success = successCallback;
this.error = errorCallback;
this.info = infoCallback;
this.iframe = null;
this.connectorLink = document.createElement('a');
this.webVaultUrl = webVaultUrl && webVaultUrl !== '' ? webVaultUrl : 'https://vault.bitwarden.com';
}
(function () {
@ -12,7 +13,7 @@
U2f.prototype.init = function (data) {
var self = thisU2f = this;
self.connectorLink.href = 'https://vault.bitwarden.com/u2f-connector.html' +
self.connectorLink.href = self.webVaultUrl + '/u2f-connector.html' +
'?data=' + this.base64Encode(JSON.stringify(data)) +
'&parent=' + encodeURIComponent(document.location.href) +
'&v=1';

View File

@ -1,6 +1,7 @@
function ConstantsService(i18nService) {
return {
baseUrlKey: 'baseUrl',
webVaultUrlKey: 'webVaultUrl',
apiUrlKey: 'apiUrl',
identityUrlKey: 'identityUrl',
disableGaKey: 'disableGa',