mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
fix: use triggering origin for notification links (#6628)
* take baseurl if saved on event * refactor: make es mocks reusable * Revert "refactor: make es mocks reusable" This reverts commit434ce12a6a
. * make messages testable * test asset url * fmt * fmt * simplify notification.Start * test url combinations * support init code added * support password changed * support reset pw * support user domain claimed * support add pwless login * support verify phone * Revert "support verify phone" This reverts commite40503303e
. * save trigger origin from ctx * add ready for review check * camel * test email otp * fix variable naming * fix DefaultOTPEmailURLV2 * Revert "fix DefaultOTPEmailURLV2" This reverts commitfa34d4d2a8
. * fix email otp challenged test * fix email otp challenged test * pass origin in login and gateway requests * take origin from header * take x-forwarded if present * Update internal/notification/handlers/queries.go Co-authored-by: Tim Möhlmann <tim+github@zitadel.com> * Update internal/notification/handlers/commands.go Co-authored-by: Tim Möhlmann <tim+github@zitadel.com> * move origin header to ctx if available * generate * cleanup * use forwarded header * support X-Forwarded-* headers * standardize context handling * fix linting --------- Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
This commit is contained in:
@@ -45,6 +45,7 @@ type key int
|
||||
const (
|
||||
httpHeaders key = iota
|
||||
remoteAddr
|
||||
origin
|
||||
)
|
||||
|
||||
func CopyHeadersToContext(h http.Handler) http.Handler {
|
||||
@@ -61,7 +62,7 @@ func HeadersFromCtx(ctx context.Context) (http.Header, bool) {
|
||||
return headers, ok
|
||||
}
|
||||
|
||||
func OriginFromCtx(ctx context.Context) string {
|
||||
func OriginHeader(ctx context.Context) string {
|
||||
headers, ok := ctx.Value(httpHeaders).(http.Header)
|
||||
if !ok {
|
||||
return ""
|
||||
@@ -69,6 +70,18 @@ func OriginFromCtx(ctx context.Context) string {
|
||||
return headers.Get(Origin)
|
||||
}
|
||||
|
||||
func ComposedOrigin(ctx context.Context) string {
|
||||
o, ok := ctx.Value(origin).(string)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func WithComposedOrigin(ctx context.Context, composed string) context.Context {
|
||||
return context.WithValue(ctx, origin, composed)
|
||||
}
|
||||
|
||||
func RemoteIPFromCtx(ctx context.Context) string {
|
||||
ctxHeaders, ok := HeadersFromCtx(ctx)
|
||||
if !ok {
|
||||
|
Reference in New Issue
Block a user