Skip to content

Commit 8f97640

Browse files
authored
Merge pull request #11 from jjlin/alt-base
Add web vault support for alternate base dir (subdir/subpath) hosting
2 parents e5bec69 + 4bd042a commit 8f97640

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

patches/v2.12.0.patch

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts
2+
index a92bf70c..0ebcfc8f 100644
3+
--- a/src/app/services/services.module.ts
4+
+++ b/src/app/services/services.module.ts
5+
@@ -123,22 +123,31 @@ const environmentService = new EnvironmentService(apiService, storageService, no
6+
const auditService = new AuditService(cryptoFunctionService, apiService);
7+
const eventLoggingService = new EventLoggingService(storageService, apiService, userService, cipherService);
8+
9+
-const analytics = new Analytics(window, () => platformUtilsService.isDev() || platformUtilsService.isSelfHost(),
10+
+const analytics = new Analytics(window, () => platformUtilsService.isDev() || platformUtilsService.isSelfHost() || true,
11+
platformUtilsService, storageService, appIdService);
12+
containerService.attachToWindow(window);
13+
14+
export function initFactory(): Function {
15+
+ function getBaseUrl() {
16+
+ // If the base URL is `https://bitwarden.example.com/base/path/`,
17+
+ // `window.location.href` should have one of the following forms:
18+
+ //
19+
+ // - `https://bitwarden.example.com/base/path/`
20+
+ // - `https://bitwarden.example.com/base/path/#/some/endpoint[?queryParam=...]`
21+
+ //
22+
+ // We want to get to just `https://bitwarden.example.com/base/path`.
23+
+ let baseUrl = window.location.href;
24+
+ baseUrl = baseUrl.replace(/#.*/, ''); // Strip off `#` and everything after.
25+
+ baseUrl = baseUrl.replace(/\/+$/, ''); // Trim any trailing `/` chars.
26+
+ return baseUrl;
27+
+ }
28+
return async () => {
29+
await (storageService as HtmlStorageService).init();
30+
- const isDev = platformUtilsService.isDev();
31+
- if (!isDev && platformUtilsService.isSelfHost()) {
32+
- environmentService.baseUrl = window.location.origin;
33+
- } else {
34+
- environmentService.notificationsUrl = isDev ? 'http://localhost:61840' :
35+
- 'https://notifications.bitwarden.com'; // window.location.origin + '/notifications';
36+
- }
37+
+ const isDev = false;
38+
+ environmentService.baseUrl = getBaseUrl();
39+
+ environmentService.notificationsUrl = environmentService.baseUrl + '/notifications';
40+
apiService.setUrls({
41+
- base: isDev ? null : window.location.origin,
42+
+ base: isDev ? null : environmentService.baseUrl,
43+
api: isDev ? 'http://localhost:4000' : null,
44+
identity: isDev ? 'http://localhost:33656' : null,
45+
events: isDev ? 'http://localhost:46273' : null,
46+
diff --git a/src/app/settings/two-factor-u2f.component.ts b/src/app/settings/two-factor-u2f.component.ts
47+
index 5560c476..a9b954a8 100644
48+
--- a/src/app/settings/two-factor-u2f.component.ts
49+
+++ b/src/app/settings/two-factor-u2f.component.ts
50+
@@ -128,6 +128,7 @@ export class TwoFactorU2fComponent extends TwoFactorBaseComponent implements OnI
51+
(window as any).u2f.register(u2fChallenge.appId, [{
52+
version: u2fChallenge.version,
53+
challenge: u2fChallenge.challenge,
54+
+ attestation: 'direct',
55+
}], [], (data: any) => {
56+
this.ngZone.run(() => {
57+
this.u2fListening = false;
58+
diff --git a/src/scss/styles.scss b/src/scss/styles.scss
59+
index 2e1dbec9..9f01a7b9 100644
60+
--- a/src/scss/styles.scss
61+
+++ b/src/scss/styles.scss
62+
@@ -1,5 +1,31 @@
63+
@import "../css/webfonts.css";
64+
65+
+/**** START Bitwarden_RS CHANGES ****/
66+
+/* This combines all selectors extending it into one */
67+
+%bwrs-hide { display: none !important; }
68+
+
69+
+/* This allows searching for the combined style in the browsers dev-tools (look into the head tag) */
70+
+#bwrs-hide, head { @extend %bwrs-hide; }
71+
+
72+
+/* Hide any link pointing to billing */
73+
+a[href$="/settings/billing"] { @extend %bwrs-hide; }
74+
+
75+
+/* Hide any link pointing to subscriptions */
76+
+a[href$="/settings/subscription"] { @extend %bwrs-hide; }
77+
+
78+
+/* Hide Two-Factor menu in Organization settings */
79+
+app-org-settings a[href$="/settings/two-factor"] { @extend %bwrs-hide; }
80+
+
81+
+/* Hide organization plans */
82+
+app-organization-plans > form > div.form-check { @extend %bwrs-hide; }
83+
+app-organization-plans > form > h2.mt-5 { @extend %bwrs-hide; }
84+
+
85+
+/* Hide Tax Info in Organization settings */
86+
+app-org-account > div.secondary-header.border-0.mb-0:nth-child(3) { @extend %bwrs-hide; }
87+
+app-org-account > p { @extend %bwrs-hide; }
88+
+app-org-account > a.btn.btn-outline-secondary { @extend %bwrs-hide; }
89+
+/**** END Bitwarden_RS CHANGES ****/
90+
+
91+
$primary: #3c8dbc;
92+
$primary-accent: #286090;
93+
$secondary: #ced4da;
94+
diff --git a/webpack.config.js b/webpack.config.js
95+
index aecb1860..44acdc1d 100644
96+
--- a/webpack.config.js
97+
+++ b/webpack.config.js
98+
@@ -170,6 +170,7 @@ const config = {
99+
},
100+
minimizer: [
101+
new TerserPlugin({
102+
+ sourceMap: true,
103+
terserOptions: {
104+
safari10: true,
105+
},

0 commit comments

Comments
 (0)