Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: validate access token (#1867)

CorrectRoadHc9aa2eeb9852
diff --git a/server/jwt.go b/server/jwt.go
index 4f6a31aa2..2cb9af448 100644
--- a/server/jwt.go
+++ b/server/jwt.go
@@ -111,6 +111,11 @@ func JWTMiddleware(server *Server, next echo.HandlerFunc, secret string) echo.Ha
}
return nil, errors.Errorf("unexpected access token kid=%v", t.Header["kid"])
})
+
+ if !accessToken.Valid {
+ return echo.NewHTTPError(http.StatusUnauthorized, "Invalid access token.")
+ }
+
if !audienceContains(claims.Audience, auth.AccessTokenAudienceName) {
return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Invalid access token, audience mismatch, got %q, expected %q.", claims.Audience, auth.AccessTokenAudienceName))
}