mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
[PM-2594] Replacing hardcoded cloud vault urls based on region obtained from ConfigService (#5629)
* [PM-2594] Added property "CloudVault" to EnvironmentServerConfigData and EnvironmentServerConfigResponse * [PM-2594] Replaced hardcoded vault urls with value obtained from ConfigService * [PM-2594] Renamed EnvironmentServerConfigResponse.cloudVault to cloudWebVault * [PM-2594] Updated unit test with new property "cloudWebVault" * [PM-2594] Added methods to get and set CloudWebVaultUrl on EnvironmentService. Configured ConfigurationService to set value based on cloudVaultRegion * [PM-2594] Added JSDOC comments to methods getCloudWebVaultUrl and setCloudWebVaultUrl * [PM-2594] Renamed EnvironmentServerConfigData.cloudVaultRegion to cloudRegion * [PM-2594] Fixed unit test
This commit is contained in:
@@ -66,7 +66,7 @@
|
|||||||
<a
|
<a
|
||||||
bitButton
|
bitButton
|
||||||
buttonType="secondary"
|
buttonType="secondary"
|
||||||
href="https://vault.bitwarden.com"
|
href="{{ this.cloudWebVaultUrl }}"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
|
|||||||
import { OrganizationConnectionResponse } from "@bitwarden/common/admin-console/models/response/organization-connection.response";
|
import { OrganizationConnectionResponse } from "@bitwarden/common/admin-console/models/response/organization-connection.response";
|
||||||
import { BillingSyncConfigApi } from "@bitwarden/common/billing/models/api/billing-sync-config.api";
|
import { BillingSyncConfigApi } from "@bitwarden/common/billing/models/api/billing-sync-config.api";
|
||||||
import { SelfHostedOrganizationSubscriptionView } from "@bitwarden/common/billing/models/view/self-hosted-organization-subscription.view";
|
import { SelfHostedOrganizationSubscriptionView } from "@bitwarden/common/billing/models/view/self-hosted-organization-subscription.view";
|
||||||
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
@@ -34,6 +35,7 @@ export class OrganizationSubscriptionSelfhostComponent implements OnInit, OnDest
|
|||||||
subscription: SelfHostedOrganizationSubscriptionView;
|
subscription: SelfHostedOrganizationSubscriptionView;
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
userOrg: Organization;
|
userOrg: Organization;
|
||||||
|
cloudWebVaultUrl: string;
|
||||||
|
|
||||||
licenseOptions = LicenseOptions;
|
licenseOptions = LicenseOptions;
|
||||||
form = new FormGroup({
|
form = new FormGroup({
|
||||||
@@ -82,8 +84,11 @@ export class OrganizationSubscriptionSelfhostComponent implements OnInit, OnDest
|
|||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private i18nService: I18nService
|
private i18nService: I18nService,
|
||||||
) {}
|
private environmentService: EnvironmentService
|
||||||
|
) {
|
||||||
|
this.cloudWebVaultUrl = this.environmentService.getCloudWebVaultUrl();
|
||||||
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.route.params
|
this.route.params
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
<a
|
<a
|
||||||
bitButton
|
bitButton
|
||||||
buttonType="secondary"
|
buttonType="secondary"
|
||||||
href="https://vault.bitwarden.com/#/settings/subscription"
|
href="{{ this.cloudWebVaultUrl }}/#/settings/subscription"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Router } from "@angular/router";
|
|||||||
import { DialogServiceAbstraction, SimpleDialogType } from "@bitwarden/angular/services/dialog";
|
import { DialogServiceAbstraction, SimpleDialogType } from "@bitwarden/angular/services/dialog";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { SubscriptionResponse } from "@bitwarden/common/billing/models/response/subscription.response";
|
import { SubscriptionResponse } from "@bitwarden/common/billing/models/response/subscription.response";
|
||||||
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
@@ -22,6 +23,7 @@ export class UserSubscriptionComponent implements OnInit {
|
|||||||
showUpdateLicense = false;
|
showUpdateLicense = false;
|
||||||
sub: SubscriptionResponse;
|
sub: SubscriptionResponse;
|
||||||
selfHosted = false;
|
selfHosted = false;
|
||||||
|
cloudWebVaultUrl: string;
|
||||||
|
|
||||||
cancelPromise: Promise<any>;
|
cancelPromise: Promise<any>;
|
||||||
reinstatePromise: Promise<any>;
|
reinstatePromise: Promise<any>;
|
||||||
@@ -34,9 +36,11 @@ export class UserSubscriptionComponent implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private fileDownloadService: FileDownloadService,
|
private fileDownloadService: FileDownloadService,
|
||||||
private dialogService: DialogServiceAbstraction
|
private dialogService: DialogServiceAbstraction,
|
||||||
|
private environmentService: EnvironmentService
|
||||||
) {
|
) {
|
||||||
this.selfHosted = platformUtilsService.isSelfHost();
|
this.selfHosted = platformUtilsService.isSelfHost();
|
||||||
|
this.cloudWebVaultUrl = this.environmentService.getCloudWebVaultUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
|||||||
@@ -39,6 +39,19 @@ export abstract class EnvironmentService {
|
|||||||
hasBaseUrl: () => boolean;
|
hasBaseUrl: () => boolean;
|
||||||
getNotificationsUrl: () => string;
|
getNotificationsUrl: () => string;
|
||||||
getWebVaultUrl: () => string;
|
getWebVaultUrl: () => string;
|
||||||
|
/**
|
||||||
|
* Retrieves the URL of the cloud web vault app.
|
||||||
|
*
|
||||||
|
* @returns {string} The URL of the cloud web vault app.
|
||||||
|
* @remarks Use this method only in views exclusive to self-host instances.
|
||||||
|
*/
|
||||||
|
getCloudWebVaultUrl: () => string;
|
||||||
|
/**
|
||||||
|
* Sets the URL of the cloud web vault app based on the region parameter.
|
||||||
|
*
|
||||||
|
* @param {Region} region - The region of the cloud web vault app.
|
||||||
|
*/
|
||||||
|
setCloudWebVaultUrl: (region: Region) => void;
|
||||||
getSendUrl: () => string;
|
getSendUrl: () => string;
|
||||||
getIconsUrl: () => string;
|
getIconsUrl: () => string;
|
||||||
getApiUrl: () => string;
|
getApiUrl: () => string;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Region } from "../../abstractions/environment.service";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
EnvironmentServerConfigData,
|
EnvironmentServerConfigData,
|
||||||
ServerConfigData,
|
ServerConfigData,
|
||||||
@@ -15,6 +17,7 @@ describe("ServerConfigData", () => {
|
|||||||
url: "https://test.com",
|
url: "https://test.com",
|
||||||
},
|
},
|
||||||
environment: {
|
environment: {
|
||||||
|
cloudRegion: Region.EU,
|
||||||
vault: "https://vault.com",
|
vault: "https://vault.com",
|
||||||
api: "https://api.com",
|
api: "https://api.com",
|
||||||
identity: "https://identity.com",
|
identity: "https://identity.com",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Jsonify } from "type-fest";
|
import { Jsonify } from "type-fest";
|
||||||
|
|
||||||
|
import { Region } from "../../abstractions/environment.service";
|
||||||
import {
|
import {
|
||||||
ServerConfigResponse,
|
ServerConfigResponse,
|
||||||
ThirdPartyServerConfigResponse,
|
ThirdPartyServerConfigResponse,
|
||||||
@@ -50,6 +51,7 @@ export class ThirdPartyServerConfigData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class EnvironmentServerConfigData {
|
export class EnvironmentServerConfigData {
|
||||||
|
cloudRegion: Region;
|
||||||
vault: string;
|
vault: string;
|
||||||
api: string;
|
api: string;
|
||||||
identity: string;
|
identity: string;
|
||||||
@@ -57,6 +59,7 @@ export class EnvironmentServerConfigData {
|
|||||||
sso: string;
|
sso: string;
|
||||||
|
|
||||||
constructor(response: Partial<EnvironmentServerConfigResponse>) {
|
constructor(response: Partial<EnvironmentServerConfigResponse>) {
|
||||||
|
this.cloudRegion = response.cloudRegion;
|
||||||
this.vault = response.vault;
|
this.vault = response.vault;
|
||||||
this.api = response.api;
|
this.api = response.api;
|
||||||
this.identity = response.identity;
|
this.identity = response.identity;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { BaseResponse } from "../../../models/response/base.response";
|
import { BaseResponse } from "../../../models/response/base.response";
|
||||||
|
import { Region } from "../../abstractions/environment.service";
|
||||||
|
|
||||||
export class ServerConfigResponse extends BaseResponse {
|
export class ServerConfigResponse extends BaseResponse {
|
||||||
version: string;
|
version: string;
|
||||||
@@ -23,6 +24,7 @@ export class ServerConfigResponse extends BaseResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class EnvironmentServerConfigResponse extends BaseResponse {
|
export class EnvironmentServerConfigResponse extends BaseResponse {
|
||||||
|
cloudRegion: Region;
|
||||||
vault: string;
|
vault: string;
|
||||||
api: string;
|
api: string;
|
||||||
identity: string;
|
identity: string;
|
||||||
@@ -36,6 +38,7 @@ export class EnvironmentServerConfigResponse extends BaseResponse {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.cloudRegion = this.getResponseProperty("CloudRegion");
|
||||||
this.vault = this.getResponseProperty("Vault");
|
this.vault = this.getResponseProperty("Vault");
|
||||||
this.api = this.getResponseProperty("Api");
|
this.api = this.getResponseProperty("Api");
|
||||||
this.identity = this.getResponseProperty("Identity");
|
this.identity = this.getResponseProperty("Identity");
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export class ConfigService implements ConfigServiceAbstraction {
|
|||||||
return serverConfig;
|
return serverConfig;
|
||||||
}
|
}
|
||||||
await this.stateService.setServerConfig(data);
|
await this.stateService.setServerConfig(data);
|
||||||
|
this.environmentService.setCloudWebVaultUrl(data.environment?.cloudRegion);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export class EnvironmentService implements EnvironmentServiceAbstraction {
|
|||||||
protected eventsUrl: string;
|
protected eventsUrl: string;
|
||||||
private keyConnectorUrl: string;
|
private keyConnectorUrl: string;
|
||||||
private scimUrl: string = null;
|
private scimUrl: string = null;
|
||||||
|
private cloudWebVaultUrl: string;
|
||||||
|
|
||||||
readonly usUrls: Urls = {
|
readonly usUrls: Urls = {
|
||||||
base: null,
|
base: null,
|
||||||
@@ -86,6 +87,26 @@ export class EnvironmentService implements EnvironmentServiceAbstraction {
|
|||||||
return "https://vault.bitwarden.com";
|
return "https://vault.bitwarden.com";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCloudWebVaultUrl() {
|
||||||
|
if (this.cloudWebVaultUrl != null) {
|
||||||
|
return this.cloudWebVaultUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.usUrls.webVault;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCloudWebVaultUrl(region: Region) {
|
||||||
|
switch (region) {
|
||||||
|
case Region.EU:
|
||||||
|
this.cloudWebVaultUrl = this.euUrls.webVault;
|
||||||
|
break;
|
||||||
|
case Region.US:
|
||||||
|
default:
|
||||||
|
this.cloudWebVaultUrl = this.usUrls.webVault;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getSendUrl() {
|
getSendUrl() {
|
||||||
return this.getWebVaultUrl() === "https://vault.bitwarden.com"
|
return this.getWebVaultUrl() === "https://vault.bitwarden.com"
|
||||||
? "https://send.bitwarden.com/#"
|
? "https://send.bitwarden.com/#"
|
||||||
@@ -239,6 +260,7 @@ export class EnvironmentService implements EnvironmentServiceAbstraction {
|
|||||||
return {
|
return {
|
||||||
base: this.baseUrl,
|
base: this.baseUrl,
|
||||||
webVault: this.webVaultUrl,
|
webVault: this.webVaultUrl,
|
||||||
|
cloudWebVault: this.cloudWebVaultUrl,
|
||||||
api: this.apiUrl,
|
api: this.apiUrl,
|
||||||
identity: this.identityUrl,
|
identity: this.identityUrl,
|
||||||
icons: this.iconsUrl,
|
icons: this.iconsUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user