1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

[AC-2740] Add device-approval to bw serve (#9512)

* Extract bw serve endpoint configuration to a configurator class

* Add device-approval endpoints to bw serve
This commit is contained in:
Thomas Rittson
2024-06-13 11:32:51 +10:00
committed by GitHub
parent b35930074c
commit 89aa6220ca
14 changed files with 613 additions and 442 deletions

View File

@@ -6,6 +6,8 @@ import { MessageResponse } from "@bitwarden/cli/models/response/message.response
import { OrganizationService } from "@bitwarden/common/admin-console/services/organization/organization.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { ServiceContainer } from "../../service-container";
export class ApproveAllCommand {
constructor(
private organizationAuthRequestService: OrganizationAuthRequestService,
@@ -49,4 +51,11 @@ export class ApproveAllCommand {
return Response.error(e);
}
}
static create(serviceContainer: ServiceContainer) {
return new ApproveAllCommand(
serviceContainer.organizationAuthRequestService,
serviceContainer.organizationService,
);
}
}

View File

@@ -5,6 +5,7 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { OrganizationAuthRequestService } from "../../../../bit-common/src/admin-console/auth-requests";
import { ServiceContainer } from "../../service-container";
export class ApproveCommand {
constructor(
@@ -51,4 +52,11 @@ export class ApproveCommand {
return Response.error(e);
}
}
static create(serviceContainer: ServiceContainer) {
return new ApproveCommand(
serviceContainer.organizationService,
serviceContainer.organizationAuthRequestService,
);
}
}

View File

@@ -6,6 +6,7 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { OrganizationAuthRequestService } from "../../../../bit-common/src/admin-console/auth-requests";
import { ServiceContainer } from "../../service-container";
export class DenyAllCommand {
constructor(
@@ -46,4 +47,11 @@ export class DenyAllCommand {
return Response.error(e);
}
}
static create(serviceContainer: ServiceContainer) {
return new DenyAllCommand(
serviceContainer.organizationService,
serviceContainer.organizationAuthRequestService,
);
}
}

View File

@@ -5,6 +5,7 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { OrganizationAuthRequestService } from "../../../../bit-common/src/admin-console/auth-requests";
import { ServiceContainer } from "../../service-container";
export class DenyCommand {
constructor(
@@ -43,4 +44,11 @@ export class DenyCommand {
return Response.error(e);
}
}
static create(serviceContainer: ServiceContainer) {
return new DenyCommand(
serviceContainer.organizationService,
serviceContainer.organizationAuthRequestService,
);
}
}

View File

@@ -42,11 +42,7 @@ export class DeviceApprovalProgram extends BaseProgram {
await this.exitIfFeatureFlagDisabled(FeatureFlag.BulkDeviceApproval);
await this.exitIfLocked();
const cmd = new ListCommand(
this.serviceContainer.organizationAuthRequestService,
this.serviceContainer.organizationService,
);
const cmd = ListCommand.create(this.serviceContainer);
const response = await cmd.run(options.organizationid);
this.processResponse(response);
});
@@ -61,10 +57,7 @@ export class DeviceApprovalProgram extends BaseProgram {
await this.exitIfFeatureFlagDisabled(FeatureFlag.BulkDeviceApproval);
await this.exitIfLocked();
const cmd = new ApproveCommand(
this.serviceContainer.organizationService,
this.serviceContainer.organizationAuthRequestService,
);
const cmd = ApproveCommand.create(this.serviceContainer);
const response = await cmd.run(options.organizationid, id);
this.processResponse(response);
});
@@ -78,10 +71,7 @@ export class DeviceApprovalProgram extends BaseProgram {
await this.exitIfFeatureFlagDisabled(FeatureFlag.BulkDeviceApproval);
await this.exitIfLocked();
const cmd = new ApproveAllCommand(
this.serviceContainer.organizationAuthRequestService,
this.serviceContainer.organizationService,
);
const cmd = ApproveAllCommand.create(this.serviceContainer);
const response = await cmd.run(options.organizationid);
this.processResponse(response);
});
@@ -96,10 +86,7 @@ export class DeviceApprovalProgram extends BaseProgram {
await this.exitIfFeatureFlagDisabled(FeatureFlag.BulkDeviceApproval);
await this.exitIfLocked();
const cmd = new DenyCommand(
this.serviceContainer.organizationService,
this.serviceContainer.organizationAuthRequestService,
);
const cmd = DenyCommand.create(this.serviceContainer);
const response = await cmd.run(options.organizationid, id);
this.processResponse(response);
});
@@ -113,10 +100,7 @@ export class DeviceApprovalProgram extends BaseProgram {
await this.exitIfFeatureFlagDisabled(FeatureFlag.BulkDeviceApproval);
await this.exitIfLocked();
const cmd = new DenyAllCommand(
this.serviceContainer.organizationService,
this.serviceContainer.organizationAuthRequestService,
);
const cmd = DenyAllCommand.create(this.serviceContainer);
const response = await cmd.run(options.organizationid);
this.processResponse(response);
});

View File

@@ -1 +1,6 @@
export { DeviceApprovalProgram } from "./device-approval.program";
export * from "./device-approval.program";
export * from "./approve.command";
export * from "./approve-all.command";
export * from "./deny.command";
export * from "./deny-all.command";
export * from "./list.command";

View File

@@ -6,6 +6,8 @@ import { ListResponse } from "@bitwarden/cli/models/response/list.response";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { ServiceContainer } from "../../service-container";
import { PendingAuthRequestResponse } from "./pending-auth-request.response";
export class ListCommand {
@@ -39,4 +41,11 @@ export class ListCommand {
return Response.error(e);
}
}
static create(serviceContainer: ServiceContainer) {
return new ListCommand(
serviceContainer.organizationAuthRequestService,
serviceContainer.organizationService,
);
}
}