fix(oidc): use authenticated encryption for opaque tokens (#12017)

# Which Problems Are Solved

Opaque tokens now use authenticated encryption.

# How the Problems Are Solved

- Upgrade zitadel/oidc to v3.47
- Copy crypto implementation for refresh and session tokens (internal to
zitadel)
- Added config that allows validating old tokens for gradual roll-out

# Additional Changes

- Set NX cache for `integration-test-build` to `false`, working on a
seperate fix.

# Additional Context

- closes #11315

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: muhlemmer <[email protected]>
This commit is contained in:
Tim Möhlmann
2026-04-13 10:59:50 +00:00
committed by GitHub
co-authored by copilot-swe-agent[bot] <198982749+[email protected]> muhlemmer
parent a28ee63b02
commit 01fe34a526
46 changed files with 406 additions and 201 deletions
+22
View File
@@ -16,6 +16,10 @@ const (
//go:generate mockgen -typed -package crypto -destination ./crypto.mock.go . EncryptionAlgorithm
// EncryptionAlgorithm is an interface that defines the methods for encrypting and decrypting values,
// used for sensitive data stored in the database.
// These methods are not intended to be used for encrypting data that is sent to the client,
// for this use the [AuthAlgorithm] instead.
type EncryptionAlgorithm interface {
Algorithm() string
EncryptionKeyID() string
@@ -28,6 +32,24 @@ type EncryptionAlgorithm interface {
DecryptString(hashed []byte, keyID string) (string, error)
}
// AuthAlgorithm is an interface that defines the methods for encrypting and decrypting tokens,
// used for sensitive data sent to the client, such as access tokens and refresh tokens.
// Implementation must obfuscate and authenticate the token.
type AuthAlgorithm interface {
// EncryptToken encrypts the token using authenticated encryption with the current encryption key.
EncryptToken(data string) (string, error)
// DecryptToken authenticates and decrypts the token using the encryption key.
// When the decrypted value contains non-UTF8 characters an error is returned.
DecryptToken(token string) (string, error)
LegacyTokenEnabled() bool
}
type AuthEncryptionAlgorithm interface {
EncryptionAlgorithm
AuthAlgorithm
}
// CryptoValue is a struct that can be used to store encrypted values in a database.
// The struct is compatible with the [driver.Valuer] and database/sql.Scanner interfaces.
type CryptoValue struct {