fix: configure default url templates (#10416)

# Which Problems Are Solved

Emails are still send only with URLs to login v1.

# How the Problems Are Solved

Add configuration for URLs as URL templates, so that links can point at
Login v2.

# Additional Changes

None

# Additional Context

Closes #10236

---------

Co-authored-by: Marco A. <[email protected]>
This commit is contained in:
Stefan Benz
2025-08-26 10:14:41 +00:00
committed by GitHub
co-authored by Marco A.
parent 2718d345b8
commit 0a14c01412
18 changed files with 370 additions and 77 deletions
+37 -1
View File
@@ -52,7 +52,43 @@ type Config struct {
AssetCache middleware.CacheConfig
// LoginV2
DefaultOTPEmailURLV2 string
DefaultPaths *DefaultPaths
}
type DefaultPaths struct {
BasePath string
PasswordSetPath string
EmailCodePath string
OTPEmailPath string
}
func (c *Config) defaultBaseURL(ctx context.Context) string {
loginV2 := authz.GetInstance(ctx).Features().LoginV2
if loginV2.Required {
// use the origin as default
baseURI := http_utils.DomainContext(ctx).Origin()
// use custom base URI if defined
if loginV2.BaseURI != nil && loginV2.BaseURI.String() != "" {
baseURI = loginV2.BaseURI.String()
}
return baseURI + c.DefaultPaths.BasePath
}
return ""
}
func (c *Config) DefaultEmailCodeURLTemplate(ctx context.Context) string {
basePath := c.defaultBaseURL(ctx)
if basePath == "" {
return ""
}
return basePath + c.DefaultPaths.EmailCodePath
}
func (c *Config) DefaultPasswordSetURLTemplate(ctx context.Context) string {
basePath := c.defaultBaseURL(ctx)
if basePath == "" {
return ""
}
return c.defaultBaseURL(ctx) + c.DefaultPaths.PasswordSetPath
}
const (