Installations
npm install @veecode-platform/plugin-vault-backend
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.19.1
NPM Version
10.2.4
Score
27.1
Supply Chain
78.8
Quality
73.8
Maintenance
25
Vulnerability
79.1
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (95.98%)
JavaScript (4.01%)
Dockerfile (0.01%)
Developer
Download Statistics
Total Downloads
4,767
Last Day
6
Last Week
23
Last Month
112
Last Year
1,067
GitHub Statistics
51,584 Commits
77 Branches
2 Contributors
Package Meta Information
Latest Version
0.4.14
Package Id
@veecode-platform/plugin-vault-backend@0.4.14
Unpacked Size
48.45 kB
Size
12.39 kB
File Count
6
NPM Version
10.2.4
Node Version
18.19.1
Publised On
02 Apr 2024
Total Downloads
Cumulative downloads
Total Downloads
4,767
Last day
500%
6
Compared to previous day
Last week
-4.2%
23
Compared to previous week
Last month
53.4%
112
Compared to previous month
Last year
-71.2%
1,067
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
16
@backstage/plugin-vault-backend
A backend for Vault, this plugin adds a few routes that are used by the frontend plugin to fetch the information from Vault.
Introduction
Vault is an identity-based secrets and encryption management system. A secret is anything that you want to tightly control access to, such as API encryption keys, passwords, or certificates. Vault provides encryption services that are gated by authentication and authorization methods.
This plugins allows you to view all the available secrets at a certain location, and redirect you to the official UI so backstage can rely on LIST permissions, which is safer.
Getting started
To get started, first you need a running instance of Vault. You can follow this tutorial to install vault and start your server locally.
-
When your Vault instance is up and running, then you will need to install the plugin into your app:
1 # From your Backstage root directory 2 yarn --cwd packages/backend add @backstage/plugin-vault-backend
-
Create a file in
src/plugins/vault.ts
and add a reference to it insrc/index.ts
:1// In packages/backend/src/plugins/vault.ts 2import { createRouter } from '@backstage/plugin-vault-backend'; 3import { Router } from 'express'; 4import { PluginEnvironment } from '../types'; 5 6export default async function createPlugin( 7 env: PluginEnvironment, 8): Promise<Router> { 9 return await createRouter({ 10 logger: env.logger, 11 config: env.config, 12 scheduler: env.scheduler, 13 }); 14}
1diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts 2index f2b14b2..2c64f47 100644 3--- a/packages/backend/src/index.ts 4+++ b/packages/backend/src/index.ts 5@@ -22,6 +22,7 @@ import { Config } from '@backstage/config'; 6 import app from './plugins/app'; 7+import vault from './plugins/vault'; 8 import scaffolder from './plugins/scaffolder'; 9@@ -56,6 +57,7 @@ async function main() { 10 const authEnv = useHotMemoize(module, () => createEnv('auth')); 11+ const vaultEnv = useHotMemoize(module, () => createEnv('vault')); 12 const proxyEnv = useHotMemoize(module, () => createEnv('proxy')); 13@@ -63,6 +65,7 @@ async function main() { 14 15 const apiRouter = Router(); 16 apiRouter.use('/catalog', await catalog(catalogEnv)); 17+ apiRouter.use('/vault', await vault(vaultEnv)); 18 apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv));
-
Add some extra configurations in your
app-config.yaml
.1vault: 2 baseUrl: http://your-internal-vault-url.svc 3 publicUrl: https://your-vault-url.example.com 4 token: <VAULT_TOKEN> 5 secretEngine: 'customSecretEngine' # Optional. By default it uses 'secrets'. Can be overwritten by the annotation of the entity 6 kvVersion: <kv-version> # Optional. The K/V version that your instance is using. The available options are '1' or '2' 7 schedule: # Optional. If the token renewal is enabled this schedule will be used instead of the hourly one 8 frequency: { hours: 1 } 9 timeout: { hours: 1 }
-
Get a
VAULT_TOKEN
with LIST permissions, as it's enough for the plugin. You can check this tutorial for more info. -
If you also want to use the
renew
functionality, you need to attach the following block to your custom policy, so that Backstage can perform a token-renew:# Allow tokens to renew themselves path "auth/token/renew-self" { capabilities = ["update"] }
New Backend System
The Vault backend plugin has support for the new backend system, here's how you can set that up:
In your packages/backend/src/index.ts
make the following changes:
1 import { createBackend } from '@backstage/backend-defaults'; 2 const backend = createBackend(); 3 // ... other feature additions 4+ backend.add(import('@backstage/plugin-vault-backend'); 5 backend.start();
The token renewal is enabled automatically in the new backend system depending on the app-config.yaml
. If the schedule
is not defined there, no
task will be executed. If you want to use the default renewal scheduler (which runs hourly), set schedule: true
. In case you want a custom schedule
just use a configuration like the one set above.
Integration with the Catalog
The plugin can be integrated into each Component in the catalog. To allow listing the available secrets a new annotation must be added to the catalog-info.yaml
:
1apiVersion: backstage.io/v1alpha1 2kind: Component 3metadata: 4 # ... 5 annotations: 6 vault.io/secrets-path: path/to/secrets
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:
.
├── ...
├── secrets # Your secret engine name (usually it is `secrets`)
│ ├── test # Folder with test secrets
│ │ ├── backstage # In this folder there are secrets for Backstage
│ ├── other # Other folder with more secrets inside
│ └── folder # And another folder
└── ...
You will set the vault.io/secret-path
to test/backstage
. If the folder backstage
contains other sub-folders, the plugin will fetch the secrets inside them and adapt the View and Edit URLs to point to the correct place.
In case you need to support different secret engines for entities of the catalog you can provide optional annotation to the entity in catalog-info.yaml
:
1 apiVersion: backstage.io/v1alpha1 2 kind: Component 3 metadata: 4 # ... 5 annotations: 6 vault.io/secrets-path: path/to/secrets 7+ vault.io/secrets-engine: customSecretEngine # Optional. By default it uses the 'secretEngine' value from your app-config.
That will overwrite the default secret engine from the configuration.
Renew token
In a secure Vault instance, it's usual that the tokens are refreshed after some time. In order to always have a valid token to fetch the secrets, it might be necessary to execute a renew action after some time. By default this is deactivated, but it can be easily activated and configured to be executed periodically (hourly by default, but customizable by the user within the app-config.yaml file). In order to do that, modify your src/plugins/vault.ts
file to look like this one:
1import { VaultBuilder } from '@backstage/plugin-vault-backend'; 2import { Router } from 'express'; 3import { PluginEnvironment } from '../types'; 4 5export default async function createPlugin( 6 env: PluginEnvironment, 7): Promise<Router> { 8 const builder = await VaultBuilder.createBuilder({ 9 logger: env.logger, 10 config: env.config, 11 scheduler: env.scheduler, 12 }).enableTokenRenew( 13 env.scheduler.createScheduledTaskRunner({ 14 frequency: { minutes: 10 }, 15 timeout: { minutes: 1 }, 16 }), 17 ); 18 19 const { router } = builder.build(); 20 21 return router; 22}
If the taskRunner
is not set when calling the enableTokenRenew
, the plugin will automatically check what is set in the app-config.yaml
file. Refer to the new backend system setup for more information about it.
Features
- List the secrets present in a certain path
- Use different secret engines for different entities
- Open a link to view the secret
- Open a link to edit the secret
- Renew the token automatically with a defined periodicity
The secrets cannot be edited/viewed from within Backstage to make it more secure. Backstage will only have permissions to LIST data from Vault or to renew its own token if that is needed. And the user who wants to edit/view a certain secret needs the correct permissions to do so.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
18 different organizations found -- score normalized to 10
Details
- Info: contributors work for 0+x,ONEARMY,backstage,boxen,cisco @ciscocx former @dxc-technology,harness,keyloop,kossiitkgp,mend,metakgp,minacolor,nordeck,plancraft,roadiehq,spotify,tentaclelabs,webex,zero-plus-x
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: License file found in expected location: LICENSE:1
- Info: FSF or OSI recognized license: LICENSE:1
Reason
30 commit(s) out of 30 and 0 issue activity out of 0 found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
- Info: Found linked content in security policy: SECURITY.md
- Info: Found text in security policy: SECURITY.md
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md
- Info: security policy detected in current repo: SECURITY.md
Reason
2 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/devportal_publish_plugins.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/veecode-platform/backstage-plugins/devportal_publish_plugins.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/devportal_publish_plugins.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/veecode-platform/backstage-plugins/devportal_publish_plugins.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/devportal_publish_plugins.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/veecode-platform/backstage-plugins/devportal_publish_plugins.yml/master?enable=pin
- Warn: containerImage not pinned by hash: packages/backend/Dockerfile:12: pin your Docker image by updating node:16-bullseye-slim to node:16-bullseye-slim@sha256:503446c15c6236291222f8192513c2eb56a02a8949cbadf4fe78cce19815c734
- Warn: pipCommand not pinned by hash: packages/backend/Dockerfile:18-23
- Info: no insecure (not pinned by hash) dependency downloads found in Dockerfiles
- Info: no insecure (not pinned by hash) dependency downloads found in shell scripts
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
found 30 unreviewed changesets out of 30 -- score normalized to 0
Reason
no update tool detected
Details
- Warn: tool 'RenovateBot' is not used: Follow the instructions from https://docs.renovatebot.com/configuration-options/. (Low effort)
- Warn: tool 'Dependabot' is not used: Follow the instructions from https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates. (Low effort)
- Warn: tool 'PyUp' is not used: Follow the instructions from https://docs.pyup.io/docs. (Low effort)
- Warn: tool 'Sonatype Lift' is not used: Follow the instructions from https://help.sonatype.com/lift/getting-started. (Low effort)
Reason
project is not fuzzed
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
- Warn: CodeQL tool not detected
Reason
non read-only tokens detected in GitHub workflows
Details
- Warn: no topLevel permission defined: .github/workflows/devportal_publish_plugins.yml:1: Visit https://app.stepsecurity.io/secureworkflow/veecode-platform/backstage-plugins/devportal_publish_plugins.yml/master?enable=permissions Tick the 'Restrict permissions for GITHUB_TOKEN' Untick other options NOTE: If you want to resolve multiple issues at once, you can visit https://app.stepsecurity.io/securerepo instead. (Low effort)
- Info: topLevel permissions set to 'read-all': .github/workflows/scorecard.yml:18
- Info: no jobLevel write permissions found
Score
4.8
/10
Last Scanned on 2023-09-12T19:37:29Z
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More