-
-
Notifications
You must be signed in to change notification settings - Fork 833
Conversation
Can I be a pain and suggest that the discovery parts go in matrix-js-sdk. I can certainly think of projects which would benefit from this code and it would limit duping the same algo all over the place? |
It would be nearly impossible to put the .well-known bits in the js-sdk and maintain a helpful UI, sorry. Edit: unless anyone has bright ideas on how to do so, given all the potential surrounding the redesign. |
and
Then I'm afraid you are:
There was a rationale why this was made this way, and I would strongly recommend you do not deviate from it in the slightest. |
Return an object that would give the outcome of the auto-discovery (ignore, fail prompt, fail error, ok, etc.) so the UI can react accordingly. |
Basically this, but @turt2live thinks this might be quite difficult with the UX requirements in the spec so it may not be so simple. |
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.
Looks good modulo comments here & over on the spec PR.
|
||
if (this.state.discoveredHsUrl) { | ||
console.log("Rewriting username because the homeserver was discovered"); | ||
username = username.substring(1).split(":")[0]; |
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.
Should we not just be sending the full mxid to the server?
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.
this eventually gets passed along to /login
as just the localpart. Here seemed like a good enough place to do the conversion is all.
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.
hmm, where's that? I thought it just went through as 'user' in https://github.com/matrix-org/matrix-react-sdk/blob/master/src/Login.js#L130 ?
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.
yea, around there. According to the spec ( https://matrix.org/docs/spec/client_server/r0.4.0.html#identifier-types ) it should work fine with the local part or user ID - I might have stumbled on a synapse bug (or I suck at testing)
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.
My testing was flawed - will fix.
@@ -218,8 +233,12 @@ module.exports = React.createClass({ | |||
}).done(); | |||
}, | |||
|
|||
onUsernameChanged: function(username) { | |||
onUsernameChanged: function(username, endOfInput) { |
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 would be tempted to just have a separate onUsernameBlur
rather than adding a param
return; | ||
} | ||
|
||
console.log("Verifying homeserver URL: " + hsUrl); |
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.
Presumably this would go if matrix-org/matrix-spec-proposals#1700 is approved?
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.
Yup
// XXX: We don't verify the identity server URL because sydent doesn't register | ||
// the route we need. | ||
|
||
// console.log("Verifying identity server URL: " + isUrl); |
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 assume also unnecessary with matrix-org/matrix-spec-proposals#1700
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.
Yup
customHsUrl={this.props.customHsUrl} | ||
customIsUrl={this.props.customIsUrl} | ||
customHsUrl={this.state.discoveredHsUrl || this.props.customHsUrl} | ||
customIsUrl={this.state.discoveredIsUrl ||this.props.customIsUrl} |
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.
Should the value from .well-known be changing the default rather than setting custom URLs? You may still want to override the HS URL (eg. https://example.com/
-> https://example-test.com/
) but having got the urls from .well-known essentially provides us a better default.
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.
There was something that got in the way when I tried to set them explicitly the first time, however I think I might have fixed the bug towards the end of implementing this. I'll see if I can repurpose the custom properties instead of introducing new ones, while also maintaining the ability to override the discovered URL (for power users).
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 think it's best to keep this as-is. It forces the UI to switch to "Custom Server", signifying that something happened. It isn't the best UX, but it is something.
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.
otherwise looks fine
const url = new URL("https://" + serverName); | ||
this._tryWellKnownDiscovery(url.hostname); | ||
} catch (e) { | ||
console.error("Problem parsing URL or unhandled error doing .well-known discovery"); |
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 think we've been converging on console.log("message", e)
which does a sensible thing
Fixes element-hq/element-web#7253
Note: this does not implement step 2 of the discovery process. This is because IPv6 addresses are difficult to verify this way. Instead, this will adopt any port number in the user's ID as part of the address it queries for a .well-known config. See matrix-org/matrix-spec-proposals#1700 for more information.
Here's it working for someone trying to log in with a not-matrix.org address (for example):