Help us shape the future of Go! Take the 2026 Go Developer Survey

rekey

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package rekey re-encrypts every secret stored in the database under the primary key of the encryption keyset, so a key an operator rotated away from can be retired. It reads and writes rows of every Workspace (and the User and Staff member rows no Workspace owns), so it holds the raw client; it is the only place that sweeps the stored ciphertext.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Count

type Count struct {
	// Column names the stored secret, as "table.column".
	Column string
	// Rewritten values were sealed under an older key and now are under the primary one.
	Rewritten int
	// Current values were already under the primary key and were left alone.
	Current int
	// Raced rows changed while the sweep ran (a request saved them): their new value was
	// sealed by the running server, so they are skipped. A second run counts them as current.
	Raced int
}

Count is what one sweep did to a column.

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module re-encrypts the stored secrets.

func New

func New(client *ent.Client, cipher *secrets.Cipher) *Module

New builds the Module on the raw client and the cipher whose primary key is the target.

func (*Module) Run

func (m *Module) Run(ctx context.Context) ([]Count, error)

Run sweeps every column that holds ciphertext, in id order and page by page. It fails at the first value the cipher cannot read, which means a key is missing from the keyset: nothing guesses, and what was already rewritten stays valid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL