mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
add encrypted collection name to confirmUser request (#15156)
This commit is contained in:
@@ -83,6 +83,7 @@ import {
|
|||||||
ResetPasswordDialogResult,
|
ResetPasswordDialogResult,
|
||||||
} from "./components/reset-password.component";
|
} from "./components/reset-password.component";
|
||||||
import { DeleteManagedMemberWarningService } from "./services/delete-managed-member/delete-managed-member-warning.service";
|
import { DeleteManagedMemberWarningService } from "./services/delete-managed-member/delete-managed-member-warning.service";
|
||||||
|
import { OrganizationUserService } from "./services/organization-user/organization-user.service";
|
||||||
|
|
||||||
class MembersTableDataSource extends PeopleTableDataSource<OrganizationUserView> {
|
class MembersTableDataSource extends PeopleTableDataSource<OrganizationUserView> {
|
||||||
protected statusType = OrganizationUserStatusType;
|
protected statusType = OrganizationUserStatusType;
|
||||||
@@ -141,6 +142,7 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
|
|||||||
private billingApiService: BillingApiServiceAbstraction,
|
private billingApiService: BillingApiServiceAbstraction,
|
||||||
protected deleteManagedMemberWarningService: DeleteManagedMemberWarningService,
|
protected deleteManagedMemberWarningService: DeleteManagedMemberWarningService,
|
||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
|
private organizationUserService: OrganizationUserService,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
apiService,
|
apiService,
|
||||||
@@ -327,6 +329,14 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
|
|||||||
}
|
}
|
||||||
|
|
||||||
async confirmUser(user: OrganizationUserView, publicKey: Uint8Array): Promise<void> {
|
async confirmUser(user: OrganizationUserView, publicKey: Uint8Array): Promise<void> {
|
||||||
|
if (
|
||||||
|
await firstValueFrom(this.configService.getFeatureFlag$(FeatureFlag.CreateDefaultLocation))
|
||||||
|
) {
|
||||||
|
this.organizationUserService
|
||||||
|
.confirmUser(this.organization, user, publicKey)
|
||||||
|
.pipe(takeUntilDestroyed())
|
||||||
|
.subscribe();
|
||||||
|
} else {
|
||||||
const orgKey = await this.keyService.getOrgKey(this.organization.id);
|
const orgKey = await this.keyService.getOrgKey(this.organization.id);
|
||||||
const key = await this.encryptService.encapsulateKeyUnsigned(orgKey, publicKey);
|
const key = await this.encryptService.encapsulateKeyUnsigned(orgKey, publicKey);
|
||||||
const request = new OrganizationUserConfirmRequest();
|
const request = new OrganizationUserConfirmRequest();
|
||||||
@@ -337,6 +347,7 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
|
|||||||
request,
|
request,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async revoke(user: OrganizationUserView) {
|
async revoke(user: OrganizationUserView) {
|
||||||
const confirmed = await this.revokeUserConfirmationDialog(user);
|
const confirmed = await this.revokeUserConfirmationDialog(user);
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { combineLatest, filter, map, Observable, switchMap } from "rxjs";
|
||||||
|
|
||||||
|
import {
|
||||||
|
OrganizationUserConfirmRequest,
|
||||||
|
OrganizationUserApiService,
|
||||||
|
} from "@bitwarden/admin-console/common";
|
||||||
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
|
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||||
|
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
|
||||||
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
|
import { OrganizationId } from "@bitwarden/common/types/guid";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
|
import { OrganizationUserView } from "../../../core/views/organization-user.view";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: "root",
|
||||||
|
})
|
||||||
|
export class OrganizationUserService {
|
||||||
|
constructor(
|
||||||
|
protected keyService: KeyService,
|
||||||
|
private encryptService: EncryptService,
|
||||||
|
private organizationUserApiService: OrganizationUserApiService,
|
||||||
|
private accountService: AccountService,
|
||||||
|
private i18nService: I18nService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
private orgKey$(organization: Organization) {
|
||||||
|
return this.accountService.activeAccount$.pipe(
|
||||||
|
getUserId,
|
||||||
|
switchMap((userId) => this.keyService.orgKeys$(userId)),
|
||||||
|
filter((orgKeys) => !!orgKeys),
|
||||||
|
map((organizationKeysById) => organizationKeysById[organization.id as OrganizationId]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmUser(
|
||||||
|
organization: Organization,
|
||||||
|
user: OrganizationUserView,
|
||||||
|
publicKey: Uint8Array,
|
||||||
|
): Observable<void> {
|
||||||
|
const encryptedCollectionName$ = this.orgKey$(organization).pipe(
|
||||||
|
switchMap((orgKey) =>
|
||||||
|
this.encryptService.encryptString(this.i18nService.t("My Itmes"), orgKey),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const encryptedKey$ = this.orgKey$(organization).pipe(
|
||||||
|
switchMap((orgKey) => this.encryptService.encapsulateKeyUnsigned(orgKey, publicKey)),
|
||||||
|
);
|
||||||
|
|
||||||
|
return combineLatest([encryptedKey$, encryptedCollectionName$]).pipe(
|
||||||
|
switchMap(([key, collectionName]) => {
|
||||||
|
const request: OrganizationUserConfirmRequest = {
|
||||||
|
key: key.encryptedString,
|
||||||
|
defaultUserCollectionName: collectionName.encryptedString,
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.organizationUserApiService.postOrganizationUserConfirm(
|
||||||
|
organization.id,
|
||||||
|
user.id,
|
||||||
|
request,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
import { EncryptedString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
// @ts-strict-ignore
|
|
||||||
export class OrganizationUserConfirmRequest {
|
export class OrganizationUserConfirmRequest {
|
||||||
key: string;
|
key: EncryptedString | undefined;
|
||||||
|
defaultUserCollectionName: EncryptedString | undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export enum FeatureFlag {
|
|||||||
/* Admin Console Team */
|
/* Admin Console Team */
|
||||||
SeparateCustomRolePermissions = "pm-19917-separate-custom-role-permissions",
|
SeparateCustomRolePermissions = "pm-19917-separate-custom-role-permissions",
|
||||||
OptimizeNestedTraverseTypescript = "pm-21695-optimize-nested-traverse-typescript",
|
OptimizeNestedTraverseTypescript = "pm-21695-optimize-nested-traverse-typescript",
|
||||||
|
CreateDefaultLocation = "pm-19467-create-default-location",
|
||||||
|
|
||||||
/* Auth */
|
/* Auth */
|
||||||
PM16117_SetInitialPasswordRefactor = "pm-16117-set-initial-password-refactor",
|
PM16117_SetInitialPasswordRefactor = "pm-16117-set-initial-password-refactor",
|
||||||
@@ -77,6 +78,7 @@ export const DefaultFeatureFlagValue = {
|
|||||||
/* Admin Console Team */
|
/* Admin Console Team */
|
||||||
[FeatureFlag.SeparateCustomRolePermissions]: FALSE,
|
[FeatureFlag.SeparateCustomRolePermissions]: FALSE,
|
||||||
[FeatureFlag.OptimizeNestedTraverseTypescript]: FALSE,
|
[FeatureFlag.OptimizeNestedTraverseTypescript]: FALSE,
|
||||||
|
[FeatureFlag.CreateDefaultLocation]: FALSE,
|
||||||
|
|
||||||
/* Autofill */
|
/* Autofill */
|
||||||
[FeatureFlag.BlockBrowserInjectionsByDomain]: FALSE,
|
[FeatureFlag.BlockBrowserInjectionsByDomain]: FALSE,
|
||||||
|
|||||||
Reference in New Issue
Block a user