From bb414fd241c9c121da0fefd73f0651a42ecfdac1 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Mon, 19 Oct 2026 10:05:58 +0200 Subject: [PATCH 1/2] fix(invite): Back to application lands in the workspace, not on /start INVITE_REDIRECT_URI may contain {slug}; the registry replaces it with the workspace slug at all three invite sites (new workspace, member invite, resend). Stage and prod currently point at /start?invited=1, which the portal does not handle, so invitees landed on the trial signup form after setting their password. With https://app.breakpilot.com/{slug}/dashboard they arrive signed in in their workspace. A redirect without {slug} stays as configured, so this is safe to deploy before the env change. Co-Authored-By: Claude Opus 5.5 --- internal/keycloak/client.go | 5 ++++- internal/keycloak/members.go | 4 ++-- internal/keycloak/members_test.go | 22 ++++++++++++++++++++-- internal/keycloak/orgs.go | 8 +++++++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/internal/keycloak/client.go b/internal/keycloak/client.go index 64289fd..42d4cae 100644 --- a/internal/keycloak/client.go +++ b/internal/keycloak/client.go @@ -38,7 +38,10 @@ type HTTPConfig struct { // Invite mail: which client + redirect the execute-actions email uses. // Defaults keep the dev realm working; stage/prod set portal-{env} and - // the portal's public URL. + // the portal's public URL. "{slug}" in the redirect is replaced by the + // workspace slug, so "Back to application" lands in the workspace + // (e.g. https://app.breakpilot.com/start?invited=1&ws={slug}, which the + // portal forwards to //dashboard; Keycloak only allows /start*). InviteClientID string InviteRedirectURI string } diff --git a/internal/keycloak/members.go b/internal/keycloak/members.go index 598dccc..5519f10 100644 --- a/internal/keycloak/members.go +++ b/internal/keycloak/members.go @@ -148,7 +148,7 @@ func (a *HTTPAdapter) InviteMember(ctx context.Context, in MemberInviteInput) (* _ = resp.Body.Close() res := &MemberInviteResult{UserID: userID, Status: InviteStatusInvited, Created: created} - if _, merr := a.executeActionsEmail(ctx, userID, []string{"VERIFY_EMAIL", "UPDATE_PASSWORD"}, a.cfg.InviteRedirectURI); merr != nil { + if _, merr := a.executeActionsEmail(ctx, userID, []string{"VERIFY_EMAIL", "UPDATE_PASSWORD"}, a.inviteRedirect(in.Slug)); merr != nil { res.MailError = merr } return res, nil @@ -204,7 +204,7 @@ func (a *HTTPAdapter) ResendInvite(ctx context.Context, slug, email string) erro } for _, m := range members { if strings.EqualFold(m.Email, email) { - _, err := a.executeActionsEmail(ctx, m.UserID, []string{"VERIFY_EMAIL", "UPDATE_PASSWORD"}, a.cfg.InviteRedirectURI) + _, err := a.executeActionsEmail(ctx, m.UserID, []string{"VERIFY_EMAIL", "UPDATE_PASSWORD"}, a.inviteRedirect(slug)) return err } } diff --git a/internal/keycloak/members_test.go b/internal/keycloak/members_test.go index b96b0fe..c9dec4d 100644 --- a/internal/keycloak/members_test.go +++ b/internal/keycloak/members_test.go @@ -22,6 +22,7 @@ type membersKC struct { users map[string]memberRepresentation // user id → user brief bool // member list omits attributes mails []string // user ids that got the execute-actions mail + redirects []string // redirect_uri of each execute-actions mail created []userCreate puts map[string]map[string][]string // user id → attributes PUT createErr int // non-zero: POST /users answers this status @@ -181,11 +182,12 @@ func newMembersKC(t *testing.T) (*membersKC, *HTTPAdapter) { mux.HandleFunc("PUT /admin/realms/test-realm/users/{id}/execute-actions-email", func(w http.ResponseWriter, r *http.Request) { k.mu.Lock() defer k.mu.Unlock() - if r.URL.Query().Get("client_id") != "portal-test" || r.URL.Query().Get("redirect_uri") != "https://portal.test/onboard" { + if r.URL.Query().Get("client_id") != "portal-test" { http.Error(w, "bad invite client", http.StatusBadRequest) return } k.mails = append(k.mails, r.PathValue("id")) + k.redirects = append(k.redirects, r.URL.Query().Get("redirect_uri")) w.WriteHeader(http.StatusNoContent) }) mux.HandleFunc("GET /admin/realms/test-realm/users/{id}/credentials", func(w http.ResponseWriter, r *http.Request) { @@ -261,7 +263,7 @@ func newMembersKC(t *testing.T) (*membersKC, *HTTPAdapter) { t.Cleanup(srv.Close) a := NewHTTPAdapter(HTTPConfig{ BaseURL: srv.URL, Realm: "test-realm", ClientID: "c", ClientSecret: "s", Timeout: 5 * time.Second, - InviteClientID: "portal-test", InviteRedirectURI: "https://portal.test/onboard", + InviteClientID: "portal-test", InviteRedirectURI: "https://portal.test/{slug}/dashboard", }) return k, a } @@ -326,6 +328,10 @@ func TestHTTPAdapter_InviteMember_newUser(t *testing.T) { if len(k.mails) != 1 || k.mails[0] != res.UserID { t.Errorf("execute-actions mail: %v", k.mails) } + // "Back to application" in the invite must land in the workspace, not on /start. + if len(k.redirects) != 1 || k.redirects[0] != "https://portal.test/acme/dashboard" { + t.Errorf("invite redirect: %v", k.redirects) + } if got := k.members["org-acme"]; len(got) != 2 || got[1] != res.UserID { t.Errorf("membership: %v", got) } @@ -441,3 +447,15 @@ func TestListOrgMembers_findsOrgByAliasNotName(t *testing.T) { t.Fatalf("unknown alias: want ErrOrgNotFound, got %v", err) } } + +func TestHTTPAdapter_InviteRedirect(t *testing.T) { + a := NewHTTPAdapter(HTTPConfig{InviteRedirectURI: "https://app.test/{slug}/dashboard"}) + if got := a.inviteRedirect("acme"); got != "https://app.test/acme/dashboard" { + t.Errorf("slug placeholder: %s", got) + } + // A fixed redirect without the placeholder stays as configured. + b := NewHTTPAdapter(HTTPConfig{InviteRedirectURI: "https://app.test/start"}) + if got := b.inviteRedirect("acme"); got != "https://app.test/start" { + t.Errorf("fixed redirect: %s", got) + } +} diff --git a/internal/keycloak/orgs.go b/internal/keycloak/orgs.go index 451b3e4..70b46f9 100644 --- a/internal/keycloak/orgs.go +++ b/internal/keycloak/orgs.go @@ -167,7 +167,7 @@ func (a *HTTPAdapter) CreateOrgAndInvite(ctx context.Context, in InviteInput) (* if in.EmailVerified { actions = []string{"UPDATE_PASSWORD"} } - inviteURL, err := a.executeActionsEmail(ctx, userID, actions, a.cfg.InviteRedirectURI) + inviteURL, err := a.executeActionsEmail(ctx, userID, actions, a.inviteRedirect(in.Slug)) if err != nil { // Non-fatal: the account exists, the mail can be resent. return &InviteResult{OrganizationID: orgID, UserID: userID, MailError: err}, nil @@ -296,6 +296,12 @@ func (a *HTTPAdapter) findUserByEmail(ctx context.Context, email string) (string return "", errUserLookupMiss } +// inviteRedirect is the configured invite redirect with "{slug}" replaced by +// the workspace slug. +func (a *HTTPAdapter) inviteRedirect(slug string) string { + return strings.ReplaceAll(a.cfg.InviteRedirectURI, "{slug}", url.PathEscape(slug)) +} + func (a *HTTPAdapter) executeActionsEmail(ctx context.Context, userID string, actions []string, redirectURI string) (string, error) { resp, err := a.adminCall(ctx, http.MethodPut, fmt.Sprintf("/users/%s/execute-actions-email?client_id=%s&redirect_uri=%s", userID, url.QueryEscape(a.cfg.InviteClientID), url.QueryEscape(redirectURI)), From 3551d2355b911477d7e0006ca2549ce8f2bfa450 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Mon, 19 Oct 2026 10:11:53 +0200 Subject: [PATCH 2/2] build(deps): kin-openapi 0.149.0 (CVE-2026-100349, -100351..-100354) Trivy fails the shared job on five HIGH advisories in kin-openapi 0.144.0; all are fixed by 0.149.0. Co-Authored-By: Claude Opus 5.5 --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index e7002cf..a3e051a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.26.0 require ( github.com/coreos/go-oidc/v3 v3.20.0 - github.com/getkin/kin-openapi v0.144.0 + github.com/getkin/kin-openapi v0.149.0 github.com/go-jose/go-jose/v4 v4.1.4 github.com/golang-migrate/migrate/v4 v4.19.1 github.com/google/uuid v1.6.0 @@ -68,7 +68,7 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/rs/xid v1.6.0 // indirect - github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect + github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 // indirect github.com/shirou/gopsutil/v4 v4.26.3 // indirect github.com/sirupsen/logrus v1.9.4 // indirect github.com/stretchr/testify v1.11.1 // indirect diff --git a/go.sum b/go.sum index 56a6272..0ad2679 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,8 @@ github.com/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ github.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/getkin/kin-openapi v0.144.0 h1:hIRcTH+KjLfkLpYU6bSSfdFpi0fZi1fp+hSPi4aQu9Y= -github.com/getkin/kin-openapi v0.144.0/go.mod h1:3BH9M9XDe/y9M5DSvEocVYAYq1w0qrhJHjC/vZi0AaY= +github.com/getkin/kin-openapi v0.149.0 h1:ZbhmVJ4yq5RZDUsyP8lcBcGMsjsaTqXEFt6isdtMDfA= +github.com/getkin/kin-openapi v0.149.0/go.mod h1:1+BHDzstro+P5CKtPy1X4PfofnFgmRe6uvMy9+r9fKY= github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA= @@ -151,8 +151,8 @@ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0t github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/shirou/gopsutil/v4 v4.26.3 h1:2ESdQt90yU3oXF/CdOlRCJxrP+Am1aBYubTMTfxJ1qc= github.com/shirou/gopsutil/v4 v4.26.3/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ= github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=