feat(api-keys): implement DenyAPIKeyPrincipal middleware and related tests
Add DenyAPIKeyPrincipal middleware to explicitly block API-key principals from accessing certain routes, ensuring security for endpoints outside the /api/v1 group. Introduce tests to validate that API keys are correctly denied access while allowing JWT sessions to pass through. This enhances the overall authorization model by reinforcing the default-deny approach for API keys.
This commit is contained in:
@@ -1668,7 +1668,12 @@ func servePresignedPreview(r *gin.Engine, cfg *config.Config) {
|
||||
}
|
||||
absDir, _ := filepath.Abs(baseDir)
|
||||
|
||||
// This route is registered on the engine root, NOT the /api/v1 group,
|
||||
// so the APIKeyGate never runs for it. RequireRole short-circuits
|
||||
// API-key principals (deferring to that absent gate), which would let
|
||||
// any valid key past the Admin check. Deny API keys explicitly first.
|
||||
r.GET("/api/v1/files/presigned-preview",
|
||||
middleware.DenyAPIKeyPrincipal(),
|
||||
middleware.RequireRole(types.TenantRoleAdmin, cfg),
|
||||
func(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
Reference in New Issue
Block a user