diff --git a/pkg/internal/auth/http.go b/pkg/internal/auth/http.go index 1e419ee..24d4334 100644 --- a/pkg/internal/auth/http.go +++ b/pkg/internal/auth/http.go @@ -6,6 +6,10 @@ import ( func ContextMiddleware(c *fiber.Ctx) error { atk := tokenExtract(c) + if len(atk) == 0 { + return c.Next() + } + c.Locals("nex_in_token", atk) if claims, err := tokenRead(atk); err == nil && claims != nil { diff --git a/pkg/internal/http/api/index.go b/pkg/internal/http/api/index.go index 2e0532d..c7aedda 100644 --- a/pkg/internal/http/api/index.go +++ b/pkg/internal/http/api/index.go @@ -8,8 +8,6 @@ import ( ) func MapAPIs(app *fiber.App) { - app.Use(auth.ContextMiddleware) - // Some built-in public-accessible APIs wellKnown := app.Group("/.well-known").Name("Well Known") { diff --git a/pkg/internal/http/server.go b/pkg/internal/http/server.go index 6a76101..4aaf9fe 100644 --- a/pkg/internal/http/server.go +++ b/pkg/internal/http/server.go @@ -1,6 +1,7 @@ package server import ( + "git.solsynth.dev/hypernet/nexus/pkg/internal/auth" "git.solsynth.dev/hypernet/nexus/pkg/internal/http/api" "github.com/goccy/go-json" "github.com/gofiber/fiber/v2" @@ -42,6 +43,8 @@ func NewServer() *HTTPApp { Output: log.Logger, })) + app.Use(auth.ContextMiddleware) + api.MapAPIs(app) return &HTTPApp{app}