Skip to content

Commit

Permalink
fix: add HydraLoginRequest on flow creation (#3152)
Browse files Browse the repository at this point in the history
The oauth2_login_request field was missing when initially creating the login flow.

Closes #3108
  • Loading branch information
CaptainStandby committed Mar 8, 2023
1 parent 6d83dc9 commit 09312dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions selfservice/flow/login/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ func (h *Handler) createBrowserLoginFlow(w http.ResponseWriter, r *http.Request,
return
}

a.HydraLoginRequest = hlr

x.AcceptToRedirectOrJSON(w, r, h.d.Writer(), a, a.AppendTo(h.d.Config().SelfServiceFlowLoginUI(r.Context())).String())
}

Expand Down
7 changes: 7 additions & 0 deletions selfservice/flow/login/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ func TestFlowLifecycle(t *testing.T) {
res, _ := initAuthenticatedFlow(t, url.Values{"login_challenge": {hydra.FAKE_SUCCESS}}, false)
require.Contains(t, res.Request.URL.String(), loginTS.URL)
})

t.Run("case=oauth2 flow init adds oauth2_login_request field", func(t *testing.T) {
res, body := initSPAFlow(t, url.Values{"login_challenge": {hydra.FAKE_SUCCESS}})
assert.NotContains(t, res.Request.URL.String(), loginTS.URL)

assert.NotEmpty(t, gjson.GetBytes(body, "oauth2_login_request").Value(), "%s", body)
})
})

t.Run("case=relative redirect when self-service login ui is a relative URL", func(t *testing.T) {
Expand Down

0 comments on commit 09312dd

Please sign in to comment.