Added (optional) publicUrl to vault-backend plugin

Signed-off-by: Casper Thygesen <cth@trifork.com>
This commit is contained in:
Casper Thygesen
2022-12-01 10:33:59 +00:00
parent 80d9674a4a
commit 568ae02463
5 changed files with 22 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-vault-backend': patch
---
Added (optional) publicUrl to editUrl and showUrl in case baseUrl is an internal url
+2 -1
View File
@@ -63,7 +63,8 @@ To get started, first you need a running instance of Vault. You can follow [this
```yaml
vault:
baseUrl: http://your-vault-url
baseUrl: http://your-internal-vault-url.svc
publicUrl: https://your-vault-url.example.com
token: <VAULT_TOKEN>
secretEngine: 'customSecretEngine' # Optional. By default it uses 'secrets'
kvVersion: <kv-version> # Optional. The K/V version that your instance is using. The available options are '1' or '2'
+6
View File
@@ -23,6 +23,12 @@ export interface Config {
*/
baseUrl: string;
/**
* The publicUrl for your Vault instance (Optional).
* @visibility frontend
*/
publicUrl?: string;
/**
* The token used by Backstage to access Vault.
* @visibility secret
@@ -27,6 +27,11 @@ export interface VaultConfig {
*/
baseUrl: string;
/**
* The publicUrl for your Vault instance (Optional).
*/
publicUrl?: string;
/**
* The token used by Backstage to access Vault.
*/
@@ -135,11 +135,13 @@ export class VaultClient implements VaultApi {
)),
);
} else {
const vaultUrl =
this.vaultConfig.publicUrl || this.vaultConfig.baseUrl;
secrets.push({
name: secret,
path: secretPath,
editUrl: `${this.vaultConfig.baseUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}/edit/${secretPath}/${secret}`,
showUrl: `${this.vaultConfig.baseUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}/show/${secretPath}/${secret}`,
editUrl: `${vaultUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}/edit/${secretPath}/${secret}`,
showUrl: `${vaultUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}/show/${secretPath}/${secret}`,
});
}
}),