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
+2 -49
View File
@@ -2,7 +2,6 @@ package command
import (
"context"
"net/url"
"strings"
"time"
@@ -15,7 +14,6 @@ import (
"github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/feature"
"github.com/zitadel/zitadel/internal/i18n"
"github.com/zitadel/zitadel/internal/id"
"github.com/zitadel/zitadel/internal/notification/channels/smtp"
@@ -124,57 +122,12 @@ type InstanceSetup struct {
SMTPConfiguration *SMTPConfiguration
OIDCSettings *OIDCSettings
Quotas *SetQuotas
Features *InstanceSetupFeatures
Features *InstanceFeatures
Limits *SetLimits
Restrictions *SetRestrictions
RolePermissionMappings []authz.RoleMapping
}
type InstanceSetupFeatures struct {
LoginDefaultOrg *bool
UserSchema *bool
ImprovedPerformance []feature.ImprovedPerformanceType
DebugOIDCParentError *bool
OIDCSingleV1SessionTermination *bool
LoginV2 *InstanceSetupFeatureLoginV2
PermissionCheckV2 *bool
ManagementConsoleUseV2UserApi *bool
EnableRelationalTables *bool
}
type InstanceSetupFeatureLoginV2 struct {
Required bool `json:"required,omitempty"`
BaseURI *string `json:"base_uri,omitempty"`
}
func (f *InstanceSetupFeatures) ToInstanceFeatures() (_ *InstanceFeatures, err error) {
if f == nil {
return nil, nil
}
var loginV2 *feature.LoginV2
if f.LoginV2 != nil {
loginV2 = &feature.LoginV2{Required: f.LoginV2.Required}
if f.LoginV2.BaseURI != nil {
loginV2.BaseURI, err = url.Parse(*f.LoginV2.BaseURI)
if err != nil {
return nil, err
}
}
}
return &InstanceFeatures{
LoginDefaultOrg: f.LoginDefaultOrg,
UserSchema: f.UserSchema,
ImprovedPerformance: f.ImprovedPerformance,
DebugOIDCParentError: f.DebugOIDCParentError,
OIDCSingleV1SessionTermination: f.OIDCSingleV1SessionTermination,
LoginV2: loginV2,
PermissionCheckV2: f.PermissionCheckV2,
ManagementConsoleUseV2UserApi: f.ManagementConsoleUseV2UserApi,
EnableRelationalTables: f.EnableRelationalTables,
}, nil
}
type SMTPConfiguration struct {
Description string
SMTP smtp.SMTP
@@ -468,7 +421,7 @@ func setupQuotas(commands *Commands, validations *[]preparation.Validation, setQ
return nil
}
func setupFeatures(validations *[]preparation.Validation, features *InstanceSetupFeatures, instanceID string) {
func setupFeatures(validations *[]preparation.Validation, features *InstanceFeatures, instanceID string) {
if features != nil {
*validations = append(*validations, prepareSetFeatures(instanceID, features))
}