Skip to content

Commit 0647152

Browse files
committed
fix: fix tests and expectations
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 09bc0f4 commit 0647152

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

core/http/app_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,10 @@ var _ = Describe("API test", func() {
428428
"X-Forwarded-Prefix": {"/myprefix/"},
429429
})
430430
Expect(err).To(BeNil(), "error")
431-
Expect(sc).To(Equal(401), "status code")
431+
Expect(sc).To(Equal(200), "status code")
432+
// Non-API paths pass through to the React SPA (which handles login client-side)
432433
Expect(string(body)).To(ContainSubstring(`<base href="https://example.org/myprefix/" />`), "body")
434+
Expect(string(body)).To(ContainSubstring(`<div id="root">`), "should serve React SPA")
433435
})
434436

435437
It("Should support reverse-proxy when authenticated", func() {

core/http/auth/middleware.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,8 @@ func Middleware(db *gorm.DB, appConfig *config.ApplicationConfig) echo.Middlewar
8585

8686
// 5. Require auth for API paths
8787
if isAPIPath(path) {
88-
return authError(c, appConfig)
89-
}
90-
91-
// 6. Pass through for non-API paths when auth is DB-based
92-
// (the React UI will redirect to login as needed)
93-
if authEnabled && !hasLegacyKeys {
94-
return next(c)
95-
}
96-
97-
// 7. Legacy behavior: if API keys are set, all paths require auth
98-
if hasLegacyKeys {
99-
// Check GET exemptions
100-
if appConfig.DisableApiKeyRequirementForHttpGet && c.Request().Method == http.MethodGet {
88+
// Check GET exemptions for legacy keys
89+
if hasLegacyKeys && appConfig.DisableApiKeyRequirementForHttpGet && c.Request().Method == http.MethodGet {
10190
for _, rx := range appConfig.HttpGetExemptedEndpoints {
10291
if rx.MatchString(c.Path()) {
10392
return next(c)
@@ -107,6 +96,8 @@ func Middleware(db *gorm.DB, appConfig *config.ApplicationConfig) echo.Middlewar
10796
return authError(c, appConfig)
10897
}
10998

99+
// 6. Non-API paths (UI, static assets) pass through.
100+
// The React UI handles login redirects client-side.
110101
return next(c)
111102
}
112103
}

0 commit comments

Comments
 (0)