Skip to content

Commit

Permalink
feat: add flow internal context into post-login webhook context (PS-261)
Browse files Browse the repository at this point in the history
(cherry picked from commit ee4d463)
  • Loading branch information
splaunov committed Mar 22, 2024
1 parent 60537a9 commit 07b59ed
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions selfservice/hook/web_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ type (
}

templateContext struct {
Flow flow.Flow `json:"flow"`
RequestHeaders http.Header `json:"request_headers"`
RequestMethod string `json:"request_method"`
RequestURL string `json:"request_url"`
RequestCookies map[string]string `json:"request_cookies"`
Identity *identity.Identity `json:"identity,omitempty"`
Flow flow.Flow `json:"flow"`
InternalContext json.RawMessage `json:"internal_context"`
RequestHeaders http.Header `json:"request_headers"`
RequestMethod string `json:"request_method"`
RequestURL string `json:"request_url"`
RequestCookies map[string]string `json:"request_cookies"`
Identity *identity.Identity `json:"identity,omitempty"`
}

WebHook struct {
Expand Down Expand Up @@ -134,12 +135,13 @@ func (e *WebHook) ExecuteLoginPreHook(_ http.ResponseWriter, req *http.Request,
func (e *WebHook) ExecuteLoginPostHook(_ http.ResponseWriter, req *http.Request, _ node.UiNodeGroup, flow *login.Flow, session *session.Session) error {
return otelx.WithSpan(req.Context(), "selfservice.hook.WebHook.ExecuteLoginPostHook", func(ctx context.Context) error {
return e.execute(ctx, &templateContext{
Flow: flow,
RequestHeaders: req.Header,
RequestMethod: req.Method,
RequestURL: x.RequestURL(req).String(),
RequestCookies: cookies(req),
Identity: session.Identity,
Flow: flow,
InternalContext: json.RawMessage(flow.InternalContext),
RequestHeaders: req.Header,
RequestMethod: req.Method,
RequestURL: x.RequestURL(req).String(),
RequestCookies: cookies(req),
Identity: session.Identity,
})
})
}
Expand Down

0 comments on commit 07b59ed

Please sign in to comment.