Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove topic overlap between the database and application topics #2

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ Piggy Bank is a secrets storage tool for applications that works with NATS. Secr

A decryption key is returned from the initialization phase. If this key is lost, all of the data is unrecoverable.

## Add KV bucket

Be sure to add the KV bucket to NATS: `nats kv add piggybank`

## Example Usage

1. Start piggybank `piggybank start`
2. Initialize the database `nats req piggybank.database.initialize ""`
3. Unlock the database with key sent from step 1 `nats req piggybank.database.unlock '{"database_key": "foobar"}'`
2. Initialize the database `nats req piggybankdb.initialize ""`
3. Unlock the database with key sent from step 1 `nats req piggybankdb.unlock '{"database_key": "foobar"}'`
4. Add a secret for an application `nats req -H method:post piggybank.myapplication.registrySecret "somesecrettext"`
5. Retrieve a secret `nats req -H method:get piggybank.myapplication.registrySecret`
6. Lock the database `nats req piggybank.database.lock ""`
7. Try to retrieve the secret again `nats req -H method:get piggybank.myapplication.registrySecret`
5. Retrieve a secret `nats req -H method:get piggybank.myapplication.registrySecret ""`
6. Lock the database `nats req piggybankdb.lock ""`
7. Try to retrieve the secret again `nats req -H method:get piggybank.myapplication.registrySecret ""`

## Permissions
Permissions are defined as normal NATS subject permissions. If you have access to a subject, then you can retrieve the secrets. This means the permissions can be as granular as desired.

## Config
Piggy Bank requires a config file. It uses Cue to read the configs, but the configs can also be in json or yaml format.

The Cue schema is in `cmd/schema.cue`.
The Cue schema is in `cmd/schema.cue`.
2 changes: 1 addition & 1 deletion server/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (n *NatsBackend) SetupMicro() error {
return err
}

databaseGroup := srv.AddGroup("piggybank.database")
databaseGroup := srv.AddGroup("piggybankdb")
if err := databaseGroup.AddEndpoint("lock", micro.HandlerFunc(n.LockRequest)); err != nil {
return err
}
Expand Down
Loading