Skip to content
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

Merged

Conversation

nidhey27
Copy link
Contributor

@nidhey27 nidhey27 commented Nov 14, 2024

Issue

Closes: #996

Description:

  • Extracted parseBasicAuth to handle authorization header parsing
  • Added respondUnauthorized for consistent unauthorized responses
  • Moved credential validation logic to validateCredentials
  • Simplified main middleware function for improved readability and maintainability

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests.
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

@nidhey27 nidhey27 force-pushed the refactor/basic-auth-middleware branch from 03ec4c9 to b2d176c Compare November 14, 2024 07:55
@Umang01-hash
Copy link
Contributor

@nidhey27 your PR has some failing tests as well as code quality issues. Please resolve them

@nidhey27
Copy link
Contributor Author

nidhey27 commented Nov 14, 2024

@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.

@nidhey27 nidhey27 force-pushed the refactor/basic-auth-middleware branch from ffe2bcd to 7637fdf Compare November 14, 2024 12:26
@nidhey27
Copy link
Contributor Author

@Umang01-hash @vipul-rawat Were the recent changes you made intentional or accidental?

@Umang01-hash
Copy link
Contributor

@nidhey27 We haven't committed anything intentionally. I think you pulled from development and all our recent commits there got merged.

@Umang01-hash
Copy link
Contributor

@nidhey27 Please resolve the review comment given so that we can proceed ahead and merge your PR.

@nidhey27 nidhey27 force-pushed the refactor/basic-auth-middleware branch 2 times, most recently from fcb68ea to 74679cf Compare November 29, 2024 07:07
@Umang01-hash
Copy link
Contributor

Screenshot 2024-11-29 at 1 25 53 PM

@nidhey27 You still have one code quality issue in the PR. Please resolve this. Rest everything looks good.

Thankyou

@nidhey27 nidhey27 force-pushed the refactor/basic-auth-middleware branch from 74679cf to 7a7dd8a Compare November 29, 2024 08:15
@nidhey27 nidhey27 force-pushed the refactor/basic-auth-middleware branch from 7a7dd8a to a421c10 Compare December 2, 2024 09:54
@vipul-rawat vipul-rawat merged commit fba34dd into gofr-dev:development Dec 4, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor BasicAuthMiddleware
4 participants