* feature (db): add Db.UnderlyingDB() This is needed to allow for integration with bits that need a *dbw.DB * feature (kms): add new go-kms-wrapping/extras/kms dependency * refactor (kms): schema changes required to adopt extras/kms pkg * refactor (kms/iam): rename to DeprecateCreateKeysTx(...) * refactor (kms): remove deprecated test * refactor (kms): refactor Kms type This refactor includes renaming the existing type to DeprecatedKms and then refactoring the Kms type to become a wrapper of go-kms-wrapping/extras/kms * refactor (kms): delete all the unneeded bits All this stuff is not needed now that we're using go-kms-wrapping/extras/kms * refactor (db): fixup tests after kms refactor * refactor (kms/tests): use testing.TB for test helpers Our test helper packages were not possible to use with benchmarks. This refactor switches to testing.TB to allow both tests and benchmarks to use the helpers. * tests (session benchmarks): refactor to use new Kms type * refactor (schema): rm test which relies on deprecated Kms code * refactor (kms): post rebase on main changes required * chore (kms refactor): re-add unit test from main * refactor (kms): uses migrations that don't include KMS schema changes
85 lines
2.2 KiB
Go
85 lines
2.2 KiB
Go
package kms
|
|
|
|
// KeyPurpose allows an application to specify the reason they need a key; this
|
|
// is used to select which DEK to return
|
|
type KeyPurpose uint
|
|
|
|
// ****************************************************************************
|
|
// IMPORTANT: if you're adding a new KeyPurpose, you should consider whether or
|
|
// not existing scopes need this new type of key. If they do, then you may want
|
|
// to add the new key into kms.ReconcileKeys(...)
|
|
// ****************************************************************************
|
|
const (
|
|
// KeyPurposeUnknown is the default, and indicates that a correct purpose
|
|
// wasn't specified
|
|
KeyPurposeUnknown KeyPurpose = iota
|
|
|
|
// KeyPurposeDatabase is used for general encryption needs for most values
|
|
// in the database, excluding the oplog
|
|
KeyPurposeDatabase
|
|
|
|
// KeyPurposeOplog is used for oplogs
|
|
KeyPurposeOplog
|
|
|
|
// KeyPurposeRecovery is used for recovery access
|
|
KeyPurposeRecovery
|
|
|
|
// KeyPurposeWorkerAuth is used for worker auth
|
|
KeyPurposeWorkerAuth
|
|
|
|
// KeyPurposeTokens is used for token encryption
|
|
KeyPurposeTokens
|
|
|
|
// KeyPurposeSessions is used as a base key to derive session-specific encryption keys
|
|
KeyPurposeSessions
|
|
|
|
// KeyPurposeOidc is used for encrypting oidc states included in
|
|
// authentication URLs
|
|
KeyPurposeOidc
|
|
|
|
// KeyPurposeAudit is used for audit operations
|
|
KeyPurposeAudit
|
|
|
|
// KeyPurposeRootKey is used as the root key
|
|
KeyPurposeRootKey
|
|
)
|
|
|
|
// String returns the key purpose cast as a string, just so it can be called as
|
|
// a function instead of direct casting elsewhere, yw
|
|
func (k KeyPurpose) String() string {
|
|
switch k {
|
|
case KeyPurposeDatabase:
|
|
return "database"
|
|
case KeyPurposeOplog:
|
|
return "oplog"
|
|
case KeyPurposeRecovery:
|
|
return "recovery"
|
|
case KeyPurposeWorkerAuth:
|
|
return "workerauth"
|
|
case KeyPurposeTokens:
|
|
return "tokens"
|
|
case KeyPurposeSessions:
|
|
return "sessions"
|
|
case KeyPurposeOidc:
|
|
return "oidc"
|
|
case KeyPurposeAudit:
|
|
return "audit"
|
|
case KeyPurposeRootKey:
|
|
return "rootKey"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
// ValidDekPurposes returns the current list of valid DEK key purposes
|
|
func ValidDekPurposes() []KeyPurpose {
|
|
return []KeyPurpose{
|
|
KeyPurposeDatabase,
|
|
KeyPurposeOplog,
|
|
KeyPurposeTokens,
|
|
KeyPurposeSessions,
|
|
KeyPurposeOidc,
|
|
KeyPurposeAudit,
|
|
}
|
|
}
|