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 Jun 13, 2024
1 parent 1a70648 commit 6ad618e
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions selfservice/hook/web_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ 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"`
Session *session.Session `json:"session,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"`
Session *session.Session `json:"session,omitempty"`
}

WebHook struct {
Expand Down Expand Up @@ -135,13 +136,14 @@ 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,
Session: session,
Flow: flow,
InternalContext: json.RawMessage(flow.InternalContext),
RequestHeaders: req.Header,
RequestMethod: req.Method,
RequestURL: x.RequestURL(req).String(),
RequestCookies: cookies(req),
Identity: session.Identity,
Session: session,
})
})
}
Expand Down

0 comments on commit 6ad618e

Please sign in to comment.