From 4d1831296ccee45a9445ae29e8c0e4c685e17cc2 Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Sat, 25 Jan 2025 15:39:14 -0500 Subject: [PATCH] fixup claims --- lib/handler/middleware.go | 2 +- lib/handler/registration_token.go | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/handler/middleware.go b/lib/handler/middleware.go index dd5112b..ed6aed7 100644 --- a/lib/handler/middleware.go +++ b/lib/handler/middleware.go @@ -15,7 +15,7 @@ import ( type contextKey string -const claimsKey contextKey = "claims" +const claimsKey contextKey = "githubClaims" const githubKeysURL = "https://token.actions.githubusercontent.com/.well-known/jwks" diff --git a/lib/handler/registration_token.go b/lib/handler/registration_token.go index 8bbc4eb..b490bda 100644 --- a/lib/handler/registration_token.go +++ b/lib/handler/registration_token.go @@ -9,11 +9,7 @@ import ( ) func (h *Handler) RepoAdminToken(w http.ResponseWriter, r *http.Request) { - claims, ok := r.Context().Value(claimsKey).(GitHubClaims) - if !ok { - http.Error(w, "Unauthorized: missing claims in context", http.StatusUnauthorized) - return - } + claims := r.Context().Value(claimsKey).(GitHubClaims) if claims.Repository == "" { http.Error(w, "Invalid request: repository claim is empty", http.StatusBadRequest) return