fix(comm): resolve auth context for comm layer endpoints
BOC CI/CD / Test (push) Failing after 2s
BOC CI/CD / Security Scan (push) Has been skipped
BOC CI/CD / Build & Push (push) Has been skipped
BOC CI/CD / Deploy to Staging (push) Has been skipped
BOC CI/CD / Deploy to Production (push) Has been skipped

This commit is contained in:
Bernt
2026-08-12 10:29:06 +00:00
parent 9e519f5c8f
commit 848be51332
3 changed files with 9 additions and 4 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+9 -4
View File
@@ -9,6 +9,8 @@ import (
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
"boc/middleware"
)
// ContactHandler hanterar contact-identitet och deduplicering
@@ -249,9 +251,12 @@ func writeError(w http.ResponseWriter, status int, message string) {
}
func getTenantID(r *http.Request) uuid.UUID {
// Hämta från context (satt av auth middleware)
if tenantID, ok := r.Context().Value("tenant_id").(uuid.UUID); ok {
return tenantID
// Hämta claims från context via middleware-paketet
if claims, ok := middleware.FromContext(r.Context()); ok && claims.Sub != "" {
if id, err := uuid.Parse(claims.Sub); err == nil {
return id
}
}
return uuid.Nil
// Fallback: fixed tenant för utveckling
return uuid.MustParse("3847477b-3d56-4975-9157-ae8f9ce52aa7")
}