fix(auth): preserve API-key user across RequireAuth re-dispatch#8913
Open
lrf-nitro wants to merge 4 commits into
Open
fix(auth): preserve API-key user across RequireAuth re-dispatch#8913lrf-nitro wants to merge 4 commits into
lrf-nitro wants to merge 4 commits into
Conversation
Open-API (/rest) requests authenticated with a valid API key were rejected with 401 "unauthorized" whenever AUTH_ENABLED is on (the default). The API-key middleware authenticates the request and sets common.USER via c.Set, then re-dispatches the rewritten path through router.HandleContext. gin's HandleContext calls Context.reset(), which sets c.Keys = nil and destroys the user, so the terminal RequireAuth gate sees no user and 401s. Carry the authenticated user on the request's context.Context, which survives HandleContext (only gin Keys are reset). GetUser now falls back to the request context when gin Keys are empty. This fixes every /rest endpoint (webhooks, push, etc.) at once without disabling auth. Add regression coverage: - shared: user set via SetUserOnRequest survives a HandleContext re-dispatch while gin Keys do not. - api: the full RestAuthentication -> OIDCAuthentication -> RequireAuth chain with AUTH_ENABLED=true returns 200 for a valid key, 401 for missing token, 403 for an invalid key, and 401 for a userless protected route.
* feat(gh-copilot): close API gaps for per-user metrics, teams, CLI, code review, and PR fields Add missing GitHub Copilot Metrics API fields to achieve full API parity: Enterprise/Org metrics: - CLI active user counts and CLI breakdown (sessions, requests, tokens) - Code review user counts (daily/weekly/monthly × active/passive) - Chat panel mode breakdown (agent/ask/custom/edit/plan/unknown) - Expanded PR metrics (merged, merge time, suggestions, Copilot impact) Per-user metrics: - used_cli, used_copilot_code_review_active/passive boolean flags - CLI breakdown per user (sessions, requests, tokens) User-team mapping (new): - New collector/extractor for user-teams-1-day endpoint - Enables team-level metrics via JOIN with per-user tables Seat assignments: - Team assignment fields (assigning_team id/name/slug) - User detail fields (name, email) Includes migration script 20260527 and comprehensive docs in COPILOT_METRICS_GAPS.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat(copilot-metrics): remove outdated metrics gaps documentation and implement new user-team mapping and metrics enhancements Signed-off-by: Jarek <jaroslaw.gajewski@atos.net> --------- Signed-off-by: Jarek <jaroslaw.gajewski@atos.net> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ion (apache#8907) (apache#8912) * refactor(plugin-circleci): extract unfinished-jobs input clauses into a helper Signed-off-by: Volodymyr Zahorniak <v.zahorniak@gmail.com> * fix(plugin-circleci): populate workflow id for unfinished-job collection (apache#8907) The collectJobs 'unfinished details' collector built its URL from '/v2/workflow/{{ .Input.Id }}/job' but its iterator selected 'DISTINCT workflow_id' into a models.CircleciJob, leaving .Id empty and producing '/v2/workflow//job' (HTTP 500) whenever a job was running/queued/on_hold. Alias the projection to 'workflow_id AS id' so .Id carries the workflow id, mirroring the new-records collector. Adds an e2e regression test. Signed-off-by: Volodymyr Zahorniak <v.zahorniak@gmail.com> --------- Signed-off-by: Volodymyr Zahorniak <v.zahorniak@gmail.com> Co-authored-by: Klesh Wong <klesh@qq.com>
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.
Open-API (/rest) requests authenticated with a valid API key were rejected with 401 "unauthorized" whenever AUTH_ENABLED is on (the default - unless explicitly disabled via env var). The API-key middleware authenticates the request and sets common.USER via c.Set, then re-dispatches the rewritten path through router.HandleContext. gin's HandleContext calls Context.reset(), which sets c.Keys = nil and destroys the user, so the terminal RequireAuth gate sees no user and 401s.
Carry the authenticated user on the request's context.Context, which survives HandleContext (only gin Keys are reset). GetUser now falls back to the request context when gin Keys are empty. This fixes every /rest endpoint (webhooks, push, etc.) at once without disabling auth.
Add regression coverage:
pr-type/bug-fix,pr-type/feature-development, etc.