-
Notifications
You must be signed in to change notification settings - Fork 7
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
Provide better error message when API authentication fails #5683
Conversation
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.
Changes look OK but I suspect the test failures in the BVTs are related.
@@ -1207,7 +1242,16 @@ private static void addDefaultUserLoginDelay(HttpServletRequest request, String | |||
return handleAuthentication(request, ContainerManager.getRoot()).getUser(); | |||
} | |||
|
|||
return null; | |||
// Basic auth has failed so send failure response in a format that APIs can consume | |||
// TODO: Shouldn't our client APIs set a default "respFormat" attribute? Java library doesn't... |
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 added respFormat
years ago for a niche use case that could only consume XML. I think it's fine to default to JSON and not bother explicitly requesting it.
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 was necessary to get ClientAPITest to pass, since it sets "respFormat" to XML in a few cases, and was unhappy with hard-coded JSON response. Happy to discuss and clean this up on develop or later 24.7.x... I don't love what feels like one-off handling here.
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.
Please hold off on merging until we have a decision on timing. See my question to the Release Management group in the chat.
Rationale
We want API clients to receive more helpful guidance when authentication fails. For example, password expired vs. password doesn't meet complexity requirements vs. bad credentials. https://www.labkey.org/home/Developer/issues/issues-details.view?issueId=50841
Changes
AuthenticationStatus
can now tailor error messages for web UI vs. API purposes. For example, returning a message to a piece of code that suggests checking the caps lock seems unhelpful.