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

Improve wellknown usage #3585

Merged
merged 12 commits into from
Jul 5, 2021
Merged

Improve wellknown usage #3585

merged 12 commits into from
Jul 5, 2021

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Jun 30, 2021

This PR fixes several issues:

Fixes #2843 : we now first perform a .well-known request, even if the entered URL is a valid Matrix API

Fixes #3572: we now store the url entered at session creation (Auth database migration required to add the new field), for further reference. Settings screen is updated:

image

and

image

API URL is only displayed in developer mode (see the diff with https://user-images.githubusercontent.com/3940906/123458079-e79cba00-d5e4-11eb-825e-4d481662b418.png).

Some change in the SDK API, wellknown now takes a domain instead of a matrixId.

Tested OK

  • sign in on matrix.org
  • sign up on matrix.org
  • SSO on matrix.org (using a GitHub account, see the screenshots)
  • sign in on mozilla.modular.im (other SSO)
  • sign in using a matrixId
  • use element web url (develop.element.io) to retrieve config file

Limitation

If the user enter the matrix API url, for instance "matrix-client.matrix.org", there is no way to deduce the domain matrix.org. So every further wellknow request will fail.

@BillCarsonFr BillCarsonFr self-requested a review July 5, 2021 14:04
Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just 2 remarks

if (it is Failure.OtherServerError
&& it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
// It's maybe a Riot url?
getRiotDomainLoginFlowInternal(homeServerConnectionConfig)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Riot reference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return tryOrNull { getWellknown(userId) }
suspend fun RawService.getElementWellknown(sessionParams: SessionParams): ElementWellKnown? {
// By default we use the domain of the userId to retrieve the .well-known data
val domain = sessionParams.userId.substringAfter(":")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have an extension method for this substringAfter(":") as we use it at several places

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: added fun String.getDomain(): String in MatrixPattern

@bmarty bmarty merged commit ca45cdd into develop Jul 5, 2021
@bmarty bmarty deleted the feature/bma/wellknown branch July 5, 2021 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants