Repository navigation
Conversation
Add GET /api/admin/auth/key, which returns the calling API key's id, name, project, organization and role. Every other management endpoint either names the project in its URL or is reserved for admins, so a caller holding only a key had no way to discover which project to address. The key learns only about itself, so no permission check is needed beyond authentication. Admins and other actors are refused with a 403. The role is read back from the auth method rather than the actor, which does not carry it; a key revoked since the auth cache was filled gets a 404. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
A caller that holds only an API key can't find out which project the key belongs to:
{projectID}in the URL.whoami,profile,projects, …) is admin-only and returns "this endpoint is only available to admins".401with no hint about the right one. That's on purpose and should stay.Right now the only way to get the project ID is to copy it out of the console URL.
What
A new endpoint,
GET /api/admin/auth/key, which returnsid,name,project_id,organization_idandrole.403.rbac.Actordoesn't carry it. The lookup is scoped to the key's own project. A key revoked after the auth cache was filled gets a404instead of stale data.Changes
resources.yml: new path plus aCurrentAPIKeyschemaresources_gen.goandconsole/src/oapi/management.generated.ts: regenerated (additive only)AuthMethodsController.GetCurrentAPIKeyand handler tests for: API key, admin refused, revoked keyTesting
go test ./internal/http/controllers/v1/management/ -run TestGetCurrentAPIKeyHandlerpasses against a real Postgres (testcontainers).