mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-25 13:58:46 +00:00
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:
co-authored by
Claude Opus 4.8
Cursor
parent
f3dcfa3db6
commit
9067605b66
@@ -237,7 +237,7 @@ func unmarshalIdpUser(idpUserData []byte, idpUser idp.User) (idp.User, error) {
|
||||
return idpUser, nil
|
||||
}
|
||||
|
||||
func idpIntentToIDPIntentPb(intent *command.IDPIntentWriteModel, alg crypto.EncryptionAlgorithm) (_ *user.RetrieveIdentityProviderIntentResponse, err error) {
|
||||
func idpIntentToIDPIntentPb(intent *command.IDPIntentWriteModel, alg crypto.AuthEncryptionAlgorithm) (_ *user.RetrieveIdentityProviderIntentResponse, err error) {
|
||||
rawInformation := new(structpb.Struct)
|
||||
err = rawInformation.UnmarshalJSON(intent.IDPUser)
|
||||
if err != nil {
|
||||
@@ -279,7 +279,7 @@ func idpIntentToIDPIntentPb(intent *command.IDPIntentWriteModel, alg crypto.Encr
|
||||
return information, nil
|
||||
}
|
||||
|
||||
func idpOAuthTokensToPb(idpIDToken string, idpAccessToken, idpRefreshToken *crypto.CryptoValue, alg crypto.EncryptionAlgorithm) (_ *user.IDPInformation_Oauth, err error) {
|
||||
func idpOAuthTokensToPb(idpIDToken string, idpAccessToken, idpRefreshToken *crypto.CryptoValue, alg crypto.AuthEncryptionAlgorithm) (_ *user.IDPInformation_Oauth, err error) {
|
||||
var idToken *string
|
||||
if idpIDToken != "" {
|
||||
idToken = &idpIDToken
|
||||
|
||||
@@ -25,7 +25,7 @@ type Server struct {
|
||||
command *command.Commands
|
||||
query *query.Queries
|
||||
userCodeAlg crypto.EncryptionAlgorithm
|
||||
idpAlg crypto.EncryptionAlgorithm
|
||||
idpAlg crypto.AuthEncryptionAlgorithm
|
||||
idpCallback func(ctx context.Context) string
|
||||
samlRootURL func(ctx context.Context, idpID string) string
|
||||
|
||||
@@ -41,7 +41,7 @@ func CreateServer(
|
||||
query *query.Queries,
|
||||
systemDefaults systemdefaults.SystemDefaults,
|
||||
userCodeAlg crypto.EncryptionAlgorithm,
|
||||
idpAlg crypto.EncryptionAlgorithm,
|
||||
idpAlg crypto.AuthEncryptionAlgorithm,
|
||||
idpCallback func(ctx context.Context) string,
|
||||
samlRootURL func(ctx context.Context, idpID string) string,
|
||||
assetAPIPrefix func(ctx context.Context) string,
|
||||
|
||||
@@ -21,8 +21,8 @@ import (
|
||||
)
|
||||
|
||||
func Test_idpIntentToIDPIntentPb(t *testing.T) {
|
||||
decryption := func(err error) crypto.EncryptionAlgorithm {
|
||||
mCrypto := crypto.NewMockEncryptionAlgorithm(gomock.NewController(t))
|
||||
decryption := func(err error) crypto.AuthEncryptionAlgorithm {
|
||||
mCrypto := crypto.NewMockAuthEncryptionAlgorithm(gomock.NewController(t))
|
||||
mCrypto.EXPECT().Algorithm().Return("enc")
|
||||
mCrypto.EXPECT().DecryptionKeyIDs().Return([]string{"id"})
|
||||
mCrypto.EXPECT().DecryptString(gomock.Any(), gomock.Any()).DoAndReturn(
|
||||
@@ -37,7 +37,7 @@ func Test_idpIntentToIDPIntentPb(t *testing.T) {
|
||||
|
||||
type args struct {
|
||||
intent *command.IDPIntentWriteModel
|
||||
alg crypto.EncryptionAlgorithm
|
||||
alg crypto.AuthEncryptionAlgorithm
|
||||
}
|
||||
type res struct {
|
||||
resp *user.RetrieveIdentityProviderIntentResponse
|
||||
|
||||
@@ -23,7 +23,7 @@ type Server struct {
|
||||
command *command.Commands
|
||||
query *query.Queries
|
||||
userCodeAlg crypto.EncryptionAlgorithm
|
||||
idpAlg crypto.EncryptionAlgorithm
|
||||
idpAlg crypto.AuthEncryptionAlgorithm
|
||||
idpCallback func(ctx context.Context) string
|
||||
samlRootURL func(ctx context.Context, idpID string) string
|
||||
|
||||
@@ -38,7 +38,7 @@ func CreateServer(
|
||||
command *command.Commands,
|
||||
query *query.Queries,
|
||||
userCodeAlg crypto.EncryptionAlgorithm,
|
||||
idpAlg crypto.EncryptionAlgorithm,
|
||||
idpAlg crypto.AuthEncryptionAlgorithm,
|
||||
idpCallback func(ctx context.Context) string,
|
||||
samlRootURL func(ctx context.Context, idpID string) string,
|
||||
assetAPIPrefix func(ctx context.Context) string,
|
||||
|
||||
@@ -505,7 +505,7 @@ func (s *Server) RetrieveIdentityProviderIntent(ctx context.Context, req *connec
|
||||
return idpIntentToIDPIntentPb(intent, s.idpAlg)
|
||||
}
|
||||
|
||||
func idpIntentToIDPIntentPb(intent *command.IDPIntentWriteModel, alg crypto.EncryptionAlgorithm) (_ *connect.Response[user.RetrieveIdentityProviderIntentResponse], err error) {
|
||||
func idpIntentToIDPIntentPb(intent *command.IDPIntentWriteModel, alg crypto.AuthEncryptionAlgorithm) (_ *connect.Response[user.RetrieveIdentityProviderIntentResponse], err error) {
|
||||
rawInformation := new(structpb.Struct)
|
||||
err = rawInformation.UnmarshalJSON(intent.IDPUser)
|
||||
if err != nil {
|
||||
@@ -547,7 +547,7 @@ func idpIntentToIDPIntentPb(intent *command.IDPIntentWriteModel, alg crypto.Encr
|
||||
return connect.NewResponse(information), nil
|
||||
}
|
||||
|
||||
func idpOAuthTokensToPb(idpIDToken string, idpAccessToken, idpRefreshToken *crypto.CryptoValue, alg crypto.EncryptionAlgorithm) (_ *user.IDPInformation_Oauth, err error) {
|
||||
func idpOAuthTokensToPb(idpIDToken string, idpAccessToken, idpRefreshToken *crypto.CryptoValue, alg crypto.AuthEncryptionAlgorithm) (_ *user.IDPInformation_Oauth, err error) {
|
||||
var idToken *string
|
||||
if idpIDToken != "" {
|
||||
idToken = &idpIDToken
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
)
|
||||
|
||||
func Test_idpIntentToIDPIntentPb(t *testing.T) {
|
||||
decryption := func(err error) crypto.EncryptionAlgorithm {
|
||||
mCrypto := crypto.NewMockEncryptionAlgorithm(gomock.NewController(t))
|
||||
decryption := func(err error) crypto.AuthEncryptionAlgorithm {
|
||||
mCrypto := crypto.NewMockAuthEncryptionAlgorithm(gomock.NewController(t))
|
||||
mCrypto.EXPECT().Algorithm().Return("enc")
|
||||
mCrypto.EXPECT().DecryptionKeyIDs().Return([]string{"id"})
|
||||
mCrypto.EXPECT().DecryptString(gomock.Any(), gomock.Any()).DoAndReturn(
|
||||
@@ -38,7 +38,7 @@ func Test_idpIntentToIDPIntentPb(t *testing.T) {
|
||||
|
||||
type args struct {
|
||||
intent *command.IDPIntentWriteModel
|
||||
alg crypto.EncryptionAlgorithm
|
||||
alg crypto.AuthEncryptionAlgorithm
|
||||
}
|
||||
type res struct {
|
||||
resp *user.RetrieveIdentityProviderIntentResponse
|
||||
|
||||
Reference in New Issue
Block a user