@backstage-community/plugin-vault 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @backstage-community/plugin-vault
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7ad5206: Added support for multiple secrets paths
8
+
9
+ ## 0.16.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 84e3915: Backstage version bump to v1.47.2
14
+
3
15
  ## 0.15.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -44,6 +44,7 @@ To get started, first you need a running instance of Vault. You can follow [this
44
44
  token: <VAULT_TOKEN>
45
45
  secretEngine: 'customSecretEngine' # Optional. By default it uses 'secrets'. Can be overwritten by the annotation of the entity
46
46
  kvVersion: <kv-version> # Optional. The K/V version that your instance is using. The available options are '1' or '2'
47
+ secretSuffix: 'config' # Optional. Suffix to append to the secret path when creating new secrets (e.g., 'config')
47
48
  ```
48
49
 
49
50
  4. Get a `VAULT_TOKEN` with **LIST** permissions, as it's enough for the plugin. You can check [this tutorial](https://learn.hashicorp.com/tutorials/vault/tokens) for more info.
@@ -98,6 +99,20 @@ metadata:
98
99
  vault.io/secrets-engine: customSecretEngine # Optional. By default it uses the 'secretEngine' value from your app-config.
99
100
  ```
100
101
 
102
+ ### Multiple Secret Paths
103
+
104
+ You can also specify multiple secret paths separated by commas. Each path will be displayed in the Vault table:
105
+
106
+ ```yaml
107
+ apiVersion: backstage.io/v1alpha1
108
+ kind: Component
109
+ metadata:
110
+ # ...
111
+ annotations:
112
+ vault.io/secrets-path: path/to/secrets,another/path,third/path
113
+ vault.io/secrets-engine: customSecretEngine # Optional. By default it uses the 'secretEngine' value from your app-config.
114
+ ```
115
+
101
116
  The path is relative to your secrets engine folder. So if you want to get the secrets for backstage and you have the following directory structure:
102
117
 
103
118
  .
package/dist/api.esm.js CHANGED
@@ -37,11 +37,36 @@ class VaultClient {
37
37
  if (secretEngine) {
38
38
  query.engine = secretEngine;
39
39
  }
40
- const result = await this.callApi(
41
- `v1/secrets/${encodeURIComponent(secretPath)}`,
42
- query
40
+ const result = await this.callApi(`v1/secrets/${encodeURIComponent(secretPath)}`, query);
41
+ return {
42
+ secrets: result.items,
43
+ vaultUrl: result.vaultUrl,
44
+ createUrl: result.createUrl
45
+ };
46
+ }
47
+ /**
48
+ * Returns the createUrl for a secret path using the dedicated backend route.
49
+ */
50
+ async getCreateUrl(secretPath, options) {
51
+ const query = {};
52
+ const { secretEngine } = options || {};
53
+ if (secretEngine) {
54
+ query.engine = secretEngine;
55
+ }
56
+ const apiUrl = `${await this.discoveryApi.getBaseUrl("vault")}`;
57
+ const response = await this.fetchApi.fetch(
58
+ `${apiUrl}/v1/secrets/${encodeURIComponent(
59
+ secretPath
60
+ )}/create-url?${new URLSearchParams(query).toString()}`,
61
+ {
62
+ headers: {
63
+ Accept: "application/json"
64
+ }
65
+ }
43
66
  );
44
- return result.items;
67
+ if (!response.ok) return void 0;
68
+ const data = await response.json();
69
+ return data.createUrl;
45
70
  }
46
71
  }
47
72
 
@@ -1 +1 @@
1
- {"version":3,"file":"api.esm.js","sources":["../src/api.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n DiscoveryApi,\n createApiRef,\n FetchApi,\n} from '@backstage/core-plugin-api';\nimport { NotFoundError, ResponseError } from '@backstage/errors';\n\n/**\n * @public\n */\nexport const vaultApiRef = createApiRef<VaultApi>({\n id: 'plugin.vault.service',\n});\n\n/**\n * Object containing the secret name and some links.\n * @public\n */\nexport type VaultSecret = {\n name: string;\n path: string;\n showUrl: string;\n editUrl: string;\n};\n\n/**\n * Interface for the VaultApi.\n * @public\n */\nexport interface VaultApi {\n /**\n * Returns a list of secrets used to show in a table.\n * @param secretPath - The path where the secrets are stored in Vault\n * @param options - Additional options to be passed to the Vault API, allows to override vault default settings in app config file\n */\n listSecrets(\n secretPath: string,\n options?: {\n secretEngine?: string;\n },\n ): Promise<VaultSecret[]>;\n}\n\n/**\n * Default implementation of the VaultApi.\n * @public\n */\nexport class VaultClient implements VaultApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor({\n discoveryApi,\n fetchApi,\n }: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n }) {\n this.discoveryApi = discoveryApi;\n this.fetchApi = fetchApi;\n }\n\n private async callApi<T>(\n path: string,\n query: { [key in string]: any },\n ): Promise<T> {\n const apiUrl = `${await this.discoveryApi.getBaseUrl('vault')}`;\n const response = await this.fetchApi.fetch(\n `${apiUrl}/${path}?${new URLSearchParams(query).toString()}`,\n {\n headers: {\n Accept: 'application/json',\n },\n },\n );\n if (response.ok) {\n return (await response.json()) as T;\n } else if (response.status === 404) {\n throw new NotFoundError(`No secrets found in path '${path}'`);\n }\n throw await ResponseError.fromResponse(response);\n }\n\n async listSecrets(\n secretPath: string,\n options?: {\n secretEngine?: string;\n },\n ): Promise<VaultSecret[]> {\n const query: { [key in string]: any } = {};\n const { secretEngine } = options || {};\n if (secretEngine) {\n query.engine = secretEngine;\n }\n\n const result = await this.callApi<{ items: VaultSecret[] }>(\n `v1/secrets/${encodeURIComponent(secretPath)}`,\n query,\n );\n return result.items;\n }\n}\n"],"names":[],"mappings":";;;AAyBO,MAAM,cAAc,YAAuB,CAAA;AAAA,EAChD,EAAI,EAAA;AACN,CAAC;AAmCM,MAAM,WAAgC,CAAA;AAAA,EAC1B,YAAA;AAAA,EACA,QAAA;AAAA,EAEj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,MAC5C;AAAA,KACF;AACA,IAAA,OAAO,MAAO,CAAA,KAAA;AAAA;AAElB;;;;"}
1
+ {"version":3,"file":"api.esm.js","sources":["../src/api.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n DiscoveryApi,\n createApiRef,\n FetchApi,\n} from '@backstage/core-plugin-api';\nimport { NotFoundError, ResponseError } from '@backstage/errors';\n\n/**\n * @public\n */\nexport const vaultApiRef = createApiRef<VaultApi>({\n id: 'plugin.vault.service',\n});\n\n/**\n * Object containing the secret name and some links.\n * @public\n */\nexport type VaultSecret = {\n name: string;\n path: string;\n showUrl: string;\n editUrl: string;\n};\n\n/**\n * Response from listSecrets API call\n * @public\n */\nexport type ListSecretsResponse = {\n secrets: VaultSecret[];\n vaultUrl?: string;\n createUrl?: string;\n};\n\n/**\n * Interface for the VaultApi.\n * @public\n */\nexport interface VaultApi {\n /**\n * Returns a list of secrets used to show in a table along with vault URLs.\n * @param secretPath - The path where the secrets are stored in Vault\n * @param options - Additional options to be passed to the Vault API, allows to override vault default settings in app config file\n */\n listSecrets(\n secretPath: string,\n options?: {\n secretEngine?: string;\n },\n ): Promise<ListSecretsResponse>;\n\n getCreateUrl(\n secretPath: string,\n options?: {\n secretEngine?: string;\n },\n ): Promise<string | undefined>;\n}\n\n/**\n * Default implementation of the VaultApi.\n * @public\n */\nexport class VaultClient implements VaultApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor({\n discoveryApi,\n fetchApi,\n }: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n }) {\n this.discoveryApi = discoveryApi;\n this.fetchApi = fetchApi;\n }\n\n private async callApi<T>(\n path: string,\n query: { [key in string]: any },\n ): Promise<T> {\n const apiUrl = `${await this.discoveryApi.getBaseUrl('vault')}`;\n const response = await this.fetchApi.fetch(\n `${apiUrl}/${path}?${new URLSearchParams(query).toString()}`,\n {\n headers: {\n Accept: 'application/json',\n },\n },\n );\n if (response.ok) {\n return (await response.json()) as T;\n } else if (response.status === 404) {\n throw new NotFoundError(`No secrets found in path '${path}'`);\n }\n throw await ResponseError.fromResponse(response);\n }\n\n async listSecrets(\n secretPath: string,\n options?: {\n secretEngine?: string;\n },\n ): Promise<ListSecretsResponse> {\n const query: { [key in string]: any } = {};\n const { secretEngine } = options || {};\n if (secretEngine) {\n query.engine = secretEngine;\n }\n\n const result = await this.callApi<{\n items: VaultSecret[];\n vaultUrl?: string;\n createUrl?: string;\n }>(`v1/secrets/${encodeURIComponent(secretPath)}`, query);\n return {\n secrets: result.items,\n vaultUrl: result.vaultUrl,\n createUrl: result.createUrl,\n };\n }\n\n /**\n * Returns the createUrl for a secret path using the dedicated backend route.\n */\n async getCreateUrl(\n secretPath: string,\n options?: { secretEngine?: string },\n ): Promise<string | undefined> {\n const query: { [key in string]: any } = {};\n const { secretEngine } = options || {};\n if (secretEngine) {\n query.engine = secretEngine;\n }\n const apiUrl = `${await this.discoveryApi.getBaseUrl('vault')}`;\n const response = await this.fetchApi.fetch(\n `${apiUrl}/v1/secrets/${encodeURIComponent(\n secretPath,\n )}/create-url?${new URLSearchParams(query).toString()}`,\n {\n headers: {\n Accept: 'application/json',\n },\n },\n );\n if (!response.ok) return undefined;\n const data = await response.json();\n return data.createUrl;\n }\n}\n"],"names":[],"mappings":";;;AAyBO,MAAM,cAAc,YAAuB,CAAA;AAAA,EAChD,EAAI,EAAA;AACN,CAAC;AAoDM,MAAM,WAAgC,CAAA;AAAA,EAC1B,YAAA;AAAA,EACA,QAAA;AAAA,EAEjB,WAAY,CAAA;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;AAAA,MACL,SAAS,MAAO,CAAA,KAAA;AAAA,MAChB,UAAU,MAAO,CAAA,QAAA;AAAA,MACjB,WAAW,MAAO,CAAA;AAAA,KACpB;AAAA;AACF;AAAA;AAAA;AAAA,EAKA,MAAM,YACJ,CAAA,UAAA,EACA,OAC6B,EAAA;AAC7B,IAAA,MAAM,QAAkC,EAAC;AACzC,IAAA,MAAM,EAAE,YAAA,EAAiB,GAAA,OAAA,IAAW,EAAC;AACrC,IAAA,IAAI,YAAc,EAAA;AAChB,MAAA,KAAA,CAAM,MAAS,GAAA,YAAA;AAAA;AAEjB,IAAA,MAAM,SAAS,CAAG,EAAA,MAAM,KAAK,YAAa,CAAA,UAAA,CAAW,OAAO,CAAC,CAAA,CAAA;AAC7D,IAAM,MAAA,QAAA,GAAW,MAAM,IAAA,CAAK,QAAS,CAAA,KAAA;AAAA,MACnC,CAAA,EAAG,MAAM,CAAe,YAAA,EAAA,kBAAA;AAAA,QACtB;AAAA,OACD,CAAe,YAAA,EAAA,IAAI,gBAAgB,KAAK,CAAA,CAAE,UAAU,CAAA,CAAA;AAAA,MACrD;AAAA,QACE,OAAS,EAAA;AAAA,UACP,MAAQ,EAAA;AAAA;AACV;AACF,KACF;AACA,IAAI,IAAA,CAAC,QAAS,CAAA,EAAA,EAAW,OAAA,KAAA,CAAA;AACzB,IAAM,MAAA,IAAA,GAAO,MAAM,QAAA,CAAS,IAAK,EAAA;AACjC,IAAA,OAAO,IAAK,CAAA,SAAA;AAAA;AAEhB;;;;"}
@@ -11,64 +11,98 @@ import { vaultApiRef } from '../../api.esm.js';
11
11
  import { VAULT_SECRET_PATH_ANNOTATION, VAULT_SECRET_ENGINE_ANNOTATION } from '../../constants.esm.js';
12
12
 
13
13
  const vaultSecretConfig = (entity) => {
14
- const secretPath = entity.metadata.annotations?.[VAULT_SECRET_PATH_ANNOTATION];
14
+ const secretPathAnnotation = entity.metadata.annotations?.[VAULT_SECRET_PATH_ANNOTATION];
15
+ const secretPaths = secretPathAnnotation ? secretPathAnnotation.split(",").map((path) => path.trim()).filter(Boolean) : [];
15
16
  const secretEngine = entity.metadata.annotations?.[VAULT_SECRET_ENGINE_ANNOTATION];
16
- return { secretPath, secretEngine };
17
+ return { secretPaths, secretEngine };
17
18
  };
18
19
  const EntityVaultTable = ({ entity }) => {
19
20
  const vaultApi = useApi(vaultApiRef);
20
- const { secretPath, secretEngine } = vaultSecretConfig(entity);
21
- if (!secretPath) {
21
+ const { secretPaths, secretEngine } = vaultSecretConfig(entity);
22
+ if (!secretPaths || secretPaths.length === 0) {
22
23
  throw Error(
23
24
  `The secret path is undefined. Please, define the annotation ${VAULT_SECRET_PATH_ANNOTATION}`
24
25
  );
25
26
  }
26
27
  const { value, loading, error } = useAsync(async () => {
27
- return vaultApi.listSecrets(secretPath, { secretEngine });
28
+ const results = await Promise.all(
29
+ secretPaths.map(async (path) => {
30
+ const response = await vaultApi.listSecrets(path, { secretEngine }).catch(() => ({
31
+ secrets: []
32
+ }));
33
+ let createUrl = void 0;
34
+ if (response.secrets.length === 0) {
35
+ createUrl = await vaultApi.getCreateUrl?.(path, { secretEngine });
36
+ }
37
+ return {
38
+ path,
39
+ secrets: response.secrets,
40
+ createUrl
41
+ };
42
+ })
43
+ );
44
+ return results;
28
45
  }, []);
29
46
  const columns = [
47
+ { title: "Path", field: "path", width: "20%" },
30
48
  { title: "Secret", field: "secret", highlight: true },
31
- { title: "View URL", field: "view", width: "10%" },
32
- { title: "Edit URL", field: "edit", width: "10%" }
49
+ { title: "View", field: "view", width: "10%" },
50
+ { title: "Edit", field: "edit", width: "10%" }
33
51
  ];
34
- const data = (value || []).map((secret) => {
35
- const secretName = `${secret.path.replace(`${secretPath}/`, "")}/${secret.name}`;
36
- return {
37
- secret: secretName,
38
- view: /* @__PURE__ */ jsx(
39
- Link,
40
- {
41
- "aria-label": "View",
42
- title: `View ${secretName}`,
43
- to: secret.showUrl,
44
- children: /* @__PURE__ */ jsx(Visibility, { style: { fontSize: 16 } })
45
- }
46
- ),
47
- edit: /* @__PURE__ */ jsx(
48
- Link,
49
- {
50
- "aria-label": "Edit",
51
- title: `Edit ${secretName}`,
52
- to: secret.editUrl,
53
- children: /* @__PURE__ */ jsx(Edit, { style: { fontSize: 16 } })
54
- }
55
- )
56
- };
52
+ const data = [];
53
+ (value || []).forEach(({ path, secrets, createUrl }) => {
54
+ if (secrets.length === 0) {
55
+ data.push({
56
+ path,
57
+ secret: /* @__PURE__ */ jsxs(Typography, { variant: "body2", color: "textSecondary", children: [
58
+ "No secrets, ",
59
+ /* @__PURE__ */ jsx(Link, { to: createUrl || "", children: "create one" })
60
+ ] }),
61
+ view: null,
62
+ edit: null
63
+ });
64
+ } else {
65
+ secrets.forEach((secret, index) => {
66
+ const secretName = `${secret.path.replace(`${path}/`, "")}/${secret.name}`;
67
+ data.push({
68
+ path: index === 0 ? path : "",
69
+ secret: secretName,
70
+ view: /* @__PURE__ */ jsx(
71
+ Link,
72
+ {
73
+ "aria-label": "View",
74
+ title: `View ${secretName}`,
75
+ to: secret.showUrl,
76
+ children: /* @__PURE__ */ jsx(Visibility, { style: { fontSize: 16 } })
77
+ }
78
+ ),
79
+ edit: /* @__PURE__ */ jsx(
80
+ Link,
81
+ {
82
+ "aria-label": "Edit",
83
+ title: `Edit ${secretName}`,
84
+ to: secret.editUrl,
85
+ children: /* @__PURE__ */ jsx(Edit, { style: { fontSize: 16 } })
86
+ }
87
+ )
88
+ });
89
+ });
90
+ }
57
91
  });
58
92
  if (error) {
59
93
  return /* @__PURE__ */ jsxs(Alert, { severity: "error", children: [
60
- "Unexpected error while fetching secrets from path '",
61
- secretPath,
62
- "':",
63
- " ",
94
+ "Unexpected error while fetching secrets from path(s) '",
95
+ secretPaths.join(", "),
96
+ "': ",
64
97
  error.message
65
98
  ] });
66
99
  }
100
+ const subtitle = secretPaths.length === 1 ? `Secrets for ${entity.metadata.name} in ${secretPaths[0]}` : `Secrets for ${entity.metadata.name} in ${secretPaths.length} paths`;
67
101
  return /* @__PURE__ */ jsx(
68
102
  Table,
69
103
  {
70
104
  title: "Vault",
71
- subtitle: `Secrets for ${entity.metadata.name} in ${secretPath}`,
105
+ subtitle,
72
106
  columns,
73
107
  data,
74
108
  isLoading: loading,
@@ -81,8 +115,9 @@ const EntityVaultTable = ({ entity }) => {
81
115
  emptyContent: /* @__PURE__ */ jsx(Box, { style: { textAlign: "center", padding: "15px" }, children: /* @__PURE__ */ jsxs(Typography, { variant: "body1", children: [
82
116
  "No secrets found for ",
83
117
  entity.metadata.name,
84
- " in ",
85
- secretPath
118
+ " in",
119
+ " ",
120
+ secretPaths.join(", ")
86
121
  ] }) })
87
122
  }
88
123
  );
@@ -1 +1 @@
1
- {"version":3,"file":"EntityVaultTable.esm.js","sources":["../../../src/components/EntityVaultTable/EntityVaultTable.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Entity } from '@backstage/catalog-model';\nimport { Link, Table, TableColumn } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport Box from '@material-ui/core/Box';\nimport Typography from '@material-ui/core/Typography';\nimport Edit from '@material-ui/icons/Edit';\nimport Visibility from '@material-ui/icons/Visibility';\nimport Alert from '@material-ui/lab/Alert';\nimport useAsync from 'react-use/esm/useAsync';\nimport { VaultSecret, vaultApiRef } from '../../api';\nimport {\n VAULT_SECRET_ENGINE_ANNOTATION,\n VAULT_SECRET_PATH_ANNOTATION,\n} from '../../constants';\n\nexport const vaultSecretConfig = (entity: Entity) => {\n const secretPath =\n entity.metadata.annotations?.[VAULT_SECRET_PATH_ANNOTATION];\n const secretEngine =\n entity.metadata.annotations?.[VAULT_SECRET_ENGINE_ANNOTATION];\n\n return { secretPath, secretEngine };\n};\n\nexport const EntityVaultTable = ({ entity }: { entity: Entity }) => {\n const vaultApi = useApi(vaultApiRef);\n const { secretPath, secretEngine } = vaultSecretConfig(entity);\n if (!secretPath) {\n throw Error(\n `The secret path is undefined. Please, define the annotation ${VAULT_SECRET_PATH_ANNOTATION}`,\n );\n }\n\n const { value, loading, error } = useAsync(async (): Promise<\n VaultSecret[]\n > => {\n return vaultApi.listSecrets(secretPath, { secretEngine });\n }, []);\n\n const columns: TableColumn[] = [\n { title: 'Secret', field: 'secret', highlight: true },\n { title: 'View URL', field: 'view', width: '10%' },\n { title: 'Edit URL', field: 'edit', width: '10%' },\n ];\n\n const data = (value || []).map(secret => {\n const secretName = `${secret.path.replace(`${secretPath}/`, '')}/${\n secret.name\n }`;\n\n return {\n secret: secretName,\n view: (\n <Link\n aria-label=\"View\"\n title={`View ${secretName}`}\n to={secret.showUrl}\n >\n <Visibility style={{ fontSize: 16 }} />\n </Link>\n ),\n edit: (\n <Link\n aria-label=\"Edit\"\n title={`Edit ${secretName}`}\n to={secret.editUrl}\n >\n <Edit style={{ fontSize: 16 }} />\n </Link>\n ),\n };\n });\n\n if (error) {\n return (\n <Alert severity=\"error\">\n Unexpected error while fetching secrets from path '{secretPath}':{' '}\n {error.message}\n </Alert>\n );\n }\n\n return (\n <Table\n title=\"Vault\"\n subtitle={`Secrets for ${entity.metadata.name} in ${secretPath}`}\n columns={columns}\n data={data}\n isLoading={loading}\n options={{\n padding: 'dense',\n pageSize: 10,\n emptyRowsWhenPaging: false,\n search: false,\n }}\n emptyContent={\n <Box style={{ textAlign: 'center', padding: '15px' }}>\n <Typography variant=\"body1\">\n No secrets found for {entity.metadata.name} in {secretPath}\n </Typography>\n </Box>\n }\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA8Ba,MAAA,iBAAA,GAAoB,CAAC,MAAmB,KAAA;AACnD,EAA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AA;AAAA,OACV;AAAA,MACA,YACE,kBAAA,GAAA,CAAC,GAAI,EAAA,EAAA,KAAA,EAAO,EAAE,SAAA,EAAW,QAAU,EAAA,OAAA,EAAS,MAAO,EAAA,EACjD,QAAC,kBAAA,IAAA,CAAA,UAAA,EAAA,EAAW,SAAQ,OAAQ,EAAA,QAAA,EAAA;AAAA,QAAA,uBAAA;AAAA,QACJ,OAAO,QAAS,CAAA,IAAA;AAAA,QAAK,MAAA;AAAA,QAAK;AAAA,OAAA,EAClD,CACF,EAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
1
+ {"version":3,"file":"EntityVaultTable.esm.js","sources":["../../../src/components/EntityVaultTable/EntityVaultTable.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Entity } from '@backstage/catalog-model';\nimport { Link, Table, TableColumn } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport Box from '@material-ui/core/Box';\nimport Typography from '@material-ui/core/Typography';\nimport Edit from '@material-ui/icons/Edit';\nimport Visibility from '@material-ui/icons/Visibility';\nimport Alert from '@material-ui/lab/Alert';\nimport useAsync from 'react-use/esm/useAsync';\nimport { VaultSecret, vaultApiRef } from '../../api';\nimport {\n VAULT_SECRET_ENGINE_ANNOTATION,\n VAULT_SECRET_PATH_ANNOTATION,\n} from '../../constants';\n\nexport const vaultSecretConfig = (entity: Entity) => {\n const secretPathAnnotation =\n entity.metadata.annotations?.[VAULT_SECRET_PATH_ANNOTATION];\n const secretPaths = secretPathAnnotation\n ? secretPathAnnotation\n .split(',')\n .map(path => path.trim())\n .filter(Boolean)\n : [];\n const secretEngine =\n entity.metadata.annotations?.[VAULT_SECRET_ENGINE_ANNOTATION];\n\n return { secretPaths, secretEngine };\n};\n\nexport const EntityVaultTable = ({ entity }: { entity: Entity }) => {\n const vaultApi = useApi(vaultApiRef);\n const { secretPaths, secretEngine } = vaultSecretConfig(entity);\n if (!secretPaths || secretPaths.length === 0) {\n throw Error(\n `The secret path is undefined. Please, define the annotation ${VAULT_SECRET_PATH_ANNOTATION}`,\n );\n }\n\n const { value, loading, error } = useAsync(async (): Promise<\n { path: string; secrets: VaultSecret[]; createUrl?: string }[]\n > => {\n const results = await Promise.all(\n secretPaths.map(async path => {\n const response = await vaultApi\n .listSecrets(path, { secretEngine })\n .catch(() => ({\n secrets: [],\n }));\n\n let createUrl: string | undefined = undefined;\n if (response.secrets.length === 0) {\n createUrl = await vaultApi.getCreateUrl?.(path, { secretEngine });\n }\n return {\n path,\n secrets: response.secrets,\n createUrl,\n };\n }),\n );\n return results;\n }, []);\n\n const columns: TableColumn[] = [\n { title: 'Path', field: 'path', width: '20%' },\n { title: 'Secret', field: 'secret', highlight: true },\n { title: 'View', field: 'view', width: '10%' },\n { title: 'Edit', field: 'edit', width: '10%' },\n ];\n\n const data: any[] = [];\n\n (value || []).forEach(({ path, secrets, createUrl }) => {\n if (secrets.length === 0) {\n // No secrets in this path - show a link to create one\n data.push({\n path,\n secret: (\n <Typography variant=\"body2\" color=\"textSecondary\">\n No secrets, <Link to={createUrl || ''}>create one</Link>\n </Typography>\n ),\n view: null,\n edit: null,\n });\n } else {\n secrets.forEach((secret, index) => {\n const secretName = `${secret.path.replace(`${path}/`, '')}/${\n secret.name\n }`;\n data.push({\n path: index === 0 ? path : '',\n secret: secretName,\n view: (\n <Link\n aria-label=\"View\"\n title={`View ${secretName}`}\n to={secret.showUrl}\n >\n <Visibility style={{ fontSize: 16 }} />\n </Link>\n ),\n edit: (\n <Link\n aria-label=\"Edit\"\n title={`Edit ${secretName}`}\n to={secret.editUrl}\n >\n <Edit style={{ fontSize: 16 }} />\n </Link>\n ),\n });\n });\n }\n });\n\n if (error) {\n return (\n <Alert severity=\"error\">\n Unexpected error while fetching secrets from path(s) '\n {secretPaths.join(', ')}': {error.message}\n </Alert>\n );\n }\n\n const subtitle =\n secretPaths.length === 1\n ? `Secrets for ${entity.metadata.name} in ${secretPaths[0]}`\n : `Secrets for ${entity.metadata.name} in ${secretPaths.length} paths`;\n\n return (\n <Table\n title=\"Vault\"\n subtitle={subtitle}\n columns={columns}\n data={data}\n isLoading={loading}\n options={{\n padding: 'dense',\n pageSize: 10,\n emptyRowsWhenPaging: false,\n search: false,\n }}\n emptyContent={\n <Box style={{ textAlign: 'center', padding: '15px' }}>\n <Typography variant=\"body1\">\n No secrets found for {entity.metadata.name} in{' '}\n {secretPaths.join(', ')}\n </Typography>\n </Box>\n }\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA8Ba,MAAA,iBAAA,GAAoB,CAAC,MAAmB,KAAA;AACnD,EAAA,MAAM,oBACJ,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,4BAA4B,CAAA;AAC5D,EAAA,MAAM,WAAc,GAAA,oBAAA,GAChB,oBACG,CAAA,KAAA,CAAM,GAAG,CACT,CAAA,GAAA,CAAI,CAAQ,IAAA,KAAA,IAAA,CAAK,MAAM,CAAA,CACvB,MAAO,CAAA,OAAO,IACjB,EAAC;AACL,EAAA,MAAM,YACJ,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,8BAA8B,CAAA;AAE9D,EAAO,OAAA,EAAE,aAAa,YAAa,EAAA;AACrC;AAEO,MAAM,gBAAmB,GAAA,CAAC,EAAE,MAAA,EAAiC,KAAA;AAClE,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAA,MAAM,EAAE,WAAA,EAAa,YAAa,EAAA,GAAI,kBAAkB,MAAM,CAAA;AAC9D,EAAA,IAAI,CAAC,WAAA,IAAe,WAAY,C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A,UAAA,EAAA,EAAW,SAAQ,OAAQ,EAAA,QAAA,EAAA;AAAA,QAAA,uBAAA;AAAA,QACJ,OAAO,QAAS,CAAA,IAAA;AAAA,QAAK,KAAA;AAAA,QAAI,GAAA;AAAA,QAC9C,WAAA,CAAY,KAAK,IAAI;AAAA,OAAA,EACxB,CACF,EAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
package/dist/index.d.ts CHANGED
@@ -41,19 +41,31 @@ type VaultSecret = {
41
41
  showUrl: string;
42
42
  editUrl: string;
43
43
  };
44
+ /**
45
+ * Response from listSecrets API call
46
+ * @public
47
+ */
48
+ type ListSecretsResponse = {
49
+ secrets: VaultSecret[];
50
+ vaultUrl?: string;
51
+ createUrl?: string;
52
+ };
44
53
  /**
45
54
  * Interface for the VaultApi.
46
55
  * @public
47
56
  */
48
57
  interface VaultApi {
49
58
  /**
50
- * Returns a list of secrets used to show in a table.
59
+ * Returns a list of secrets used to show in a table along with vault URLs.
51
60
  * @param secretPath - The path where the secrets are stored in Vault
52
61
  * @param options - Additional options to be passed to the Vault API, allows to override vault default settings in app config file
53
62
  */
54
63
  listSecrets(secretPath: string, options?: {
55
64
  secretEngine?: string;
56
- }): Promise<VaultSecret[]>;
65
+ }): Promise<ListSecretsResponse>;
66
+ getCreateUrl(secretPath: string, options?: {
67
+ secretEngine?: string;
68
+ }): Promise<string | undefined>;
57
69
  }
58
70
 
59
- export { EntityVaultCard, VAULT_SECRET_PATH_ANNOTATION, type VaultApi, type VaultSecret, isVaultAvailable, vaultApiRef, vaultPlugin };
71
+ export { EntityVaultCard, type ListSecretsResponse, VAULT_SECRET_PATH_ANNOTATION, type VaultApi, type VaultSecret, isVaultAvailable, vaultApiRef, vaultPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-vault",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "A Backstage plugin that integrates towards Vault",
5
5
  "backstage": {
6
6
  "role": "frontend-plugin",
@@ -45,11 +45,11 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@backstage/catalog-model": "^1.7.6",
48
- "@backstage/core-components": "^0.18.4",
49
- "@backstage/core-plugin-api": "^1.12.1",
48
+ "@backstage/core-components": "^0.18.6",
49
+ "@backstage/core-plugin-api": "^1.12.2",
50
50
  "@backstage/errors": "^1.2.7",
51
- "@backstage/frontend-plugin-api": "^0.13.2",
52
- "@backstage/plugin-catalog-react": "^1.21.4",
51
+ "@backstage/frontend-plugin-api": "^0.13.4",
52
+ "@backstage/plugin-catalog-react": "^1.21.6",
53
53
  "@material-ui/core": "^4.12.2",
54
54
  "@material-ui/icons": "^4.9.1",
55
55
  "@material-ui/lab": "4.0.0-alpha.61",
@@ -81,10 +81,10 @@
81
81
  }
82
82
  },
83
83
  "devDependencies": {
84
- "@backstage/cli": "^0.35.1",
85
- "@backstage/core-app-api": "^1.19.3",
86
- "@backstage/dev-utils": "^1.1.18",
87
- "@backstage/plugin-catalog": "^1.32.1",
84
+ "@backstage/cli": "^0.35.3",
85
+ "@backstage/core-app-api": "^1.19.4",
86
+ "@backstage/dev-utils": "^1.1.19",
87
+ "@backstage/plugin-catalog": "^1.32.2",
88
88
  "@backstage/test-utils": "^1.7.14",
89
89
  "@testing-library/dom": "^10.0.0",
90
90
  "@testing-library/jest-dom": "^6.0.0",