MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / Authenticated

Function Authenticated

api/pkg/middlewares/authenticated_middlesare.go:21–36  ·  view source on GitHub ↗

Authenticated checks if the request is authenticated

(tracer telemetry.Tracer)

Source from the content-addressed store, hash-verified

19
20// Authenticated checks if the request is authenticated
21func Authenticated(tracer telemetry.Tracer) fiber.Handler {
22 return func(c fiber.Ctx) error {
23 _, span := tracer.StartFromFiberCtx(c, "middlewares.Authenticated")
24 defer span.End()
25
26 if tokenUser, ok := c.Locals(ContextKeyAuthUserID).(entities.AuthContext); !ok || tokenUser.IsNoop() {
27 return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
28 "status": "error",
29 "message": "You are not authorized to carry out this request.",
30 "data": "Make sure your API key is set in the [x-api-key] header in the request",
31 })
32 }
33
34 return c.Next()
35 }
36}

Callers

nothing calls this directly

Calls 2

IsNoopMethod · 0.80
StartFromFiberCtxMethod · 0.65

Tested by

no test coverage detected