-
Notifications
You must be signed in to change notification settings - Fork 307
Change HTTPBasicAuthenticator log message from warning to trace for 'No basic auth' error #5221
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
base: main
Are you sure you want to change the base?
Change HTTPBasicAuthenticator log message from warning to trace for 'No basic auth' error #5221
Conversation
Signed-off-by: Stewart Brown <[email protected]>
if (!authorizationHeader.trim().toLowerCase().startsWith("basic ")) { | ||
log.warn("No 'Basic Authorization' header, send 401 and 'WWW-Authenticate Basic'"); | ||
if (!authorizationHeader.trim().toLowerCase().startsWith("basic ") && isTraceEnabled) { | ||
log.trace("No 'Basic Authorization' header, send 401 and 'WWW-Authenticate Basic'"); |
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.
Thanks for the PR. While I understand noise created when multiple auth types are used, moving this line to trace logging might be an issue for clusters with only basic auth enabled. I don't think there's another log line available.
For #4054, would it be possible to change the order
, i.e. mark SAML as order 1 and basic auth as order 2? Do you still see same amount of logs?
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.
+1 to @shikharj05
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.
I also agree that changing to trace isn't the answer but the behavior should change for valid scenarios requiring multiple authenticators using fallthrough.
The fix required could be one of the following:
- Pass the isChallenge flag from the authDomain to the extractCredentials calls. Only log.warn when isChallenge is true
- Alternatively, and probably a more complete fix, would be be to pass the firstChallengingHttpAuthenticator to the extractCredentials calls. Only log.warn when the firstChallengingHttpAuthenticator is of type HTTPBasicAuthenticator
The starting point for these changes would be the httpAuthenticator.extractCredentials call at https://github.com/opensearch-project/security/blob/main/src/main/java/org/opensearch/security/auth/BackendRegistry.java#L282
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.
Thanks all! Initially raised this PR as i felt that it was odd that basic auth was the only authentication type logging a warn message on checking that the header was in the expected format- leaving this message-spam only occurring when basic auth was earlier in the order.
But i understand this is could be a helpful message, so banishing it away to Trace or Debug may not be useful (especially for a more common auth type like Basic). I agree with Terry that passing isChallenge may be the way forward in this case. Especially after reading the docs, which at the moment seems inconsistent with this logging message: https://opensearch.org/docs/latest/security/authentication-backends/basic-authc/#the-challenge-setting
Will look into this a little more later this week with a bit more of a complete fix!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5221 +/- ##
==========================================
- Coverage 72.04% 71.69% -0.36%
==========================================
Files 336 384 +48
Lines 22648 23862 +1214
Branches 3560 3635 +75
==========================================
+ Hits 16317 17107 +790
- Misses 4556 4931 +375
- Partials 1775 1824 +49
🚀 New features to boost your workflow:
|
…hallenge is true Signed-off-by: Stewart Brown <[email protected]>
Signed-off-by: Stewart Brown <[email protected]>
Have added in the isChallenge flag to extractCredentials as suggested! Log the error message as a warn if 'challenge' is enabled, and at trace level if 'trace' is enabled. Otherwise do not print the error which will hopefully reduce the log spam being seen when security configs are set up in this specific ordering. Sorry for delay, other things popped up over past few weeks! Still need to test this works as expected, and will have time to do so at the start of next week. |
Description
When basic auth and SAML authentications are both enabled, the logs are filled with messages stating:
"level": "WARN", "component": "o.o.s.h.HTTPBasicAuthenticator", "message": "No 'Basic Authorization' header, send 401 and 'WWW-Authenticate Basic'"
This was thought to be addressed by #3364, however the logging message remained in another area which this PR has tuned to trace level instead.
Issues Resolved
No 'Basic Authorization' header, send 401 and 'WWW-Authenticate Basic'
in log #3273Testing
Bulk Integration testing workflow with this change seems to look fine!
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.