Skip to content
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

Fix non spec conformant login oauth flow #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JMoVS
Copy link

@JMoVS JMoVS commented Aug 26, 2023

The current implementation uses a trick where the redirect URL is passed with a parameter specifying the userID so on return, the specific userID can be extracted from the called URL again. This is against the spec of Oauths RFC and does currently work with Github, however while trying to reuse the code for interacting with the Wrike API it turned out to be problematic.

This is what I'm referring to:

Per-Request Customization

Often times a developer will think that they need to be able to use a different redirect URL on each authorization request, and will try to change the query string parameters per request. This is not the intended use of the redirect URL, and **should not be allowed by the authorization server**. **The server should reject any authorization requests with redirect URLs that are not an exact match of a registered URL.**

If a client wishes to include request-specific data in the redirect URL, it can instead use the “state” parameter to store data that will be included after the user is redirected. It can either encode the data in the state parameter itself, or use the state parameter as a session ID to store the state on the server.

Now as during the creation of the github oauth app, the redirect URL is specified without the UserID field, it should not work.

I edited the code to instead put the userID in the state field and extract it when returning back to maubot.

I tried to make sure that the delimiter between the userID and the state would not run into any conflicts. The chosen "%" is not a viable character for userIDs in matrix (https://spec.matrix.org/v1.8/appendices/#user-identifiers) and also poses no problems with URLs.

As I'm working on my end with different APIs from Wrike, would it be possible for you to check if these commits work on Github as well or if you run into other issues?

JMoVS added 3 commits August 26, 2023 20:32
…pliant with oauth

we still fail with a currently unknown ClientError in finish_login, but at least we successfully get the first token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant