mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-18 19:25:13 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user