feat(session): IDP Intent Check API with relation tables (#11820)

# Which Problems Are Solved

As part of #11035 , this PR implements the IDP intent check logic for
session validation

# How the Problems Are Solved

- Inject encryption algorithm for IDP intent tokens at DB initialization
  - Add the IDP intent repository as an invoke option
  - Rework crypto mocks using gomock
  - Implement IDP intent check logic
- minor - DB: expand IDP Intent deletion testing table with a test case
where IDP intent is not found

# Noteworthy

I did not implement `domain.Transactional` given the doubts that
@adlerhurst expressed in https://github.com/zitadel/zitadel/pull/11804 .
So, there is no transaction AT ALL in here because the `Execute()`
method contains one single DB call (Delete) and `Validate()` just does
Get calls.

# Additional Context

This is a cherry-picked PR + minor changes, coming from
https://github.com/zitadel/zitadel/pull/11164
- Relates to #11035
- Depends on https://github.com/zitadel/zitadel/pull/11804
This commit is contained in:
Marco A.
2026-03-17 10:50:47 +00:00
committed by GitHub
parent 3fdac54878
commit aa4432dc99
16 changed files with 1422 additions and 157 deletions
@@ -0,0 +1,17 @@
package convert
import (
"github.com/zitadel/zitadel/backend/v3/domain"
session_grpc "github.com/zitadel/zitadel/pkg/grpc/session/v2"
)
func CheckIDPIntentGRPCToDomain(checkIDPIntent *session_grpc.CheckIDPIntent) *domain.CheckIDPIntentType {
if checkIDPIntent == nil {
return nil
}
return &domain.CheckIDPIntentType{
ID: checkIDPIntent.GetIdpIntentId(),
Token: checkIDPIntent.GetIdpIntentToken(),
}
}
@@ -0,0 +1,55 @@
package convert
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zitadel/zitadel/backend/v3/domain"
session_grpc "github.com/zitadel/zitadel/pkg/grpc/session/v2"
)
func TestCheckIDPIntentGRPCToDomain(t *testing.T) {
t.Parallel()
tt := []struct {
testName string
input *session_grpc.CheckIDPIntent
expected *domain.CheckIDPIntentType
}{
{
testName: "nil input",
input: nil,
expected: nil,
},
{
testName: "valid input",
input: &session_grpc.CheckIDPIntent{
IdpIntentId: "intent-123",
IdpIntentToken: "token-abc",
},
expected: &domain.CheckIDPIntentType{
ID: "intent-123",
Token: "token-abc",
},
},
{
testName: "empty strings",
input: &session_grpc.CheckIDPIntent{
IdpIntentId: "",
IdpIntentToken: "",
},
expected: &domain.CheckIDPIntentType{
ID: "",
Token: "",
},
},
}
for _, tc := range tt {
t.Run(tc.testName, func(t *testing.T) {
t.Parallel()
result := CheckIDPIntentGRPCToDomain(tc.input)
assert.Equal(t, tc.expected, result)
})
}
}