Skip to content

Commit 1ab143c

Browse files
jonas-jonasory-bot
authored andcommitted
fix: transfer OAuth2 login challenge in account linking flow
GitOrigin-RevId: b666119e260f3b0b2071161578b5179e49a89616
1 parent 048d315 commit 1ab143c

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

selfservice/flow/login/handler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ func WithIsAccountLinking() FlowOption {
130130
}
131131
}
132132

133+
func WithLoginChallenge(loginChallenge string) FlowOption {
134+
return func(f *Flow) {
135+
f.OAuth2LoginChallenge = sqlxx.NullString(loginChallenge)
136+
}
137+
}
138+
133139
func (h *Handler) NewLoginFlow(w http.ResponseWriter, r *http.Request, ft flow.Type, opts ...FlowOption) (*Flow, *session.Session, error) {
134140
conf := h.d.Config()
135141
f, err := NewFlow(conf, conf.SelfServiceFlowLoginRequestLifespan(r.Context()), h.d.GenerateCSRFToken(r), r, ft)

selfservice/strategy/oidc/strategy_registration.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ func (s *Strategy) registrationToLogin(ctx context.Context, w http.ResponseWrite
274274
}
275275

276276
opts = append(opts, login.WithInternalContext(rf.InternalContext), login.WithIsAccountLinking())
277+
if rf.OAuth2LoginChallenge != "" {
278+
opts = append(opts, login.WithLoginChallenge(rf.OAuth2LoginChallenge.String()))
279+
}
277280

278281
lf, _, err := s.d.LoginHandler().NewLoginFlow(w, r, rf.Type, opts...)
279282
if err != nil {

0 commit comments

Comments
 (0)