Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions auth/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (auth *AuthClient) Authorize(sub, resource, action string) fiber.Handler {

span.End()

return c.Status(http.StatusInternalServerError).SendString("Internal Server Error")
return c.Status(statusCode).SendString(http.StatusText(statusCode))
} else if authorized {
span.End()

Expand Down Expand Up @@ -232,7 +232,7 @@ func (auth *AuthClient) checkAuthorization(ctx context.Context, sub, resource, a

opentelemetry.HandleSpanError(span, "Failed to parse token", err)

return false, http.StatusInternalServerError, err
return false, http.StatusUnauthorized, err
}

claims, ok := token.Claims.(jwt.MapClaims)
Expand All @@ -243,7 +243,7 @@ func (auth *AuthClient) checkAuthorization(ctx context.Context, sub, resource, a

opentelemetry.HandleSpanError(span, "Failed to parse claims", err)

return false, http.StatusInternalServerError, err
return false, http.StatusUnauthorized, err
}

userType, _ := claims["type"].(string)
Expand Down
2 changes: 1 addition & 1 deletion auth/middleware/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func TestCheckAuthorization_InvalidToken(t *testing.T) {

require.Error(t, err)
assert.False(t, authorized)
assert.Equal(t, http.StatusInternalServerError, statusCode)
assert.Equal(t, http.StatusUnauthorized, statusCode)
}

func TestCheckAuthorization_EmptyTypeClaim_TreatedAsNonNormalUser(t *testing.T) {
Expand Down
Loading