1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-30 13:03:53 +01:00

Disable Private Vault Export Policy (#371)

This commit is contained in:
Oscar Hinton 2021-09-15 15:57:43 +02:00 committed by GitHub
parent 4933de688d
commit 8690f51e2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 6 deletions

2
jslib

@ -1 +1 @@
Subproject commit 5f64d956520612a681611a27c5f4f2e5f27b640e Subproject commit ee1ea922a9d5a51ef8df2abf4b97fc035ed782be

View File

@ -138,7 +138,7 @@ export class Main {
this.storageService, this.i18nService, this.cryptoFunctionService); this.storageService, this.i18nService, this.cryptoFunctionService);
this.vaultTimeoutService = new VaultTimeoutService(this.cipherService, this.folderService, this.vaultTimeoutService = new VaultTimeoutService(this.cipherService, this.folderService,
this.collectionService, this.cryptoService, this.platformUtilsService, this.storageService, this.collectionService, this.cryptoService, this.platformUtilsService, this.storageService,
this.messagingService, this.searchService, this.userService, this.tokenService, this.messagingService, this.searchService, this.userService, this.tokenService, this.policyService,
async () => await this.cryptoService.clearStoredKey('auto'), null); async () => await this.cryptoService.clearStoredKey('auto'), null);
this.syncService = new SyncService(this.userService, this.apiService, this.settingsService, this.syncService = new SyncService(this.userService, this.apiService, this.settingsService,
this.folderService, this.cipherService, this.cryptoService, this.collectionService, this.folderService, this.cipherService, this.cryptoService, this.collectionService,

View File

@ -3,17 +3,27 @@ import * as inquirer from 'inquirer';
import { CryptoService } from 'jslib-common/abstractions/crypto.service'; import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { ExportService } from 'jslib-common/abstractions/export.service'; import { ExportService } from 'jslib-common/abstractions/export.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { Response } from 'jslib-node/cli/models/response'; import { Response } from 'jslib-node/cli/models/response';
import { CliUtils } from '../utils'; import { PolicyType } from 'jslib-common/enums/policyType';
import { Utils } from 'jslib-common/misc/utils'; import { Utils } from 'jslib-common/misc/utils';
import { CliUtils } from '../utils';
export class ExportCommand { export class ExportCommand {
constructor(private cryptoService: CryptoService, private exportService: ExportService) { } constructor(private cryptoService: CryptoService, private exportService: ExportService,
private policyService: PolicyService) { }
async run(password: string, options: program.OptionValues): Promise<Response> { async run(password: string, options: program.OptionValues): Promise<Response> {
if (options.organizationid == null &&
await this.policyService.policyAppliesToUser(PolicyType.DisablePersonalVaultExport)) {
return Response.badRequest(
'One or more organization policies prevents you from exporting your personal vault.'
);
}
const canInteract = process.env.BW_NOINTERACTION !== 'true'; const canInteract = process.env.BW_NOINTERACTION !== 'true';
if ((password == null || password === '') && canInteract) { if ((password == null || password === '') && canInteract) {
const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({ const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({

View File

@ -3,8 +3,8 @@ import * as inquirer from 'inquirer';
import { ApiService } from 'jslib-common/abstractions/api.service'; import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service'; import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service'; import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service'; import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service'; import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';

View File

@ -424,7 +424,7 @@ export class VaultProgram extends Program {
}) })
.action(async (password, options) => { .action(async (password, options) => {
await this.exitIfLocked(); await this.exitIfLocked();
const command = new ExportCommand(this.main.cryptoService, this.main.exportService); const command = new ExportCommand(this.main.cryptoService, this.main.exportService, this.main.policyService);
const response = await command.run(password, options); const response = await command.run(password, options);
this.processResponse(response); this.processResponse(response);
}); });