Accept the /token login path used by existing clients - #239
Merged
Conversation
Login was exposed only at POST /user/login with a JSON body, but existing clients — notably already-installed ndp-ep versions — post form-encoded username and password to POST /token. Against an Endpoint those requests returned a 404, so those users could not log in until they upgraded. Add a /token route that accepts form-encoded credentials and returns the same result as /user/login, by delegating to the same authenticate_with_credentials. /user/login is unchanged; /token is additive and takes the form these clients already send. Closes #238
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #238
Problem
Login was exposed only at
POST /user/loginwith a JSON body. Existing clients — notably already-installed versions of thendp-epPython library — authenticate by posting form-encodedusernameandpasswordtoPOST /token. Against an Endpoint those requests get a 404, so those users cannot log in until they upgrade the client.Fix
Add a
POST /tokenroute that accepts form-encoded credentials and returns the same authentication result as/user/login, delegating to the sameauthenticate_with_credentials./user/loginis unchanged;/tokenis additive and accepts the form these clients already send (so it must be form-encoded, not JSON — a JSON-only alias would turn the 404 into a 422 and still not help them).Verified
New
TestTokenAliasRouteintests/test_user_login_route.py: form-encoded credentials return the IDP payload, invalid credentials give 401, and a missing form field gives 422 (not 404). Full suite 1215 passed;black/flake8clean.Companion to the client-side fix (
ndp-ep0.8.1, which now posts to/user/login): new clients use/user/login, and this keeps older installed clients working without an upgrade.