feat(identity): add server sessions and audited mail recovery

This commit is contained in:
TakuyaYagam1 committed 2026-10-07 11:03:46 +03:00
1 parent 20c03288d6
commit 4ee53d9a74
58 files changed
+5359 -567

No files matched your search

@@ -20,6 +20,7 @@ type countingHasher struct {
hashCalls int
hashed domain.Password
verifyCalls int
dummyCalls int
verified domain.Password
stored domain.PasswordHash
verifyErr error
@@ -39,7 +40,8 @@ func (hasher *countingHasher) Verify(_ context.Context, password domain.Password
}
func (hasher *countingHasher) VerifyDummy(context.Context, domain.Password) error {
return errors.New("countingHasher.VerifyDummy - not used")
hasher.dummyCalls++
return outbound.ErrPasswordMismatch
}
var _ outbound.PasswordHasher = (*countingHasher)(nil)
@@ -116,3 +118,16 @@ func TestVerifyLoginPasswordRejectsEmptyInputBeforeKDF(t *testing.T) {
t.Fatalf("VerifyLoginPassword(empty) = %v after %d verify calls, want ErrInvalidPassword before KDF", err, hasher.verifyCalls)
}
}
func TestVerifyDummyLoginPasswordAlwaysRunsDummyHashWork(t *testing.T) {
hasher := &countingHasher{}
credentials := NewCredentials(hasher)
for _, password := range []string{"correct horse battery staple", ""} {
if err := credentials.VerifyDummyLoginPassword(context.Background(), password); !errors.Is(err, outbound.ErrPasswordMismatch) {
t.Fatalf("VerifyDummyLoginPassword() error = %v, want ErrPasswordMismatch", err)
}
}
if hasher.dummyCalls != 2 || hasher.verifyCalls != 0 {
t.Fatalf("dummy calls=%d normal calls=%d, want two dummy calls", hasher.dummyCalls, hasher.verifyCalls)
}
}