Skip to content

Commit

Permalink
chore: clean up security
Browse files Browse the repository at this point in the history
  • Loading branch information
w-h-a committed Jul 18, 2024
1 parent 34f67e1 commit 75ac5fc
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 10 deletions.
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
}

0 comments on commit 75ac5fc

Please sign in to comment.