diff --git a/Makefile b/Makefile index 05ffe5c..3067f9e 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test-e2e: .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill -VERSION := 0.82.0 +VERSION := 0.90.0 COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' diff --git a/pkg/gateway/handlers/auth/handlers.go b/pkg/gateway/handlers/auth/handlers.go index f6b948c..455f0be 100644 --- a/pkg/gateway/handlers/auth/handlers.go +++ b/pkg/gateway/handlers/auth/handlers.go @@ -8,18 +8,15 @@ import ( "database/sql" authsvc "github.com/DeBrosOfficial/network/pkg/gateway/auth" + "github.com/DeBrosOfficial/network/pkg/gateway/ctxkeys" "github.com/DeBrosOfficial/network/pkg/logging" ) -// contextKey is the type for context keys -type contextKey string - -// Context keys for request-scoped auth metadata -// These are exported so they can be used by the gateway middleware +// Use shared context keys from ctxkeys package to ensure consistency with middleware const ( - CtxKeyAPIKey contextKey = "api_key" - CtxKeyJWT contextKey = "jwt_claims" - CtxKeyNamespaceOverride contextKey = "namespace_override" + CtxKeyAPIKey = ctxkeys.APIKey + CtxKeyJWT = ctxkeys.JWT + CtxKeyNamespaceOverride = ctxkeys.NamespaceOverride ) // NetworkClient defines the minimal network client interface needed by auth handlers diff --git a/pkg/gateway/handlers/auth/jwt_handler.go b/pkg/gateway/handlers/auth/jwt_handler.go index dce7b0b..b52559b 100644 --- a/pkg/gateway/handlers/auth/jwt_handler.go +++ b/pkg/gateway/handlers/auth/jwt_handler.go @@ -139,7 +139,7 @@ func (h *Handlers) LogoutHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var subject string if req.All { - if v := ctx.Value(contextKey(CtxKeyJWT)); v != nil { + if v := ctx.Value(CtxKeyJWT); v != nil { if claims, ok := v.(*authsvc.JWTClaims); ok && claims != nil { subject = strings.TrimSpace(claims.Sub) } diff --git a/pkg/gateway/handlers/auth/wallet_handler.go b/pkg/gateway/handlers/auth/wallet_handler.go index 36ca55e..673cd1f 100644 --- a/pkg/gateway/handlers/auth/wallet_handler.go +++ b/pkg/gateway/handlers/auth/wallet_handler.go @@ -19,14 +19,14 @@ func (h *Handlers) WhoamiHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() // Determine namespace (may be overridden by auth layer) ns := h.defaultNS - if v := ctx.Value(contextKey(CtxKeyNamespaceOverride)); v != nil { + if v := ctx.Value(CtxKeyNamespaceOverride); v != nil { if s, ok := v.(string); ok && s != "" { ns = s } } // Prefer JWT if present - if v := ctx.Value(contextKey(CtxKeyJWT)); v != nil { + if v := ctx.Value(CtxKeyJWT); v != nil { if claims, ok := v.(*authsvc.JWTClaims); ok && claims != nil { writeJSON(w, http.StatusOK, map[string]any{ "authenticated": true, @@ -45,7 +45,7 @@ func (h *Handlers) WhoamiHandler(w http.ResponseWriter, r *http.Request) { // Fallback: API key identity var key string - if v := ctx.Value(contextKey(CtxKeyAPIKey)); v != nil { + if v := ctx.Value(CtxKeyAPIKey); v != nil { if s, ok := v.(string); ok { key = s }