-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue - 996 | Refactor BasicAuthMiddleware to reduce cognitive complexity #1203
base: development
Are you sure you want to change the base?
Issue - 996 | Refactor BasicAuthMiddleware to reduce cognitive complexity #1203
Conversation
Signed-off-by: nidhey27 <nidhey60@gmail.com>
03ec4c9
to
b2d176c
Compare
@nidhey27 your PR has some failing tests as well as code quality issues. Please resolve them |
@Umang01-hash sure I will have a look at it. Also a bit busy today with my day job so I will try to close this by coming weekend. |
Signed-off-by: nidhey27 <nidhey60@gmail.com>
ffe2bcd
to
7637fdf
Compare
middleware(handler).ServeHTTP(rr, req) | ||
|
||
assert.Equal(t, http.StatusUnauthorized, rr.Code) | ||
assert.Contains(t, rr.Body.String(), "Unauthorized: Authorization header missing") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test condition is failing as, on missing header the checks respond with - "Invalid or missing header"
use global map of channels to recieve messages to avoid recieving on a closed channel
@Umang01-hash @vipul-rawat Were the recent changes you made intentional or accidental? |
@nidhey27 We haven't committed anything intentionally. I think you pulled from development and all our recent commits there got merged. |
|
||
// respondUnauthorized sends a 401 Unauthorized response with a given message. | ||
func respondUnauthorized(w http.ResponseWriter, message string) { | ||
http.Error(w, "Unauthorized: "+message, http.StatusUnauthorized) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function with single line in its body may not be required.
Issue
Closes: #996
Description:
parseBasicAuth
to handle authorization header parsingrespondUnauthorized
for consistent unauthorized responsesvalidateCredentials
Checklist:
goimport
andgolangci-lint
.