labstack / echo

High performance, minimalist Go web framework
https://echo.labstack.com
MIT License
29.94k stars 2.23k forks source link

Refactor basic auth middleware to support multiple auth headers #2695

Open aldas opened 3 weeks ago

aldas commented 3 weeks ago

This is taken from v5 branch + improved tests

reasoning for it: multiple auth headers is something that can happen in environments like corporate test environments that are secured by application proxy servers where front facing proxy is configured to require own basic auth value + checks it and your application also requires basic auth headers from clients. As Go standard library stores headers in map and keys are retrieved in random order the middleware may need to check multiple headers to match correct one.

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 94.87179% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.09%. Comparing base (447c92d) to head (4ab78e4). Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
middleware/basic_auth.go 94.87% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2695 +/- ## ========================================== + Coverage 93.03% 93.09% +0.05% ========================================== Files 41 40 -1 Lines 4707 4762 +55 ========================================== + Hits 4379 4433 +54 - Misses 236 238 +2 + Partials 92 91 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.