From 669a6eaf6d917022aadb3e532c5c4d46e6be7703 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 12 Feb 2024 00:43:04 -0500 Subject: [PATCH] fix: need to cast appId as string,then parse to int --- api/middleware.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api/middleware.go b/api/middleware.go index a6dea66..f449847 100644 --- a/api/middleware.go +++ b/api/middleware.go @@ -87,14 +87,20 @@ func githubRestVerifyMiddleware(db *gorm.DB) mux.MiddlewareFunc { return } - appId, ok := claims["iss"].(uint) + appId, ok := claims["iss"].(string) if !ok { http.Error(w, "Invalid JWT", http.StatusUnauthorized) return } + appIdInt, err := strconv.Atoi(appId) + if err != nil { + http.Error(w, "Invalid JWT", http.StatusUnauthorized) + return + } + appRecord := &model.Apps{} - appRecord.ID = appId + appRecord.ID = uint(appIdInt) if err := db.First(appRecord).Error; err != nil { http.Error(w, "Invalid JWT", http.StatusUnauthorized) @@ -139,7 +145,7 @@ func githubRestVerifyMiddleware(db *gorm.DB) mux.MiddlewareFunc { return } - if appId != uint(installIdInt) { + if appIdInt != installIdInt { http.Error(w, "Invalid Install", http.StatusUnauthorized) return }