Documentation
¶
Index ¶
- Constants
- Variables
- func DecryptHandlerFunc(cipher Cipher) func(w http.ResponseWriter, r *http.Request)
- func EncryptHandlerFunc(cipher Cipher) func(w http.ResponseWriter, r *http.Request)
- func NewMux(cipher Cipher) *http.ServeMux
- func Run(ctx context.Context) error
- func RunWrapper(ctx context.Context, sopsArgs []string) error
- type Cipher
- type SakuraKMS
- type VaultDecryptRequest
- type VaultDecryptResponse
- type VaultEncryptRequest
- type VaultEncryptResponse
- type VaultErrorResponse
Constants ¶
const ( VaultPrefix = "vault:v1:" KeyIDPathParam = "key_id" EnvKeyID = "SAKURACLOUD_KMS_KEY_ID" ServerAddr = "127.0.0.1:8200" SOPSbin = "sops" )
Variables ¶
var Version = "v0.0.3"
Functions ¶
func DecryptHandlerFunc ¶
func DecryptHandlerFunc(cipher Cipher) func(w http.ResponseWriter, r *http.Request)
DecryptHandlerFunc returns an HTTP handler for Vault Transit Engine decrypt endpoint.
func EncryptHandlerFunc ¶
func EncryptHandlerFunc(cipher Cipher) func(w http.ResponseWriter, r *http.Request)
EncryptHandlerFunc returns an HTTP handler for Vault Transit Engine encrypt endpoint.
func NewMux ¶
NewMux creates a new HTTP ServeMux with Vault Transit Engine compatible API endpoints.
func Run ¶
Run starts a Vault Transit Engine compatible API server for Sakura Cloud KMS. The server listens on 127.0.0.1:8200 and provides encrypt/decrypt endpoints.
func RunWrapper ¶
RunWrapper starts a Vault Transit Engine compatible API server and executes SOPS command. It automatically configures SOPS to use Sakura Cloud KMS via SOPS_VAULT_URIS environment variable. Requires SAKURA_KMS_KEY_ID environment variable to be set.
Types ¶
type Cipher ¶
type Cipher interface {
// Encrypt encrypts plaintext using the specified key ID.
// Returns base64-encoded ciphertext string.
Encrypt(ctx context.Context, keyID string, plaintext []byte) (string, error)
// Decrypt decrypts ciphertext using the specified key ID.
// Accepts base64-encoded ciphertext string and returns plaintext bytes.
Decrypt(ctx context.Context, keyID string, ciphertext string) ([]byte, error)
}
Cipher defines the interface for encryption and decryption operations.
type SakuraKMS ¶
type SakuraKMS struct {
// contains filtered or unexported fields
}
SakuraKMS implements Cipher interface using Sakura Cloud KMS.
func NewSakuraKMS ¶
NewSakuraKMS creates a new SakuraKMS instance. It reads credentials from environment variables (SAKURACLOUD_ACCESS_TOKEN, SAKURACLOUD_ACCESS_TOKEN_SECRET).
type VaultDecryptRequest ¶
type VaultDecryptRequest struct {
Ciphertext string `json:"ciphertext"`
}
VaultDecryptRequest represents the request body for Vault Transit Engine decrypt API. Ciphertext must include "vault:v1:" prefix.
type VaultDecryptResponse ¶
type VaultDecryptResponse struct {
Plaintext string `json:"plaintext"`
}
VaultDecryptResponse represents the response body for Vault Transit Engine decrypt API. Plaintext is returned as base64-encoded string.
type VaultEncryptRequest ¶
type VaultEncryptRequest struct {
Plaintext string `json:"plaintext"`
}
VaultEncryptRequest represents the request body for Vault Transit Engine encrypt API. Plaintext must be base64-encoded string.
type VaultEncryptResponse ¶
type VaultEncryptResponse struct {
Ciphertext string `json:"ciphertext"`
}
VaultEncryptResponse represents the response body for Vault Transit Engine encrypt API. Ciphertext includes "vault:v1:" prefix followed by the encrypted data.
type VaultErrorResponse ¶ added in v0.0.3
type VaultErrorResponse struct {
Errors []string `json:"errors"`
}
VaultErrorResponse represents the error response body for Vault API. Errors is an array of error message strings.