Merge commit from fork

* fix(crypto): use authenticated encryption for IDP intent tokens

IDP intent tokens were encrypted with AES-CFB which provides no
integrity protection, making them malleable. Switch to A256GCM via
the existing AuthAlgorithm interface (EncryptToken/DecryptToken),
the same approach already used for OIDC and session tokens.

The idpConfigEncryption key type is widened from EncryptionAlgorithm
to AuthEncryptionAlgorithm so that data-at-rest encryption (IDP
client secrets, LDAP bind passwords, SAML keys) continues to use
the CFB path unmodified.

Co-authored-by: Cursor <[email protected]>

* fix(proto): raise IDP intent token max length to 500 for authenticated tokens

The switch to authenticated A256GCM (JWE compact serialization) makes IDP
intent tokens longer (~270 chars) than the previous AES-CFB base64 output.
Raise the max_len/max_length validation and OpenAPI constraints on every
idp_intent_token field from 200 to 500 so the new tokens are accepted:
user v2/v2beta (idp + user_service), session v2/v2beta, and resources
user v3alpha.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Livio Spring
2026-09-04 06:13:37 +02:00
committed by GitHub
co-authored by Claude Opus 4.8 Cursor
parent f3dcfa3db6
commit 9067605b66
33 changed files with 709 additions and 347 deletions
+11 -12
View File
@@ -421,15 +421,14 @@ func TestCommands_UpdateSession(t *testing.T) {
}
func TestCommands_updateSession(t *testing.T) {
decryption := func(err error) crypto.EncryptionAlgorithm {
mCrypto := crypto.NewMockEncryptionAlgorithm(gomock.NewController(t))
mCrypto.EXPECT().EncryptionKeyID().Return("id")
mCrypto.EXPECT().DecryptString(gomock.Any(), gomock.Any()).DoAndReturn(
func(code []byte, keyID string) (string, error) {
decryption := func(err error) crypto.AuthEncryptionAlgorithm {
mCrypto := crypto.NewMockAuthEncryptionAlgorithm(gomock.NewController(t))
mCrypto.EXPECT().DecryptToken(gomock.Any()).DoAndReturn(
func(token string) (string, error) {
if err != nil {
return "", err
}
return string(code), nil
return token, nil
})
return mCrypto
}
@@ -705,7 +704,7 @@ func TestCommands_updateSession(t *testing.T) {
sessionWriteModel: NewSessionWriteModel("sessionID", "instance1"),
sessionCommands: []SessionCommand{
CheckUser("userID", "org1", &language.Afrikaans),
CheckIntent("intent", "aW50ZW50"),
CheckIntent("intent", "intent"),
},
createToken: func(sessionID string) (string, string, error) {
return "tokenID",
@@ -756,7 +755,7 @@ func TestCommands_updateSession(t *testing.T) {
sessionWriteModel: NewSessionWriteModel("sessionID", "instance1"),
sessionCommands: []SessionCommand{
CheckUser("userID", "org1", &language.Afrikaans),
CheckIntent("intent", "aW50ZW50"),
CheckIntent("intent", "intent"),
},
createToken: func(sessionID string) (string, string, error) {
return "tokenID",
@@ -843,7 +842,7 @@ func TestCommands_updateSession(t *testing.T) {
sessionWriteModel: NewSessionWriteModel("sessionID", "instance1"),
sessionCommands: []SessionCommand{
CheckUser("userID", "org1", &language.Afrikaans),
CheckIntent("intent", "aW50ZW50"),
CheckIntent("intent", "intent"),
},
createToken: func(sessionID string) (string, string, error) {
return "tokenID",
@@ -894,7 +893,7 @@ func TestCommands_updateSession(t *testing.T) {
sessionWriteModel: NewSessionWriteModel("sessionID", "instance1"),
sessionCommands: []SessionCommand{
CheckUser("userID", "org1", &language.Afrikaans),
CheckIntent("intent", "aW50ZW50"),
CheckIntent("intent", "intent"),
},
createToken: func(sessionID string) (string, string, error) {
return "tokenID",
@@ -956,7 +955,7 @@ func TestCommands_updateSession(t *testing.T) {
sessionWriteModel: NewSessionWriteModel("sessionID", "instance1"),
sessionCommands: []SessionCommand{
CheckUser("userID", "org1", &language.Afrikaans),
CheckIntent("intent", "aW50ZW50"),
CheckIntent("intent", "intent"),
},
createToken: func(sessionID string) (string, string, error) {
return "tokenID",
@@ -1037,7 +1036,7 @@ func TestCommands_updateSession(t *testing.T) {
sessionWriteModel: NewSessionWriteModel("sessionID", "instance1"),
sessionCommands: []SessionCommand{
CheckUser("userID", "org1", &language.Afrikaans),
CheckIntent("intent", "aW50ZW50"),
CheckIntent("intent", "intent"),
},
createToken: func(sessionID string) (string, string, error) {
return "tokenID",