From 82729a279b9c94412d2afb82b1d50409c10d01a5 Mon Sep 17 00:00:00 2001 From: Hemang Kandwal Date: Mon, 10 Feb 2025 22:58:16 +0530 Subject: [PATCH] feat(core): add introspection of query to work in development mode --- core/src/auth/auth.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/src/auth/auth.go b/core/src/auth/auth.go index 6c13897f..9be541aa 100644 --- a/core/src/auth/auth.go +++ b/core/src/auth/auth.go @@ -32,6 +32,27 @@ func GetCredentials(ctx context.Context) *engine.Credentials { } func isPublicRoute(r *http.Request) bool { + if env.IsDevelopment { + body, err := io.ReadAll(r.Body) + if err != nil { + return false + } + + r.Body = io.NopCloser(bytes.NewReader(body)) + if r.Method != http.MethodPost { + return false + } + + var query map[string]interface{} + if err := json.Unmarshal(body, &query); err != nil { + return false + } + + if q, ok := query["query"].(string); ok && strings.Contains(q, "IntrospectionQuery") { + return true + } + } + return (!strings.HasPrefix(r.URL.Path, "/api/") && r.URL.Path != "/api") }