Skip to content

Commit b198e51

Browse files
docs(chore): copy the Readme to root as well (#114)
copy the Readme to root as well GH-113
1 parent 9773cf7 commit b198e51

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<a href="https://sourcefuse.github.io/arc-docs/arc-api-docs" target="_blank"><img src="https://github.com/sourcefuse/loopback4-microservice-catalog/blob/master/docs/assets/logo-dark-bg.png?raw=true" alt="ARC By SourceFuse logo" title="ARC By SourceFuse" align="right" width="150" /></a>
2+
3+
# [@sourceloop/vault](https://github.com/sourcefuse/loopback4-vault)
4+
5+
<p align="left">
6+
<a href="https://www.npmjs.com/package/@sourceloop/vault">
7+
<img src="https://img.shields.io/npm/v/@sourceloop/vault.svg" alt="npm version" />
8+
</a>
9+
<a href="https://sonarcloud.io/summary/new_code?id=sourcefuse_loopback4-vault" target="_blank">
10+
<img alt="Sonar Quality Gate" src="https://img.shields.io/sonar/quality_gate/sourcefuse_loopback4-vault?server=https%3A%2F%2Fsonarcloud.io">
11+
</a>
12+
<a href="https://app.snyk.io/org/ashishkaushik/reporting?context[page]=issues-detail&project_target=%255B%2522sourcefuse%252Floopback4-vault%2522%255D&project_origin=%255B%2522github%2522%255D&issue_status=%255B%2522Open%2522%255D&issue_by=Severity&table_issues_detail_cols=SCORE%257CCVE%257CCWE%257CPROJECT%257CEXPLOIT%2520MATURITY%257CAUTO%2520FIXABLE%257CINTRODUCED%257CSNYK%2520PRODUCT&v=1">
13+
<img alt="Synk Status" src="https://img.shields.io/badge/SYNK_SECURITY-MONITORED-GREEN">
14+
</a>
15+
<a href="https://github.com/sourcefuse/loopback4-vault/graphs/contributors" target="_blank">
16+
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/sourcefuse/loopback4-vault">
17+
</a>
18+
<a href="https://www.npmjs.com/@sourceloop/vault" target="_blank">
19+
<img alt="downloads" src="https://img.shields.io/npm/dm/@sourceloop/vault">
20+
</a>
21+
<a href="https://github.com/sourcefuse/loopback4-s3/blob/master/LICENSE">
22+
<img src="https://img.shields.io/github/license/sourcefuse/loopback4-s3.svg" alt="License" />
23+
</a>
24+
<a href="https://loopback.io/" target="_blank">
25+
<img alt="Powered By LoopBack 4" src="https://img.shields.io/badge/Powered%20by-LoopBack 4-brightgreen" />
26+
</a>
27+
</p>
28+
29+
## Overview
30+
31+
A simple loopback-next extension for Hashicorp's [Vault](https://learn.hashicorp.com/vault) integration in loopback applications based on node.js vault client [node-vault](https://github.com/kr1sp1n/node-vault).
32+
33+
## Install
34+
35+
```sh
36+
npm install @sourceloop/vault
37+
```
38+
39+
## Usage
40+
41+
In order to use this component into your LoopBack application, please follow below steps.
42+
43+
- Add component to application and provide vault endpoint, vault token and unseal key via `VaultSecurityBindings`.
44+
45+
```ts
46+
this.component(VaultComponent);
47+
this.bind(VaultSecurityBindings.CONFIG).to({
48+
endpoint: process.env.VAULT_URL,
49+
token: process.env.VAULT_TOKEN,
50+
unsealKey: process.env.VAULT_UNSEAL_KEY,
51+
});
52+
```
53+
54+
- After this, you can just inject the `VaultSecurityBindings.VAULT_CONNECTOR` across application.
55+
56+
```ts
57+
@inject(VaultSecurityBindings.VAULT_CONNECTOR)
58+
private readonly vaultConnector: VaultConnect,
59+
```
60+
61+
All the methods mentioned [here](https://github.com/kr1sp1n/node-vault/blob/master/features.md) are now available on `vaultConnector`.
62+
63+
Here is an example usage below
64+
65+
```ts
66+
private async upsertKeyToVault(credKey: string): Promise<{data: AnyObject}> {
67+
let data: {data: AnyObject};
68+
try {
69+
data = await this.vaultConnector.read(credKey);
70+
} catch (error) {
71+
if (error.response.statusCode === 404) {
72+
await this.vaultConnector.write(credKey, {empty: true});
73+
data = await this.vaultConnector.read(credKey);
74+
} else {
75+
this.logger.error(error);
76+
throw error;
77+
}
78+
}
79+
return data;
80+
}
81+
```
82+
83+
- If you need to update vault token or any other connection parameters, there is a `reconnect(config: VaultProviderOptions)` function available to do so. Whatever new config parameters are needed, you can pass those and leave the unchanged ones out of the config. It will only update the new ones keeping the existing ones intact and will reconnect with vault again. Please note that this may cause disconnection with your existing vault data if you change the endpoints here.
84+
85+
## Feedback
86+
87+
If you've noticed a bug or have a question or have a feature request, [search the issue tracker](https://github.com/sourcefuse/loopback4-vault/issues) to see if someone else in the community has already created a ticket.
88+
If not, go ahead and [make one](https://github.com/sourcefuse/loopback4-vault/issues/new/choose)!
89+
All feature requests are welcome. Implementation time may vary. Feel free to contribute the same, if you can.
90+
If you think this extension is useful, please [star](https://help.github.com/en/articles/about-stars) it. Appreciation really helps in keeping this project alive.
91+
92+
## Contributing
93+
94+
Please read [CONTRIBUTING.md](https://github.com/sourcefuse/loopback4-vault/blob/master/.github/CONTRIBUTING.md) for details on the process for submitting pull requests to us.
95+
96+
## Code of conduct
97+
98+
Code of conduct guidelines [here](https://github.com/sourcefuse/loopback4-vault/blob/master/.github/CODE_OF_CONDUCT.md).
99+
100+
## License
101+
102+
[MIT](https://github.com/sourcefuse/loopback4-vault/blob/master/LICENSE)

0 commit comments

Comments
 (0)