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

chore: clean up security #50

Merged
merged 1 commit into from
Jul 18, 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
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## Features

| Package | Examples | Use Case |
| --------- | ---------- | --------------------------------- |
| api | http | build gateway servers |
| client | grpc | synchronous communication |
| runtime | kubernetes | service info |
| security | jwts, TBD | token provisioning and encryption |
| server | grpc | build backend servers |
| store | cockroach | data persistence |
| streams | TBD | asynchronous communication |
| telemetry | memory | logs, metrics, and traces |
| Package | Examples | Use Case |
| --------- | --------------- | -------------------------- |
| api | http | build gateway servers |
| client | grpc | synchronous communication |
| runtime | kubernetes | service info |
| security | jwts, nacl, TBD | tokens, secrets, and certs |
| server | grpc | build backend servers |
| store | cockroach | data persistence |
| streams | TBD | asynchronous communication |
| telemetry | memory | logs, metrics, and traces |
1 change: 1 addition & 0 deletions security/secret/naclbox/naclbox.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package naclbox
1 change: 1 addition & 0 deletions security/secret/naclbox/naclbox_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package naclbox
1 change: 1 addition & 0 deletions security/secret/naclbox/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package naclbox
57 changes: 57 additions & 0 deletions security/secret/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package secret

import "context"

type SecretOption func(o *SecretOptions)

type SecretOptions struct {
Context context.Context
}

func NewSecretOptions(opts ...SecretOption) SecretOptions {
options := SecretOptions{
Context: context.Background(),
}

for _, fn := range opts {
fn(&options)
}

return options
}

type EncryptOption func(o *EncryptOptions)

type EncryptOptions struct {
Context context.Context
}

func NewEncryptOptions(opts ...EncryptOption) EncryptOptions {
options := EncryptOptions{
Context: context.Background(),
}

for _, fn := range opts {
fn(&options)
}

return options
}

type DecryptOption func(o *DecryptOptions)

type DecryptOptions struct {
Context context.Context
}

func NewDecryptOptions(opts ...DecryptOption) DecryptOptions {
options := DecryptOptions{
Context: context.Background(),
}

for _, fn := range opts {
fn(&options)
}

return options
}
8 changes: 8 additions & 0 deletions security/secret/secret.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package secret

type Secret interface {
Options() SecretOptions
Encrypt(bytes []byte, opts ...EncryptOption) ([]byte, error)
Decrypt(bytes []byte, opts ...DecryptOption) ([]byte, error)
String() string
}