Commit Graph
20 Commits
Author SHA1 Message Date
Sharang Parnerkar 76b836653a fix(onprem): only directory users join a workspace
In directory mode the registry attached any Keycloak user found by
e-mail. On an installation the realm also holds our local staff accounts
(onprem keycloak/staff-account.sh): a workspace admin could add one to
their team (201 added), giving our support account workspace attributes
and membership. Found in the test install.

Now only a user with a federation link (from the AD) counts, for the
first admin and for members; a local account answers not_in_directory
like an unknown address. The cloud is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1b821baa7b)
2026-11-20 17:08:48 +01:00
Sharang Parnerkar 90ae11ae42 feat(onprem): directory users instead of invitations
On-prem every account comes from the customer's AD through Keycloak's
federation, so an AD admin answered email_taken and invitations asked for a
new password. The Keycloak adapter gets a directory mode (DirectoryUsers,
on with APP_ENV=onprem):

- The first admin and invited members are existing directory users,
  attached to the organization with their role. No local user is created,
  no execute-actions mail is sent (invite status "added", audit user.added /
  keycloak.admin_added).
- An unknown address (or one outside the admitted AD groups) answers 404
  not_in_directory. For the workspace's admin it is checked before the
  workspace is created, and the adapter looks the user up before creating
  the organization, so nothing is left behind.
- Resend answers 409 no_invite_mail; directory members are never pending.
- Member lists read the roles from the user when Keycloak lists a federated
  member with its LDAP attributes only (seen with Keycloak 26.8).
- The admin address is normalized once for lookup, store and Keycloak.

Checked against Keycloak 26.8.1 with a Samba AD (the test install in
platform/onprem, realm with UNSYNCED federation and realm-policy.sh).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b8206c553f)
2026-11-20 17:08:48 +01:00
Sharang ParnerkarandClaude Opus 5.5 fe05192182 feat(authz): individual capabilities per member (RBAC step 3)
ci / shared (pull_request) Successful in 26s
ci / test (pull_request) Successful in 6m7s
ci / image (pull_request) Skipped
A member can hold capabilities on top of their bundle. They live in the
Keycloak user attribute extra_capabilities, which the tenant-context
mapper puts into the token; the registry writes it like org_roles and
clears it when the member leaves.

- POST/DELETE /v1/tenants/{id}/members/{uid}/capabilities[/{cap}]
- a person who holds registry:members.manage grants, never on
  themselves, and only what they hold themselves
- an administration capability waits for a second person: open
  requests in capability_requests (0029), approve or reject under
  /v1/tenants/{id}/capability-requests
- a role change keeps the extras; the principal parses the claim, the
  registry's own checks still go by org_roles

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
2026-11-11 13:39:36 +01:00
Sharang ParnerkarandClaude Opus 5.5 bb414fd241 fix(invite): Back to application lands in the workspace, not on /start
ci / shared (pull_request) Failing after 15s
ci / test (pull_request) Successful in 25m47s
ci / image (pull_request) Skipped
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 <noreply@anthropic.com>
2026-10-19 10:06:29 +02:00
sharangandClaude Opus 5.5 1f6236a754 feat(members): team management: role, block, remove, revoke, resend (#64)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 24m46s
ci / image (push) Successful in 33s
portal#74: PATCH/DELETE /v1/tenants/{id}/members/{uid}, POST .../resend and the staff variants; per-workspace block via org_blocked, session logout, last-admin and self guards, audit events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-10-05 18:43:31 +00:00
sharangandClaude Opus 5.5 60f20e6419 feat(trial): legal trial signup: offer, confirmation, activation (#58)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 23m58s
ci / image (push) Successful in 36s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-30 16:00:52 +00:00
sharangandClaude Opus 5.5 485f3432ac fix(keycloak): keep email and names when writing user attributes (#43)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 23m29s
ci / image (push) Successful in 35s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-28 07:44:45 +00:00
sharangandClaude Opus 5.5 e8dcd1d259 feat(admin): repair a tenant's sign-in, delete an archived tenant (#42)
ci / shared (push) Successful in 15s
ci / test (push) Successful in 23m50s
ci / image (push) Successful in 45s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-26 11:00:14 +00:00
sharangandClaude Opus 5.5 7834907562 fix(signup): report when Keycloak refuses to send the invitation (#39)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 25m6s
ci / image (push) Successful in 36s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-24 11:50:23 +00:00
sharangandClaude Opus 5.5 0a26331ffd fix(signup): reject an email that already has an account (#37)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 23m29s
ci / image (push) Successful in 32s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 22:09:00 +00:00
sharang 54e9f6a720 feat(admin): staff tenant list, detail, trial extension, invite resend (#33)
ci / shared (push) Successful in 11s
ci / test (push) Successful in 22m43s
ci / image (push) Successful in 44s
2026-09-23 19:57:59 +00:00
sharang 33ba32ef30 fix(keycloak): resolve an organization by alias, not by display name (#30)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 22m28s
ci / image (push) Successful in 25s
2026-09-14 11:30:00 +00:00
sharangandSharang Parnerkar 99214c088b feat(members): tenant organization members, invites, admin email (#28)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 22m21s
ci / image (push) Successful in 25s
Demonstration plan, phase D1 (registry side). The portal's Settings/Users page renders design fixtures today and its "Invite member" button posts to a route that does not exist, because the registry had no membership surface.

**`GET /v1/tenants/{id}/members`** lists the tenant's Keycloak organization members — user id, email, first/last name, `org_roles`, `enabled`, `created_at`. A tenant whose organization was never created (sales-led) answers an empty list rather than an error.

**`POST /v1/tenants/{id}/invites`** `{email, first_name?, last_name?, role?}` creates the Keycloak user if missing, adds the organization member (KC 26: the member body is the bare user id), writes the tenant-context user attributes, sends the same execute-actions mail the first admin gets, and audits `user.invited` with the caller as actor. Idempotent: an existing member answers `200 {status:"member"}` and sends no mail; a new one `202 {status:"invited"}`.

**Scope.** A user token may only touch its own tenant — another tenant's id is a 404, never a hint that it exists. Inviting needs the `IT_ADMIN` or `OWNER` org role, so `Principal` now carries the `org_roles` claim and `IsTenantAdmin()`. Service clients stay gated by `AUTHZ_RULES` route groups: members on `tenants.read`, invites on `tenants.write`.

**`admin_email` on the tenant** (migration `0006`, backfilled from the `keycloak.invite_sent` audit trail, and from `keycloak.provision_failed` metadata where the first invite failed) so Settings can show a real contact instead of an em dash. The first `IT_ADMIN`/`OWNER` invite fills it in when it was empty.

**Routing note worth keeping:** `GET /v1/tenants/{id}/members` cannot be registered — Go's ServeMux calls it a conflict with `GET /v1/tenants/by-slug/{slug}`, since both match `/v1/tenants/by-slug/members` and neither pattern is more specific. It is registered as `GET /v1/tenants/{id}/{sub}` instead, which *is* less specific than the by-slug lookup, so the two coexist; anything but `members` answers 404.

`openapi.yaml` documents both endpoints, the `OrgMember`/`Invite` schemas, `admin_email` and a `Forbidden` response.

Verified locally: `go vet ./...`, `gofmt` clean, `go test ./...` green, CI coverage command at **74.3%** (gate 70%).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: #28
2026-09-14 08:27:12 +00:00
sharang 8f5c9ba0b9 fix(keycloak): KC 26 org member body is the bare user id; set org tenant_id (#27)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 21m54s
ci / image (push) Successful in 22s
2026-09-12 09:39:27 +00:00
sharang 8388e47742 feat(provision): service token on product lifecycle calls; stage/prod provision URLs (#26)
ci / shared (push) Successful in 15s
ci / test (push) Successful in 22m4s
ci / image (push) Successful in 24s
2026-09-12 09:27:40 +00:00
sharang 2ea49be29d feat(m-mig-5): products table, entitlement check, tenant ladder, per-client authz (#23)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 21m58s
ci / image (push) Successful in 56s
2026-09-12 07:38:47 +00:00
sharang 80565fdbf2 fix(keycloak): org create must send a domain (KC 26 rejects domainless) (#20)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 21m24s
ci / image (push) Successful in 17s
2026-09-01 09:18:15 +00:00
sharang 84516e9b4f feat(keycloak): organizations become the membership authority source (#19)
ci / shared (push) Successful in 11s
ci / test (push) Successful in 21m22s
ci / image (push) Successful in 19s
2026-09-01 09:03:23 +00:00
sharangandSharang Parnerkar ce75ed04c2 RBAC Phase 1: membership authority endpoint + fail-closed API auth (#14)
ci / shared (push) Failing after 14s
ci / test (push) Successful in 21m13s
ci / image (push) Skipped
Implements the model-B2 membership authority (ratified compliance auth design) and inbound token verification.

- GET /v1/users/{id}/memberships: Keycloak supplies user->tenant links + org_roles (attribute projection until the realm migrates to Organizations); registered tenants override status/plan/products from registry tables (source: registry|keycloak). Closes the M5.2-deferred org_roles stub.
- New internal/authn: OIDC discovery + JWKS verification (go-oidc/v3), audience tenant-registry. /healthz + /readyz stay PUBLIC_EXPLICIT; all other routes INTERNAL_SERVICE_ONLY. AUTH_ENABLED=true refuses to start on incomplete config (fail-closed); false (dev default) keeps current behavior.
- Full suite green incl. postgres testcontainers; openapi.yaml updated (contract test passes).

Activation is a separate step (Auth-5): requires the orca-infra env merge and a portal service token (portal currently calls with no auth).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: #14
2026-08-24 18:21:46 +00:00
sharang 9138731eea feat(keycloak): M4.3 — Admin API adapter + claim resolver
ci / shared (push) Successful in 5s
ci / test (push) Successful in 1m32s
ci / image (push) Has been skipped
internal/keycloak Adapter (HTTPAdapter + Mock). POST /v1/tenants now provisions a KC organization + IT_ADMIN invite when admin_email is set; KC failures emit keycloak.provision_failed but don't roll back. POST /v1/internal/keycloak/claims resolves the current claim bundle for any (tenant_id|tenant_slug|user_attrs.*) lookup. Mock used in tests + when KEYCLOAK_ADMIN_URL is empty. HTTPAdapter tested against an in-process stub KC (httptest.Server).

Refs: M4.3
2026-05-19 11:51:09 +00:00