feat(server): add GET /v1/me identity introspection endpoint#117
Merged
Conversation
Update the indirect dependency golang.org/x/crypto to v0.51.0 to pick up the latest security and bug fixes. go.sum updated accordingly.
Introduce a new scope-protected (`read`) route `GET /v1/me` that returns the resolved caller identity (`id` and `scopes`) from the auth middleware context. This replaces the need for HyperCache Monitor to use the legacy `/v1/owners/__probe__` hack for token introspection. Key changes: - Register `GET /v1/me` route in `registerClientRoutes` behind the `read` scope middleware - Add `handleMe` handler and `meResponse` wire type that reads `httpauth.Identity` from Fiber's `Locals` and serializes it to JSON; fails fast with a 500 if the middleware wiring is absent - In anonymous mode (`AllowAnonymous: true`), returns `id: anonymous` with all three scopes, mirroring the policy's internal identity - Document the new endpoint and `IdentityResponse` schema in `openapi.yaml` - Add `me_test.go` with unit tests covering body shape (read-only, read-write, anonymous) and the missing-Locals wiring-bug path - Extend `auth_test.go` and `openapi_test.go` to include `/v1/me` in the auth-coverage and drift-detection tables - Bump `golang.org/x/net` indirect dependency to v0.54.0
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.
Introduce a new scope-protected (
read) routeGET /v1/methatreturns the resolved caller identity (
idandscopes) from theauth middleware context. This replaces the need for HyperCache Monitor
to use the legacy
/v1/owners/__probe__hack for token introspection.Key changes:
GET /v1/meroute inregisterClientRoutesbehind thereadscope middlewarehandleMehandler andmeResponsewire type that readshttpauth.Identityfrom Fiber'sLocalsand serializes it to JSON;fails fast with a 500 if the middleware wiring is absent
AllowAnonymous: true), returnsid: "anonymous"with all three scopes, mirroring the policy's internal identity
IdentityResponseschema inopenapi.yamlme_test.gowith unit tests covering body shape (read-only,read-write, anonymous) and the missing-Locals wiring-bug path
auth_test.goandopenapi_test.goto include/v1/meinthe auth-coverage and drift-detection tables
golang.org/x/netindirect dependency to v0.54.0