1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-25 12:15:18 +01:00

[PM-3554] Add support for alias creation via self-hosted SimpleLogin (#6077)

* Add support for alias creation via self-hosted SimpleLogin

* Add forwardedSimpleLoginBaseUrl to username-gen-options type

* Only show Server Url on web if on selfhosted bitwarden

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith 2023-10-23 13:48:15 +02:00 committed by GitHub
parent 55bc275f40
commit 8067b26dc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 1 deletions

View File

@ -353,6 +353,16 @@
(blur)="saveUsernameOptions()" (blur)="saveUsernameOptions()"
/> />
</div> </div>
<div class="box-content-row" appBoxRow>
<label for="simplelogin-baseUrl">{{ "baseUrl" | i18n }}</label>
<input
id="simplelogin-baseUrl"
type="text"
name="SimpleLoginDomain"
[(ngModel)]="usernameOptions.forwardedSimpleLoginBaseUrl"
(blur)="saveUsernameOptions()"
/>
</div>
</ng-container> </ng-container>
<ng-container *ngIf="usernameOptions.forwardedService === 'duckduckgo'"> <ng-container *ngIf="usernameOptions.forwardedService === 'duckduckgo'">
<div class="box-content-row" appBoxRow> <div class="box-content-row" appBoxRow>

View File

@ -380,6 +380,16 @@
(blur)="saveUsernameOptions()" (blur)="saveUsernameOptions()"
/> />
</div> </div>
<div class="box-content-row" appBoxRow>
<label for="simplelogin-baseUrl">{{ "baseUrl" | i18n }}</label>
<input
id="simplelogin-baseUrl"
type="text"
name="SimpleLoginDomain"
[(ngModel)]="usernameOptions.forwardedSimpleLoginBaseUrl"
(blur)="saveUsernameOptions()"
/>
</div>
</ng-container> </ng-container>
<ng-container *ngIf="usernameOptions.forwardedService === 'duckduckgo'"> <ng-container *ngIf="usernameOptions.forwardedService === 'duckduckgo'">
<div class="box-content-row" appBoxRow> <div class="box-content-row" appBoxRow>

View File

@ -283,6 +283,17 @@
(blur)="saveUsernameOptions()" (blur)="saveUsernameOptions()"
/> />
</div> </div>
<div class="form-group col-4" *ngIf="isSelfHosted">
<label for="simplelogin-baseUrl">{{ "baseUrl" | i18n }}</label>
<input
id="simplelogin-baseUrl"
class="form-control"
type="text"
name="SimpleLoginDomain"
[(ngModel)]="usernameOptions.forwardedSimpleLoginBaseUrl"
(blur)="saveUsernameOptions()"
/>
</div>
</div> </div>
<div class="row" *ngIf="usernameOptions.forwardedService === 'duckduckgo'"> <div class="row" *ngIf="usernameOptions.forwardedService === 'duckduckgo'">
<div class="form-group col-4"> <div class="form-group col-4">

View File

@ -4,6 +4,7 @@ export class ForwarderOptions {
fastmail = new FastmailForwarderOptions(); fastmail = new FastmailForwarderOptions();
anonaddy = new AnonAddyForwarderOptions(); anonaddy = new AnonAddyForwarderOptions();
forwardemail = new ForwardEmailForwarderOptions(); forwardemail = new ForwardEmailForwarderOptions();
simplelogin = new SimpleLoginForwarderOptions();
} }
export class FastmailForwarderOptions { export class FastmailForwarderOptions {
@ -18,3 +19,7 @@ export class AnonAddyForwarderOptions {
export class ForwardEmailForwarderOptions { export class ForwardEmailForwarderOptions {
domain: string; domain: string;
} }
export class SimpleLoginForwarderOptions {
baseUrl: string;
}

View File

@ -17,7 +17,7 @@ export class SimpleLoginForwarder implements Forwarder {
"Content-Type": "application/json", "Content-Type": "application/json",
}), }),
}; };
let url = "https://app.simplelogin.io/api/alias/random/new"; let url = options.simplelogin.baseUrl + "/api/alias/random/new";
if (options.website != null) { if (options.website != null) {
url += "?hostname=" + options.website; url += "?hostname=" + options.website;
} }

View File

@ -17,4 +17,5 @@ export type UsernameGeneratorOptions = {
forwardedForwardEmailApiToken?: string; forwardedForwardEmailApiToken?: string;
forwardedForwardEmailDomain?: string; forwardedForwardEmailDomain?: string;
forwardedSimpleLoginApiKey?: string; forwardedSimpleLoginApiKey?: string;
forwardedSimpleLoginBaseUrl?: string;
}; };

View File

@ -26,6 +26,7 @@ const DefaultOptions: UsernameGeneratorOptions = {
forwardedAnonAddyDomain: "anonaddy.me", forwardedAnonAddyDomain: "anonaddy.me",
forwardedAnonAddyBaseUrl: "https://app.addy.io", forwardedAnonAddyBaseUrl: "https://app.addy.io",
forwardedForwardEmailDomain: "hideaddress.net", forwardedForwardEmailDomain: "hideaddress.net",
forwardedSimpleLoginBaseUrl: "https://app.simplelogin.io",
}; };
export class UsernameGenerationService implements UsernameGenerationServiceAbstraction { export class UsernameGenerationService implements UsernameGenerationServiceAbstraction {
@ -128,6 +129,7 @@ export class UsernameGenerationService implements UsernameGenerationServiceAbstr
if (o.forwardedService === "simplelogin") { if (o.forwardedService === "simplelogin") {
forwarder = new SimpleLoginForwarder(); forwarder = new SimpleLoginForwarder();
forwarderOptions.apiKey = o.forwardedSimpleLoginApiKey; forwarderOptions.apiKey = o.forwardedSimpleLoginApiKey;
forwarderOptions.simplelogin.baseUrl = o.forwardedSimpleLoginBaseUrl;
} else if (o.forwardedService === "anonaddy") { } else if (o.forwardedService === "anonaddy") {
forwarder = new AnonAddyForwarder(); forwarder = new AnonAddyForwarder();
forwarderOptions.apiKey = o.forwardedAnonAddyApiToken; forwarderOptions.apiKey = o.forwardedAnonAddyApiToken;