Repository navigation
Conversation
… rewire the router Team servers now validate access tokens issued by the identity provider (signature, iss, aud, exp) and provision users from token claims: the first request with a new token resolves (iss, sub) to a user and reconciles groups and the admin role from the groups claim, cached per token for at most 5 minutes and failing closed. auth.type is now 'oidc' (default) or 'none' (no authentication, implicit admin). Adds the in-process OIDC provider (internal/auth/authtest) used by tests. Removes the old server-side OIDC login/callback and RFC 8628 device token exchange handlers: nebi no longer runs the login redirect itself, clients talk to the IdP directly. GET /api/v1/auth/config now advertises issuer/client id/scopes so clients can configure themselves. Intermediate state (cleaned up in the following commits): - basic.go, proxy.go, authcode.go and the reconciliation monitor still exist but are no longer wired into the router (dead code). - auth.go keeps LoginRequest/LoginResponse/ErrInvalidCredentials and UserContextKey (defined in basic.go) so the dead code still compiles. - The web UI still posts to the removed /auth/login endpoint; frontend login is broken until the OIDC RP frontend commit lands. - Some legacy tests were retargeted or dropped where they exercised replaced internals; they are deleted with the code anyway.
…reconciliation monitor Deletes the legacy authentication machinery that the OIDC resource server replaced: BasicAuthenticator (username/password login, nebi-signed JWTs, ADMIN_USERNAME bootstrap), the gateway IdToken cookie flow (proxy.go), the single-use auth-code store, and the authorization reconciliation status monitor with its stale-token enforcement and retry loop. auth.go loses LoginRequest/LoginResponse/ErrInvalidCredentials; UserContextKey moves to auth.go. Intermediate state: - users.password_hash is no longer written; the column drop and the CLI-side store migration (password_hash removal, refresh-token credential fields) land with the user-management commits. - The federated identity review queue still exists but nothing creates reviews anymore; it is removed next. - db.go keeps migrating the now-unused review table until its own removal commit.
…he backend nebi no longer creates, deletes or promotes users. Admins get a read-only view: users and their groups are provisioned from identity provider tokens, so user CRUD, toggle-admin, the ADMIN bootstrap helpers and the whole review-queue surface (list/approve/reject/discard) are gone, along with the CLI client methods and the desktop remote proxies for them. Intermediate state: - admin-managed groups still exist; their removal and the full schema migration (drop users.password_hash, groups.source/description, the review and reconciliation tables) land with the groups chunk. - the admin frontend still renders user/review screens against the now removed endpoints until the frontend chunk lands.
…a migration Groups are now identity-provider groups only, synced from the groups claim of access tokens. Drops the group CRUD and membership-management service, handlers and RBAC surface (group admin grants, bulk policy removal), the groups.source/description columns, and the audit actions that tracked nebi-managed users and groups. db.Migrate now runs the complete one-way migration: delete native groups with their memberships, grants and casbin policies, drop users.password_hash and the groups columns, and drop the federated identity review and auth reconciliation tables. This is the destructive step of the upgrade; it is idempotent.
nebi login now runs the RFC 8628 device authorization grant with PKCE directly against the identity provider (internal/oidcclient); the CLI stores the provider's access and refresh tokens plus the token endpoint and client id in the local credentials store, and refreshes them automatically. The desktop app's connect-to-server flow uses the same path via POST /remote/connect and /remote/connect/poll, so no nebi- issued tokens or password-based CLI login remain. The router is now the final version. Intermediate state: the web UI still uses the old login page until the frontend chunk lands.
…oup screens Login is now authorization code + PKCE against the identity provider via oidc-client-ts: the SPA redirects to the IdP, handles the callback at /auth/callback, renews with the refresh token and performs RP-initiated logout. Server config (issuer, client id, scopes) is read from GET /api/v1/auth/config, so the UI configures itself per deployment. Tests run against an in-test fake OIDC client (test/fakeOidc.ts). Removes the password login form, the user management and create-user screens, the federated identity review queue UI, group creation and the group admin grant controls; admin group views are read-only over identity-provider groups.
…ples and swagger docker-compose.yml now brings up nebi behind Traefik together with Keycloak (realm auto-import with a preconfigured public client) and Postgres; docker/local.override.yml adapts it for a laptop, gen-local- certs.sh produces the local TLS material, and compose.env.example documents the variables. The old prod compose file and password/ADMIN bootstrap env vars are gone. Docs describe the OIDC-only setup, the device-flow CLI login and the new auth.type oidc|none options. Swagger is regenerated for the new API surface.
|
Docs preview for |
…p-chunks # Conflicts: # frontend/package-lock.json # frontend/package.json
…p-chunks # Conflicts: # app.go # docker-compose.prod.yml # docker-compose.yml
- oidcclient: guard the refreshing token source's cached access token with a mutex. Callers sharing one source (the desktop app serves parallel requests from it) raced on it and could persist a refreshed token twice. Add unit tests for the token source and the device-flow polling rules. - auth: bound every identity-provider call (discovery and JWKS fetches) with a 10s HTTP client. go-oidc otherwise uses http.DefaultClient, which has no timeout, and the first discovery attempt runs before the listener starts. - store: drop the users.password_hash column locally instead of importing internal/db, which pulled the Postgres driver into the CLI binary. Keep the data directory 0700 now that it holds a refresh token. - /version reports features.auth from the resolved auth type, so a team server with auth.type none no longer advertises authentication. - remote connect: read the device-flow poll interval under the lock. - Remove dead code from the replaced auth model (cliclient.IsOIDCRedirect, login/user audit constants, golang-jwt dependency) and update CONTRIBUTING.md, the components doc, and the frontend README, which still described password login and JWT sessions.
|
I ran this PR through an LLM code review (three parallel reviewers: architecture, Go auth/API/RBAC/DB, Go CLI/desktop/store/compose, plus a docs-drift pass; every finding was adversarially re-verified against the code at 5364010 before being accepted). Build, vet, Confirmed findings, all fixed in the follow-up commit I am pushing now:
Noted but left for follow-up issues rather than this PR: the Fly deploy workflow now expects |
tylerpotts
left a comment
There was a problem hiding this comment.
Added some comments on optionally replacing some hand-rolled code with calls to the oauth2 library. Otherwise PR seems good to go
| NEBI_AUTH_OIDC_ISSUER_URL issuer; must match the tokens' "iss" claim | ||
| NEBI_AUTH_OIDC_CLIENT_ID public client of the web UI, CLI and desktop app | ||
| NEBI_AUTH_OIDC_ADMIN_GROUPS identity-provider groups whose members are admins | ||
| NEBI_AUTH_OIDC_SCOPES scopes clients request (default openid,profile,email) |
There was a problem hiding this comment.
Why would we make this configurable if we never need anything else?
There was a problem hiding this comment.
We need it for providers other than Keycloak. Nebi depends on the groups claim for group sharing and admin assignment, and several providers only release that claim when the client requests a groups scope, for example Dex and Okta. With a hardcoded openid,profile,email, those deployments would silently get no groups and no admins.
I added that explanation to the server-setup docs and config.yaml.example in c0e8a8c. Leaving this open in case you still want it removed.
- oidcclient: delegate discovery to go-oidc and the device flow, PKCE and RFC 8628 polling to oauth2 (Config.DeviceAuth, DeviceAccessToken, S256ChallengeOption, VerifierOption) instead of hand-rolled requests. Reject device authorizations without expires_in, which bounds polling. - Desktop connect: wait for the device token in a background goroutine with oauth2's polling; /remote/connect/poll only reports the outcome. A new connect or a disconnect cancels the pending wait. - Rename auth.jwt_secret / NEBI_AUTH_JWT_SECRET to encryption_key / NEBI_ENCRYPTION_KEY: it only derives the registry-credential key now. - Drop the legacy database migration (password_hash, native groups, review tables) from the server and CLI store; upgrades are tracked in #589. Document that existing databases are not migrated yet. - Remove the one-time tests asserting that removed auth routes 404. - Document when to add a groups scope to auth.oidc_scopes. - Reword the docker/local.override.yml header.
This is just #598 split into multiple commits to make this more reviewable. All commits up until b77f570 where done by @tylerpotts and not by me.