Documentation
¶
Overview ¶
Package keystore provides named RSA key pair management for GoBricks applications.
Keys are loaded at startup from DER-encoded files or base64-encoded values (typically injected via environment variables for Kubernetes/EKS deployments). Once loaded, the store is read-only and safe for concurrent access.
Configuration ¶
Keys are configured in YAML under the "keystore" section:
keystore:
keys:
signing:
public:
file: "certs/signing_public.der" # Local dev
private:
value: "${SIGNING_PRIVATE_KEY_BASE64}" # EKS (base64-encoded DER)
Usage ¶
Register the module before modules that need keys:
fw.RegisterModules(
keystore.NewModule(),
&myapp.JWEModule{},
)
Access keys via ModuleDeps (nil-check for fail-fast if keys are required):
func (m *Module) Init(deps *app.ModuleDeps) error {
if deps.KeyStore == nil {
return fmt.Errorf("KeyStore required but not configured")
}
m.keyStore = deps.KeyStore
return nil
}
privKey, err := m.keyStore.PrivateKey("signing")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the GoBricks app.Module interface for RSA key pair management. It loads named RSA key pairs at startup and provides them to other modules via deps.KeyStore.
Register before modules that need keys:
fw.RegisterModules(
keystore.NewModule(),
&myapp.JWEModule{},
)
func (*Module) Init ¶
func (m *Module) Init(deps *app.ModuleDeps) error
Init implements app.Module. Loads all configured key pairs and validates them. Fails fast on any error.