Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set correct request url in acc linking and oidc flows #4282

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/client-go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
6 changes: 0 additions & 6 deletions selfservice/flow/login/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ func WithOrganizationID(organizationID uuid.NullUUID) FlowOption {
}
}

func WithRequestedAAL(aal identity.AuthenticatorAssuranceLevel) FlowOption {
return func(f *Flow) {
f.RequestedAAL = aal
}
}

func WithInternalContext(internalContext []byte) FlowOption {
return func(f *Flow) {
f.InternalContext = internalContext
Expand Down
6 changes: 2 additions & 4 deletions selfservice/strategy/oidc/strategy_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,11 @@ func (s *Strategy) processLogin(ctx context.Context, w http.ResponseWriter, r *h
registrationFlow.OrganizationID = loginFlow.OrganizationID
registrationFlow.IDToken = loginFlow.IDToken
registrationFlow.RawIDTokenNonce = loginFlow.RawIDTokenNonce
registrationFlow.RequestURL, err = x.TakeOverReturnToParameter(loginFlow.RequestURL, registrationFlow.RequestURL)
registrationFlow.TransientPayload = loginFlow.TransientPayload
registrationFlow.Active = s.ID()

if err != nil {
return nil, s.handleError(ctx, w, r, loginFlow, provider.Config().ID, nil, err)
}
// We are converting the flow here, but want to retain the original request URL.
registrationFlow.RequestURL = loginFlow.RequestURL

if _, err := s.processRegistration(ctx, w, r, registrationFlow, token, claims, provider, container); err != nil {
return registrationFlow, err
Expand Down
10 changes: 6 additions & 4 deletions selfservice/strategy/oidc/strategy_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,12 @@ func (s *Strategy) registrationToLogin(ctx context.Context, w http.ResponseWrite
return nil, err
}

lf.RequestURL, err = x.TakeOverReturnToParameter(rf.RequestURL, lf.RequestURL)
if err != nil {
return nil, err
}
// In this scenario, we are performing account linking. The request URL is set to the "original" registration URL
// the user used to try and sign up (which triggered the account linking flow).
//
// In this scenario we want to keep the original request url instead of the current request url, as the current
// request url is an "in-between" state where we are half-way through performing account linking.
lf.RequestURL = rf.RequestURL
lf.TransientPayload = rf.TransientPayload
lf.Active = s.ID()
lf.OrganizationID = rf.OrganizationID
Expand Down
1 change: 1 addition & 0 deletions selfservice/strategy/oidc/strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,7 @@ func TestStrategy(t *testing.T) {
assert.True(t, gjson.GetBytes(body, "ui.nodes.#(attributes.name==password)").Exists(), "%s", body)
assert.Equal(t, "[email protected]", gjson.GetBytes(body, "ui.messages.#(id==1010016).context.duplicateIdentifier").String())
assert.Equal(t, gjson.GetBytes(body, "organization_id").String(), orgID.String())
assert.NotContains(t, gjson.GetBytes(body, "request_url").String(), "code=")
linkingLoginFlow.ID = gjson.GetBytes(body, "id").String()
linkingLoginFlow.UIAction = gjson.GetBytes(body, "ui.action").String()
linkingLoginFlow.CSRFToken = gjson.GetBytes(body, `ui.nodes.#(attributes.name=="csrf_token").attributes.value`).String()
Expand Down
Loading