mirror of
https://github.com/DeBrosOfficial/network.git
synced 2026-01-30 00:13:03 +00:00
Fixed issue on wallet handler
This commit is contained in:
parent
b0bc0a232e
commit
acc38d584a
2
Makefile
2
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)'
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user