From 928a2a514c5eef00d3c1c618f0c68587aa479c6e Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Tue, 10 Sep 2024 10:27:48 -0700 Subject: [PATCH] checkpoint Signed-off-by: Jeff Ortel --- api/service.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/api/service.go b/api/service.go index fff14977..811d3aca 100644 --- a/api/service.go +++ b/api/service.go @@ -29,7 +29,7 @@ type ServiceHandler struct { // AddRoutes adds routes. func (h ServiceHandler) AddRoutes(e *gin.Engine) { e.GET(ServicesRoot, h.List) - e.Any(ServiceRoot, h.Forward) + e.Any(ServiceRoot, h.Required, h.Forward) } // List godoc @@ -49,14 +49,15 @@ func (h ServiceHandler) List(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, r) } +// Required enforces RBAC. +func (h ServiceHandler) Required(ctx *gin.Context) { + Required(ctx.Param(Name)) +} + // Forward provides RBAC and forwards request to the service. func (h ServiceHandler) Forward(ctx *gin.Context) { path := ctx.Param(Wildcard) name := ctx.Param(Name) - Required(name) - if len(ctx.Errors) > 0 { - return - } route, found := serviceRoutes[name] if !found { err := &NotFound{Resource: name}