feat(session): Password Check API with relation tables (#11804)

# Which Problems Are Solved

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

# How the Problems Are Solved

- Add system config to default configuration of `domain` package for
easy initialization. Intialize the system settings when Zitadel starts
up
- Add password hasher verify logic to the default configuration of
`domain` package. Initialize it when Zitadel starts up.
  - Add settings repositories with their mocks
  - Implement the logic for doing a password check

# 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/11777
This commit is contained in:
Marco A.
2026-03-13 11:40:48 +01:00
committed by GitHub
parent d08779e279
commit 3c3201e5a0
26 changed files with 12932 additions and 2 deletions
@@ -0,0 +1,16 @@
package convert
import (
"github.com/zitadel/zitadel/backend/v3/domain"
session_grpc "github.com/zitadel/zitadel/pkg/grpc/session/v2"
)
func CheckPasswordGRPCToDomain(checkPsw *session_grpc.CheckPassword) *domain.CheckPasswordType {
if checkPsw == nil {
return nil
}
return &domain.CheckPasswordType{
Password: checkPsw.GetPassword(),
}
}
@@ -0,0 +1,38 @@
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 TestCheckPasswordGRPCToDomain(t *testing.T) {
t.Parallel()
tt := []struct {
testName string
inputCheckPsw *session_grpc.CheckPassword
expected *domain.CheckPasswordType
}{
{testName: "when nil input should return nil output"},
{
testName: "when not nil input should return valid output",
inputCheckPsw: &session_grpc.CheckPassword{Password: "pw"},
expected: &domain.CheckPasswordType{Password: "pw"},
},
}
for _, tc := range tt {
t.Run(tc.testName, func(t *testing.T) {
t.Parallel()
// Test
res := CheckPasswordGRPCToDomain(tc.inputCheckPsw)
// Verify
assert.Equal(t, tc.expected, res)
})
}
}
@@ -6,7 +6,7 @@ import (
session_grpc "github.com/zitadel/zitadel/pkg/grpc/session/v2"
)
func CheckUserGRPCToQueryOpt(checkUser *session_grpc.CheckUser) (*domain.CheckUserType, error) {
func CheckUserGRPCToDomain(checkUser *session_grpc.CheckUser) (*domain.CheckUserType, error) {
var toReturn *domain.CheckUserType
if checkUser == nil {
return toReturn, nil
@@ -47,7 +47,7 @@ func TestCheckUserGRPCToQueryOpt(t *testing.T) {
t.Parallel()
// Test
res, err := CheckUserGRPCToQueryOpt(tc.inputCheckUser)
res, err := CheckUserGRPCToDomain(tc.inputCheckUser)
// Verify
assert.ErrorIs(t, err, tc.expectedError)