Fixed issue on wallet handler

This commit is contained in:
anonpenguin23 2026-01-20 10:12:33 +02:00
parent b0bc0a232e
commit acc38d584a
4 changed files with 10 additions and 13 deletions

View File

@ -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 .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) COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'

View File

@ -8,18 +8,15 @@ import (
"database/sql" "database/sql"
authsvc "github.com/DeBrosOfficial/network/pkg/gateway/auth" authsvc "github.com/DeBrosOfficial/network/pkg/gateway/auth"
"github.com/DeBrosOfficial/network/pkg/gateway/ctxkeys"
"github.com/DeBrosOfficial/network/pkg/logging" "github.com/DeBrosOfficial/network/pkg/logging"
) )
// contextKey is the type for context keys // Use shared context keys from ctxkeys package to ensure consistency with middleware
type contextKey string
// Context keys for request-scoped auth metadata
// These are exported so they can be used by the gateway middleware
const ( const (
CtxKeyAPIKey contextKey = "api_key" CtxKeyAPIKey = ctxkeys.APIKey
CtxKeyJWT contextKey = "jwt_claims" CtxKeyJWT = ctxkeys.JWT
CtxKeyNamespaceOverride contextKey = "namespace_override" CtxKeyNamespaceOverride = ctxkeys.NamespaceOverride
) )
// NetworkClient defines the minimal network client interface needed by auth handlers // NetworkClient defines the minimal network client interface needed by auth handlers

View File

@ -139,7 +139,7 @@ func (h *Handlers) LogoutHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context() ctx := r.Context()
var subject string var subject string
if req.All { 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 { if claims, ok := v.(*authsvc.JWTClaims); ok && claims != nil {
subject = strings.TrimSpace(claims.Sub) subject = strings.TrimSpace(claims.Sub)
} }

View File

@ -19,14 +19,14 @@ func (h *Handlers) WhoamiHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context() ctx := r.Context()
// Determine namespace (may be overridden by auth layer) // Determine namespace (may be overridden by auth layer)
ns := h.defaultNS 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 != "" { if s, ok := v.(string); ok && s != "" {
ns = s ns = s
} }
} }
// Prefer JWT if present // 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 { if claims, ok := v.(*authsvc.JWTClaims); ok && claims != nil {
writeJSON(w, http.StatusOK, map[string]any{ writeJSON(w, http.StatusOK, map[string]any{
"authenticated": true, "authenticated": true,
@ -45,7 +45,7 @@ func (h *Handlers) WhoamiHandler(w http.ResponseWriter, r *http.Request) {
// Fallback: API key identity // Fallback: API key identity
var key string var key string
if v := ctx.Value(contextKey(CtxKeyAPIKey)); v != nil { if v := ctx.Value(CtxKeyAPIKey); v != nil {
if s, ok := v.(string); ok { if s, ok := v.(string); ok {
key = s key = s
} }