- Notifications
You must be signed in to change notification settings - Fork0
A loopback-next extension for HashiCorp's Vault integration in loopback-next applications
License
sourcefuse/loopback4-vault
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A simple loopback-next extension for Hashicorp'sVault integration in loopback applications based on node.js vault clientnode-vault.
npm install @sourceloop/vault
In order to use this component into your LoopBack application, please follow below steps.
- Add component to application and provide vault endpoint, vault token and unseal key via
VaultSecurityBindings
.
this.component(VaultComponent);this.bind(VaultSecurityBindings.CONFIG).to({endpoint:process.env.VAULT_URL,token:process.env.VAULT_TOKEN,unsealKey:process.env.VAULT_UNSEAL_KEY,});
- After this, you can just inject the
VaultSecurityBindings.VAULT_CONNECTOR
across application.
@inject(VaultSecurityBindings.VAULT_CONNECTOR)privatereadonlyvaultConnector:VaultConnect,
All the methods mentionedhere are now available onvaultConnector
.
Here is an example usage below
privateasyncupsertKeyToVault(credKey: string):Promise<{data:AnyObject}>{letdata:{data:AnyObject};try{data=awaitthis.vaultConnector.read(credKey);}catch(error){if(error.response.statusCode===404){awaitthis.vaultConnector.write(credKey,{empty:true});data=awaitthis.vaultConnector.read(credKey);}else{this.logger.error(error);throwerror;}}returndata;}
- 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.
If you've noticed a bug or have a question or have a feature request,search the issue tracker to see if someone else in the community has already created a ticket.If not, go ahead andmake one!All feature requests are welcome. Implementation time may vary. Feel free to contribute the same, if you can.If you think this extension is useful, pleasestar it. Appreciation really helps in keeping this project alive.
Please readCONTRIBUTING.md for details on the process for submitting pull requests to us.
Code of conduct guidelineshere.
About
A loopback-next extension for HashiCorp's Vault integration in loopback-next applications
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.