This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Interactive Auth: Return 401 from for incorrect password #1160
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Much as I don't want to go further down this refactoring rabbit hole, it would be nice to move this up one more layer so this function returned None or raise a sane error, and contain the 403 code to
validate_password_login
which is used for login and login only. wdyt?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 did try that. The thing is that, whatever error code
_check_password_auth
puts in its exception,check_auth
is going to throw it away and turn it into a 401. So I'm not sure that's any clearer.I started wondering what the point of
LoginError
actually is, and why it's different toSynapseError
, and why it lets you set the http code rather than leaving that to a higher layer, and then I decided to stop thinking about 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.
Yeah, the fact that
check_auth
will clobber it with a 401 anyway is why I thought it might be clearer to use an exception without a specific code, so it's then catching an specific exception and turning it into one the upper layer understands, rather than catching the 403 exception and replacing the code. If you see it throwing the 403 error, it's surprising when that's re-caught, but less surprising if it's, say,AuthCheckException
. I don't really hugely bothered though, either way this is an improvement over what was there before.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.
OK, I see the problem: the different auth checkers all throw LoginError, so you'd have to change all of them. Yeah, ok - it's not worth it.