Skip to content

Commit 4c741a5

Browse files
committed
fix: use 401 errors instead of 403 for nginx responses
1 parent def539a commit 4c741a5

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

internal/controller/proxy_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ func (controller *ProxyController) proxyHandler(c *gin.Context) {
190190

191191
if !controller.useBrowserResponse(proxyCtx) {
192192
c.Header("x-tinyauth-location", redirectURL)
193-
c.JSON(403, gin.H{
194-
"status": 403,
195-
"message": "Forbidden",
193+
c.JSON(401, gin.H{
194+
"status": 401,
195+
"message": "Unauthorized",
196196
})
197197
return
198198
}
@@ -234,9 +234,9 @@ func (controller *ProxyController) proxyHandler(c *gin.Context) {
234234

235235
if !controller.useBrowserResponse(proxyCtx) {
236236
c.Header("x-tinyauth-location", redirectURL)
237-
c.JSON(403, gin.H{
238-
"status": 403,
239-
"message": "Forbidden",
237+
c.JSON(401, gin.H{
238+
"status": 401,
239+
"message": "Unauthorized",
240240
})
241241
return
242242
}

internal/controller/proxy_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func TestProxyController(t *testing.T) {
371371
req.Header.Set("x-forwarded-proto", "https")
372372
req.Header.Set("x-forwarded-uri", "/")
373373
router.ServeHTTP(recorder, req)
374-
assert.Equal(t, 403, recorder.Code)
374+
assert.Equal(t, 401, recorder.Code)
375375
assert.Equal(t, "", recorder.Header().Get("remote-user"))
376376
assert.Equal(t, "", recorder.Header().Get("remote-name"))
377377
assert.Equal(t, "", recorder.Header().Get("remote-email"))

internal/controller/resources_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (controller *ResourcesController) resourcesHandler(c *gin.Context) {
3232
if controller.config.Resources.Path == "" {
3333
c.JSON(404, gin.H{
3434
"status": 404,
35-
"message": "Resources not found",
35+
"message": "Resource not found",
3636
})
3737
return
3838
}

0 commit comments

Comments
 (0)