{"action":"created","comment":{"url":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/comments/236501789","pull_request_review_id":178587155,"id":236501789,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNjUwMTc4OQ==","diff_hunk":"@@ -0,0 +1,128 @@\n+# MSC1730: Mechanism for redirecting to an alternative server during login\n+\n+Complex homeserver deployments may consist of several homeserver instances,\n+where the HS to be used for a user session is determined at login time. The HS\n+might be chosen based on any of a number of factors, such as the individual\n+user, or a simple round-robin to load-balance.\n+\n+One solution to this is for users to log in via a \"portal server\", which\n+accepts the login request, and picks the server accordingly. This proposal\n+suggests adding a field to the `/login` response which tells clients which\n+endpoint they should use for the client-server (C-S) API after login.\n+\n+## Proposal\n+\n+The response to `POST /_matrix/client/r0/login` currently includes the fields\n+`user_id`, `access_token`, `device_id`, and the deprecated `home_server`.\n+\n+We should add to this a `base_cs_url` field, which SHOULD be returned by\n+compliant homeservers, which gives a base URL for the client-server API.\n+\n+As with\n+[.well-known](https://matrix.org/docs/spec/client_server/r0.4.0.html#well-known-uri),\n+clients would then add `/_matrix/client/...` to this URL to form valid C-S\n+endpoints.\n+\n+One way that this could be used is that the portal server proxies the `/login`\n+request, and passes it on to the target HS, as shown in the sequence diagram below:\n+\n+![Sequence diagram](images/1730-seq-diagram.svg)\n+\n+Alternatively, the portal server could redirect the original `login` request to\n+the target HS with a `307 Temporary Redirect` response:\n+\n+![Sequence diagram](images/1730-seq-diagram-2.svg)\n+\n+(Note that the deprecated `home_server` field gives the `server_name` of the\n+relevant homeserver, which may be quite different to the location of the C-S\n+API, so is not of use here. Further we cannot repurpose it, because (a) this\n+might break existing clients; (b) it spells homeserver wrong.)\n+\n+### Notes on proxying vs redirecting\n+\n+Proxying the `/login` request as shown in the first sequence diagram above\n+leads to the following concerns:\n+\n+* The target homeserver sees the request coming from the portal server rather\n+  than the client, so that the wrong IP address will be recorded against the\n+  user's session. (This might be a problem for, for example, IP locking the\n+  session, and might affect the `last_seen_ip` field returned by `GET\n+  /_matrix/client/r0/devices`.)\n+\n+  This can be mitigated to some extent via the use of an `X-Forwarded-For`\n+  header, but that then requires the portal server to authenticate itself with\n+  the target homeserver in some way.\n+\n+* It causes additional complexity in the portal server, which must now be\n+  responsible for making outbound HTTP requests.\n+\n+* It potentially leads to a privacy leak, since the portal server could snoop\n+  on the returned access token. (Given that the portal server must be trusted\n+  to some extent in this architecture, it is unclear how much of a concern this\n+  really is.)\n+\n+On the other hand, redirecting it with a `307` response may reduce flexibility,\n+or require more state to be managed on the portal server [1]. Furthermore\n+support for `307` redirects among user-agents may vary\n+([RFC2616](https://tools.ietf.org/html/rfc2616#section-10.3.8) said \"If the 307\n+status code is received in response to a request other than GET or HEAD, the\n+user agent MUST NOT automatically redirect the request unless it can be\n+confirmed by the user\", though this appears to have been dropped by\n+[RFC7231](https://tools.ietf.org/html/rfc7231#section-6.4.7) and I am unaware\n+of any current browsers which do not follow `307` redirects.)\n+\n+In any case, this is an implementation decision; portal servers can use\n+whichever method best suits their needs.","path":"proposals/1730-cs-api-in-login-response.md","position":75,"original_position":75,"commit_id":"6fa754c447fe93cffd5c011640fe4c63c7daaa4b","original_commit_id":"6fa754c447fe93cffd5c011640fe4c63c7daaa4b","user":{"login":"maxidor","id":10545559,"node_id":"MDQ6VXNlcjEwNTQ1NTU5","avatar_url":"https://avatars2.githubusercontent.com/u/10545559?v=4","gravatar_id":"","url":"https://api.github.com/users/maxidor","html_url":"https://github.com/maxidor","followers_url":"https://api.github.com/users/maxidor/followers","following_url":"https://api.github.com/users/maxidor/following{/other_user}","gists_url":"https://api.github.com/users/maxidor/gists{/gist_id}","starred_url":"https://api.github.com/users/maxidor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxidor/subscriptions","organizations_url":"https://api.github.com/users/maxidor/orgs","repos_url":"https://api.github.com/users/maxidor/repos","events_url":"https://api.github.com/users/maxidor/events{/privacy}","received_events_url":"https://api.github.com/users/maxidor/received_events","type":"User","site_admin":false},"body":"Redirection requires a 307 redirect which is not defined in the C2S API spec for `/login`, so this is actually not up to implementations and requires a spec change for one of them.","created_at":"2018-11-27T02:38:45Z","updated_at":"2018-11-27T02:39:37Z","html_url":"https://github.com/matrix-org/matrix-doc/pull/1730#discussion_r236501789","pull_request_url":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/1730","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/comments/236501789"},"html":{"href":"https://github.com/matrix-org/matrix-doc/pull/1730#discussion_r236501789"},"pull_request":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/1730"}}},"pull_request":{"url":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/1730","id":233192516,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzMTkyNTE2","html_url":"https://github.com/matrix-org/matrix-doc/pull/1730","diff_url":"https://github.com/matrix-org/matrix-doc/pull/1730.diff","patch_url":"https://github.com/matrix-org/matrix-doc/pull/1730.patch","issue_url":"https://api.github.com/repos/matrix-org/matrix-doc/issues/1730","number":1730,"state":"open","locked":false,"title":"MSC1730: Mechanism for redirecting to an alternative server during login","user":{"login":"richvdh","id":1389908,"node_id":"MDQ6VXNlcjEzODk5MDg=","avatar_url":"https://avatars1.githubusercontent.com/u/1389908?v=4","gravatar_id":"","url":"https://api.github.com/users/richvdh","html_url":"https://github.com/richvdh","followers_url":"https://api.github.com/users/richvdh/followers","following_url":"https://api.github.com/users/richvdh/following{/other_user}","gists_url":"https://api.github.com/users/richvdh/gists{/gist_id}","starred_url":"https://api.github.com/users/richvdh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richvdh/subscriptions","organizations_url":"https://api.github.com/users/richvdh/orgs","repos_url":"https://api.github.com/users/richvdh/repos","events_url":"https://api.github.com/users/richvdh/events{/privacy}","received_events_url":"https://api.github.com/users/richvdh/received_events","type":"User","site_admin":false},"body":"[Rendered](https://github.com/matrix-org/matrix-doc/blob/rav/proposal/cs_api_in_login/proposals/1730-cs-api-in-login-response.md)","created_at":"2018-11-23T12:52:13Z","updated_at":"2018-11-27T02:39:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"686a3a370c4c2737189fade86d775ee3a61c4005","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1006690935,"node_id":"MDU6TGFiZWwxMDA2NjkwOTM1","url":"https://api.github.com/repos/matrix-org/matrix-doc/labels/T-Core","name":"T-Core","color":"3f6caf","default":false},{"id":1108852923,"node_id":"MDU6TGFiZWwxMTA4ODUyOTIz","url":"https://api.github.com/repos/matrix-org/matrix-doc/labels/disposition-merge","name":"disposition-merge","color":"ededed","default":false},{"id":933911135,"node_id":"MDU6TGFiZWw5MzM5MTExMzU=","url":"https://api.github.com/repos/matrix-org/matrix-doc/labels/proposal","name":"proposal","color":"8fff87","default":false},{"id":926414344,"node_id":"MDU6TGFiZWw5MjY0MTQzNDQ=","url":"https://api.github.com/repos/matrix-org/matrix-doc/labels/proposal-in-review","name":"proposal-in-review","color":"9aaae2","default":false},{"id":1108852908,"node_id":"MDU6TGFiZWwxMTA4ODUyOTA4","url":"https://api.github.com/repos/matrix-org/matrix-doc/labels/proposed-final-comment-period","name":"proposed-final-comment-period","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/1730/commits","review_comments_url":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/1730/comments","review_comment_url":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matrix-org/matrix-doc/issues/1730/comments","statuses_url":"https://api.github.com/repos/matrix-org/matrix-doc/statuses/6fa754c447fe93cffd5c011640fe4c63c7daaa4b","head":{"label":"matrix-org:rav/proposal/cs_api_in_login","ref":"rav/proposal/cs_api_in_login","sha":"6fa754c447fe93cffd5c011640fe4c63c7daaa4b","user":{"login":"matrix-org","id":8418310,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0MTgzMTA=","avatar_url":"https://avatars2.githubusercontent.com/u/8418310?v=4","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24998719,"node_id":"MDEwOlJlcG9zaXRvcnkyNDk5ODcxOQ==","name":"matrix-doc","full_name":"matrix-org/matrix-doc","private":false,"owner":{"login":"matrix-org","id":8418310,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0MTgzMTA=","avatar_url":"https://avatars2.githubusercontent.com/u/8418310?v=4","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/matrix-org/matrix-doc","description":"Matrix Documentation (including The Spec)","fork":false,"url":"https://api.github.com/repos/matrix-org/matrix-doc","forks_url":"https://api.github.com/repos/matrix-org/matrix-doc/forks","keys_url":"https://api.github.com/repos/matrix-org/matrix-doc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/matrix-doc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/matrix-doc/teams","hooks_url":"https://api.github.com/repos/matrix-org/matrix-doc/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/matrix-doc/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/matrix-doc/events","assignees_url":"https://api.github.com/repos/matrix-org/matrix-doc/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/matrix-doc/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/matrix-doc/tags","blobs_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/matrix-doc/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/matrix-doc/languages","stargazers_url":"https://api.github.com/repos/matrix-org/matrix-doc/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/matrix-doc/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/matrix-doc/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/matrix-doc/subscription","commits_url":"https://api.github.com/repos/matrix-org/matrix-doc/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/matrix-doc/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/matrix-doc/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/matrix-doc/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/matrix-doc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/matrix-doc/merges","archive_url":"https://api.github.com/repos/matrix-org/matrix-doc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/matrix-doc/downloads","issues_url":"https://api.github.com/repos/matrix-org/matrix-doc/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/matrix-doc/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/matrix-doc/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/matrix-doc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/matrix-doc/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/matrix-doc/releases{/id}","deployments_url":"https://api.github.com/repos/matrix-org/matrix-doc/deployments","created_at":"2014-10-09T16:41:02Z","updated_at":"2018-11-26T03:12:09Z","pushed_at":"2018-11-26T23:37:12Z","git_url":"git://github.com/matrix-org/matrix-doc.git","ssh_url":"git@github.com:matrix-org/matrix-doc.git","clone_url":"https://github.com/matrix-org/matrix-doc.git","svn_url":"https://github.com/matrix-org/matrix-doc","homepage":null,"size":8532,"stargazers_count":172,"watchers_count":172,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":86,"mirror_url":null,"archived":false,"open_issues_count":533,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":86,"open_issues":533,"watchers":172,"default_branch":"master"}},"base":{"label":"matrix-org:master","ref":"master","sha":"ef33c175b5999ecd526408adc9a284bcbf3b77d6","user":{"login":"matrix-org","id":8418310,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0MTgzMTA=","avatar_url":"https://avatars2.githubusercontent.com/u/8418310?v=4","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24998719,"node_id":"MDEwOlJlcG9zaXRvcnkyNDk5ODcxOQ==","name":"matrix-doc","full_name":"matrix-org/matrix-doc","private":false,"owner":{"login":"matrix-org","id":8418310,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0MTgzMTA=","avatar_url":"https://avatars2.githubusercontent.com/u/8418310?v=4","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/matrix-org/matrix-doc","description":"Matrix Documentation (including The Spec)","fork":false,"url":"https://api.github.com/repos/matrix-org/matrix-doc","forks_url":"https://api.github.com/repos/matrix-org/matrix-doc/forks","keys_url":"https://api.github.com/repos/matrix-org/matrix-doc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/matrix-doc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/matrix-doc/teams","hooks_url":"https://api.github.com/repos/matrix-org/matrix-doc/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/matrix-doc/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/matrix-doc/events","assignees_url":"https://api.github.com/repos/matrix-org/matrix-doc/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/matrix-doc/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/matrix-doc/tags","blobs_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/matrix-doc/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/matrix-doc/languages","stargazers_url":"https://api.github.com/repos/matrix-org/matrix-doc/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/matrix-doc/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/matrix-doc/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/matrix-doc/subscription","commits_url":"https://api.github.com/repos/matrix-org/matrix-doc/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/matrix-doc/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/matrix-doc/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/matrix-doc/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/matrix-doc/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/matrix-doc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/matrix-doc/merges","archive_url":"https://api.github.com/repos/matrix-org/matrix-doc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/matrix-doc/downloads","issues_url":"https://api.github.com/repos/matrix-org/matrix-doc/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/matrix-doc/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/matrix-doc/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/matrix-doc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/matrix-doc/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/matrix-doc/releases{/id}","deployments_url":"https://api.github.com/repos/matrix-org/matrix-doc/deployments","created_at":"2014-10-09T16:41:02Z","updated_at":"2018-11-26T03:12:09Z","pushed_at":"2018-11-26T23:37:12Z","git_url":"git://github.com/matrix-org/matrix-doc.git","ssh_url":"git@github.com:matrix-org/matrix-doc.git","clone_url":"https://github.com/matrix-org/matrix-doc.git","svn_url":"https://github.com/matrix-org/matrix-doc","homepage":null,"size":8532,"stargazers_count":172,"watchers_count":172,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":86,"mirror_url":null,"archived":false,"open_issues_count":533,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":86,"open_issues":533,"watchers":172,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/1730"},"html":{"href":"https://github.com/matrix-org/matrix-doc/pull/1730"},"issue":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/issues/1730"},"comments":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/issues/1730/comments"},"review_comments":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/1730/comments"},"review_comment":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/pulls/1730/commits"},"statuses":{"href":"https://api.github.com/repos/matrix-org/matrix-doc/statuses/6fa754c447fe93cffd5c011640fe4c63c7daaa4b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"maxidor"}}