fix: correctly send links to login v2 in email notifications (#10711)

# Which Problems Are Solved

There were still some emails (passkey registration and domain claimed)
sent with links pointing to login v1 even when the login v2 was enabled
for the instance.
Also while looking into the issue, it was discovered that some links
pointing to login V2 were not correctly generated.


# How the Problems Are Solved

- Added default paths for passkey registration and domain claimed
notifications
- Fixed the existing paths to properly handle concatenation (resp. use
`url.ResolveReference`)
  - Change their go types (from string) to `*url.URL` 
  - Added a mapstructure hook for string to url
- Removed unnecessary `InstanceSetupFeatures` and corresponding
conversions
- Refactored the methods on the `login.DefaultPaths` struct and added an
interface to the `Commands` to only need to pass a single config (and
not every method)
- Added an `OriginURL` method to the `DomainCtx` to prevent going from
url to string and back
- Added the use of the templates in case of enabled login v2 for passkey
registration and domain claimed)

# Additional Changes

None

# Additional Context

closes #10643

---------

Co-authored-by: Max Peintner <[email protected]>
Co-authored-by: Livio Spring <[email protected]>
Co-authored-by: Livio Spring <[email protected]>
Co-authored-by: Max Peintner <[email protected]>
Co-authored-by: Gayathri Vijayan <[email protected]>
This commit is contained in:
Stefan Benz
2026-02-13 13:06:56 +00:00
committed by GitHub
co-authored by Max Peintner Livio Spring Livio Spring Max Peintner Gayathri Vijayan
parent 382aec2d61
commit 2a2d5392a3
48 changed files with 1323 additions and 450 deletions
+96
View File
@@ -0,0 +1,96 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/zitadel/zitadel/internal/command (interfaces: LoginPaths)
//
// Generated by this command:
//
// mockgen -package command -destination ./mock_login_paths.go . LoginPaths
//
// Package command is a generated GoMock package.
package command
import (
context "context"
reflect "reflect"
gomock "go.uber.org/mock/gomock"
)
// MockLoginPaths is a mock of LoginPaths interface.
type MockLoginPaths struct {
ctrl *gomock.Controller
recorder *MockLoginPathsMockRecorder
}
// MockLoginPathsMockRecorder is the mock recorder for MockLoginPaths.
type MockLoginPathsMockRecorder struct {
mock *MockLoginPaths
}
// NewMockLoginPaths creates a new mock instance.
func NewMockLoginPaths(ctrl *gomock.Controller) *MockLoginPaths {
mock := &MockLoginPaths{ctrl: ctrl}
mock.recorder = &MockLoginPathsMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockLoginPaths) EXPECT() *MockLoginPathsMockRecorder {
return m.recorder
}
// DefaultDomainClaimedURLTemplate mocks base method.
func (m *MockLoginPaths) DefaultDomainClaimedURLTemplate(arg0 context.Context) string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DefaultDomainClaimedURLTemplate", arg0)
ret0, _ := ret[0].(string)
return ret0
}
// DefaultDomainClaimedURLTemplate indicates an expected call of DefaultDomainClaimedURLTemplate.
func (mr *MockLoginPathsMockRecorder) DefaultDomainClaimedURLTemplate(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultDomainClaimedURLTemplate", reflect.TypeOf((*MockLoginPaths)(nil).DefaultDomainClaimedURLTemplate), arg0)
}
// DefaultEmailCodeURLTemplate mocks base method.
func (m *MockLoginPaths) DefaultEmailCodeURLTemplate(arg0 context.Context) string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DefaultEmailCodeURLTemplate", arg0)
ret0, _ := ret[0].(string)
return ret0
}
// DefaultEmailCodeURLTemplate indicates an expected call of DefaultEmailCodeURLTemplate.
func (mr *MockLoginPathsMockRecorder) DefaultEmailCodeURLTemplate(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultEmailCodeURLTemplate", reflect.TypeOf((*MockLoginPaths)(nil).DefaultEmailCodeURLTemplate), arg0)
}
// DefaultPasskeySetURLTemplate mocks base method.
func (m *MockLoginPaths) DefaultPasskeySetURLTemplate(arg0 context.Context) string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DefaultPasskeySetURLTemplate", arg0)
ret0, _ := ret[0].(string)
return ret0
}
// DefaultPasskeySetURLTemplate indicates an expected call of DefaultPasskeySetURLTemplate.
func (mr *MockLoginPathsMockRecorder) DefaultPasskeySetURLTemplate(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultPasskeySetURLTemplate", reflect.TypeOf((*MockLoginPaths)(nil).DefaultPasskeySetURLTemplate), arg0)
}
// DefaultPasswordSetURLTemplate mocks base method.
func (m *MockLoginPaths) DefaultPasswordSetURLTemplate(arg0 context.Context) string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DefaultPasswordSetURLTemplate", arg0)
ret0, _ := ret[0].(string)
return ret0
}
// DefaultPasswordSetURLTemplate indicates an expected call of DefaultPasswordSetURLTemplate.
func (mr *MockLoginPathsMockRecorder) DefaultPasswordSetURLTemplate(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultPasswordSetURLTemplate", reflect.TypeOf((*MockLoginPaths)(nil).DefaultPasswordSetURLTemplate), arg0)
}