mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
* refactor `canInteract` into a component level usage. - The default service is going to be used in the CLI which won't make use of the UI-related aspects * all nested entities to be imported from the vault * initial add of archive command to the cli * add archive to oss serve * check for deleted cipher when attempting to archive * add searchability/list functionality for archived ciphers * restore an archived cipher * unarchive a cipher when a user is editing it and has lost their premium status * add missing feature flags * re-export only needed services from the vault * add needed await * add prompt when applicable for editing an archived cipher * move cipher archive service into `common/vault` * fix testing code
96 lines
2.7 KiB
TypeScript
96 lines
2.7 KiB
TypeScript
import * as koaRouter from "@koa/router";
|
|
|
|
import { OssServeConfigurator } from "@bitwarden/cli/oss-serve-configurator";
|
|
|
|
import {
|
|
ApproveAllCommand,
|
|
ApproveCommand,
|
|
DenyAllCommand,
|
|
DenyCommand,
|
|
ListCommand,
|
|
} from "./admin-console/device-approval";
|
|
import { ServiceContainer } from "./service-container";
|
|
|
|
export class BitServeConfigurator extends OssServeConfigurator {
|
|
constructor(protected override serviceContainer: ServiceContainer) {
|
|
super(serviceContainer);
|
|
}
|
|
|
|
override async configureRouter(router: koaRouter): Promise<void> {
|
|
// Register OSS endpoints
|
|
await super.configureRouter(router);
|
|
|
|
// Register bit endpoints
|
|
this.serveDeviceApprovals(router);
|
|
}
|
|
|
|
private serveDeviceApprovals(router: koaRouter) {
|
|
router.get("/device-approval/:organizationId", async (ctx, next) => {
|
|
if (await this.errorIfLocked(ctx.response)) {
|
|
await next();
|
|
return;
|
|
}
|
|
|
|
const response = await ListCommand.create(this.serviceContainer).run(
|
|
ctx.params.organizationId,
|
|
);
|
|
this.processResponse(ctx.response, response);
|
|
await next();
|
|
});
|
|
|
|
router.post("/device-approval/:organizationId/approve-all", async (ctx, next) => {
|
|
if (await this.errorIfLocked(ctx.response)) {
|
|
await next();
|
|
return;
|
|
}
|
|
|
|
const response = await ApproveAllCommand.create(this.serviceContainer).run(
|
|
ctx.params.organizationId,
|
|
);
|
|
this.processResponse(ctx.response, response);
|
|
await next();
|
|
});
|
|
|
|
router.post("/device-approval/:organizationId/approve/:requestId", async (ctx, next) => {
|
|
if (await this.errorIfLocked(ctx.response)) {
|
|
await next();
|
|
return;
|
|
}
|
|
|
|
const response = await ApproveCommand.create(this.serviceContainer).run(
|
|
ctx.params.organizationId,
|
|
ctx.params.requestId,
|
|
);
|
|
this.processResponse(ctx.response, response);
|
|
await next();
|
|
});
|
|
|
|
router.post("/device-approval/:organizationId/deny-all", async (ctx, next) => {
|
|
if (await this.errorIfLocked(ctx.response)) {
|
|
await next();
|
|
return;
|
|
}
|
|
|
|
const response = await DenyAllCommand.create(this.serviceContainer).run(
|
|
ctx.params.organizationId,
|
|
);
|
|
this.processResponse(ctx.response, response);
|
|
await next();
|
|
});
|
|
|
|
router.post("/device-approval/:organizationId/deny/:requestId", async (ctx, next) => {
|
|
if (await this.errorIfLocked(ctx.response)) {
|
|
await next();
|
|
return;
|
|
}
|
|
|
|
const response = await DenyCommand.create(this.serviceContainer).run(
|
|
ctx.params.organizationId,
|
|
ctx.params.requestId,
|
|
);
|
|
this.processResponse(ctx.response, response);
|
|
await next();
|
|
});
|
|
}
|
|
}
|