Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upconfirm_redirect_uri after validate_code feels wrong #688
Comments
Hi, Thanks for this detailed report. The overall idea of oauthlib is to provide a framework for OAuth2.0 and to put all the "RFC code" into the framework, and all the "implementation code" into your project. If we tell users to validate themselves the BTW, in order to avoid the extra database lookup, I'd suggest to store the necessary thing (i.e. the database record) in the |
I'm implementing a validator, and I am finding the behaviour of
validate_token_request
inoauthlib/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
Lines 435 to 543 in d7b90fc
Specifically the fact that
validate_code
is not required to validate theredirect_uri
, and instead we basically get two calls that are fairly similar:validate_code
client_id
code
client
request
Presumable in
validate_code
we do a bunch of work:code
, validate that it matches theclient_id
, validate it hasn't expired (since these are supposed to be short-lived).user
,.state
(if set),.scopes
,.claims
and the PKCE challenge stuff onrequest
Then a couple lines later we are asked to do:
confirm_redirect_uri
client_id
code
redirect_uri
client
request
Since we didn't return the original database object from the original lookup, to return
True
/False
to this check, we basically have to look up the code again, especially since there is no requirement to set theredirect_uri
we stored in the database on therequest
object.Is there an expectation that we stash the database object somewhere ourselves?
Why not pass the
redirect_uri
to thevalidate_code
function instead (or pull it fromrequest.redirect_uri
. This way I can even save time of doing validation in Python, instead I can just tell SQLAlchemy what I am looking for, and the database can do the sensible thing and not return a row if nothing matches (and thus I can returnFalse
).If I were to write a patch that would move that functionality up, and update the docstrings to tell users of the library to properly validate the
redirect_uri
invalidate_code
would that get accepted by the maintainers?