Skip to content

Commit 8a54ffa

Browse files
authored
fix: do not require auth for readyz/healthz endpoints (#7403)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent e3bcba5 commit 8a54ffa

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

core/config/application_config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ type ApplicationConfig struct {
7272
DisableRuntimeSettings bool
7373

7474
AgentJobRetentionDays int // Default: 30 days
75+
76+
PathWithoutAuth []string
7577
}
7678

7779
type AppOption func(*ApplicationConfig)
@@ -82,6 +84,15 @@ func NewApplicationConfig(o ...AppOption) *ApplicationConfig {
8284
UploadLimitMB: 15,
8385
Debug: true,
8486
AgentJobRetentionDays: 30, // Default: 30 days
87+
PathWithoutAuth: []string{
88+
"/static/",
89+
"/generated-audio/",
90+
"/generated-images/",
91+
"/generated-videos/",
92+
"/favicon.svg",
93+
"/readyz",
94+
"/healthz",
95+
},
8596
}
8697
for _, oo := range o {
8798
oo(opt)

core/http/middleware/auth.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,10 @@ func getApiKeyRequiredFilterFunction(applicationConfig *config.ApplicationConfig
156156
return func(c echo.Context) bool {
157157
path := c.Request().URL.Path
158158

159-
// Always skip authentication for static files
160-
if strings.HasPrefix(path, "/static/") {
161-
return true
162-
}
163-
164-
// Always skip authentication for generated content
165-
if strings.HasPrefix(path, "/generated-audio/") ||
166-
strings.HasPrefix(path, "/generated-images/") ||
167-
strings.HasPrefix(path, "/generated-videos/") {
168-
return true
169-
}
170-
171-
// Skip authentication for favicon
172-
if path == "/favicon.svg" {
173-
return true
159+
for _, p := range applicationConfig.PathWithoutAuth {
160+
if strings.HasPrefix(path, p) {
161+
return true
162+
}
174163
}
175164

176165
// Handle GET request exemptions if enabled

0 commit comments

Comments
 (0)