Skip to content

Commit

Permalink
feat(core): add introspection of query to work in development mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hkdeman committed Feb 10, 2025
1 parent 8d181fd commit 82729a2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions core/src/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 82729a2

Please sign in to comment.