Repository navigation
Conversation
hypeman-auth exchanges a workload's OIDC identity token for a short-lived access token that Hypeman servers verify with its public keys. It is a separate binary, so a Hypeman server holds no key that can issue a token. The token endpoint is the RFC 7523 JWT bearer grant, with the audience named as in RFC 8707. Tokens are signed with an ECDSA P-256 key in the RFC 9068 format hypeman-api accepts, and the keys are published through RFC 8414 metadata. A federation rule now names the audiences a token may be issued for, and optionally the identity token claim that names the caller. Single-use identity tokens are recorded by one insert in a PostgreSQL table shared by every instance, so several instances can run and a restart loses nothing.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 36e718f. Configure here.
SIGNING_KEY__PEM or SIGNING_KEY__FILE set one half of the signing_key block and left the other half from the file in place, so a file naming a key path and an environment giving the key text left both set and the server refused to start. Either variable now replaces the block. The image also names its non-root user, which the base image already ran as.
The table and its index were SQL strings in Go that ran at every start, with no record of what a database already had, so a later schema change would have needed its own if-not-exists logic. The schema is now numbered SQL files built into the binary. At start the store applies the ones the database has no record of, in one transaction behind the advisory lock that was already there, and records them in public.hypeman_auth_schema_migrations. A later change is a new file.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds
hypeman-auth, an OAuth authorization server that is a separate binary fromhypeman-api. A workload proves who it is with an OIDC identity token it already has, and receives a short-lived access token that Hypeman servers verify with the authorization server's public keys (#608). No Hypeman server holds a key that can issue one. This is the third layer after #607 and #608.curl https://auth.example.com/oauth/token \ --data-urlencode grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \ --data-urlencode assertion="$IDENTITY_TOKEN" \ --data-urlencode federation_rule_id=ci-nightly \ --data-urlencode resource=https://hypeman.example.cominvalid_grant;invalid_targetis returned only once the caller is known to be the rule's workload.hypeman-apiaccepts:audis one of the rule's audiences,scopeis the rule's permissions,client_idis the rule, and the lifetime is 300 seconds by default, at most 600, and never past the identity token's own expiry. A key'skidis its RFC 7638 thumbprint.published_keysfor rotation.authorization.audiences(required) andauthorization.subject_claim(optional: the identity token claim that names the caller, added to the token's subject).INSERT ... ON CONFLICT DO NOTHINGon the primary key of a PostgreSQL table shared by every instance, so several instances can run and a restart loses nothing. If the insert fails, nothing is issued.Operator documentation is in
docs/authorization-server.md. Design: https://gist.github.com/rgarcia/d01f8381a0d104a0dc3d9b523e14d3f4Layout
lib/authserver: the exchange, the HTTP handlers, key loading and the PostgreSQL store.cmd/auth: the binary, its configuration, and a Dockerfile.lib/oidcfederation: the two rule fields andRegistry.SingleUse.Worth a reviewer's attention
lib/authserver/migrations, built into the binary. At start the server applies the ones the database has no record of, in one transaction behind an advisory lock so that instances starting together take turns, and records them inpublic.hypeman_auth_schema_migrations. Its role therefore owns the tables and keepsCREATEon thepublicschema. A later schema change is a new file, and must leave the schema usable by the release before it.github.com/jackc/pgx/v5v5.9.0. No existing dependency changes version.Not in this PR
A workflow that publishes the image, release packaging, a signer backed by a key management service, signing long-lived tokens with
hypeman-token, and running Hypeman servers withoutjwt_secret.Testing
lib/accesstokenverifierhypeman-apiuses.TestPostgresStoreruns against a real PostgreSQL 17 whenHYPEMAN_AUTH_TEST_POSTGRES_URLis set, in a database it creates and drops: concurrent first starts, concurrent spends, cleanup, a later migration applied once, and a failing migration that changes nothing. It is skipped in CI, which has no database. The concurrent-start case fails every run without the advisory lock.go test -racepasses for./cmd/auth/... ./lib/authserver/ ./lib/oidcfederation/ ./lib/accesstoken/... ./lib/jwtauth/ ./lib/middleware/.gofmtandgo vetare clean.resourcein the URL, and served the metadata, key set and metrics. The Docker image builds and starts.make testwas not run locally; CI is its first run.Reviewed with sol-loop: 4 rounds with openai-codex/gpt-6.2-sol on extra-high reasoning. Sol verdict: approved. Two commits came after that review: a signing key from the environment now replaces the file's instead of being added to it and the image names its non-root user; and the store's schema moved from statements in Go to migration files.