fix(api-keys): enforce scope from request context after attach

Use c.Request.Context() in authenticateAPIKeyRequest so scoped keys are
actually restricted, update dto tests for removed tenant.api_key, and add
a regression test for the attach-context contract.
This commit is contained in:
wizardchen
2026-07-06 10:58:22 +08:00
committed by lyingbug
parent 94d18ea15a
commit c65ffa3d9c
4 changed files with 44 additions and 8 deletions
+1 -1
View File
@@ -260,7 +260,7 @@ func authenticateAPIKeyRequest(
if c.IsAborted() {
return false
}
if err := authorizeTenantAPIKeyAccess(ctx, c.Request.Method, c.Request.URL.Path); err != nil {
if err := authorizeTenantAPIKeyAccess(c.Request.Context(), c.Request.Method, c.Request.URL.Path); err != nil {
c.JSON(http.StatusForbidden, gin.H{"error": "Forbidden: API key scope does not allow this operation"})
c.Abort()
return false