-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add m.login.terms to the registration flow #4004
Changes from all commits
fd99787
149c4f1
3099d96
dfcad5f
f9d34a7
537d0b7
158d6c7
7ede650
22a2004
5119818
dd99db8
f293d12
762a098
442734f
a8ed93a
49a044a
88c5ffe
dba84fa
54def42
9283987
4acb6fe
81880be
a5468ea
d1e7b9c
a8d41c6
a8c9faa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add `m.login.terms` to the registration flow when consent tracking is enabled. **This makes the template arguments conditionally optional on a new `public_version` variable - update your privacy templates to support this.** | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,29 @@ | |
| </html> | ||
| """ | ||
|
|
||
| TERMS_TEMPLATE = """ | ||
| <html> | ||
| <head> | ||
| <title>Authentication</title> | ||
| <meta name='viewport' content='width=device-width, initial-scale=1, | ||
| user-scalable=no, minimum-scale=1.0, maximum-scale=1.0'> | ||
| <link rel="stylesheet" href="/_matrix/static/client/register/style.css"> | ||
| </head> | ||
| <body> | ||
| <form id="registrationForm" method="post" action="%(myurl)s"> | ||
| <div> | ||
| <p> | ||
| Please click the button below if you agree to the | ||
| <a href="%(terms_url)s">privacy policy of this homeserver.</a> | ||
| </p> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have been "Please click the button below if you have read the privacy policy of this homeserver." Because if you have a button to "Agree" you also need a workflow to "disagree" later on, which we don't want to provide. see #4185 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. The average home server doesn't have any consent to track because there should be nothing you have to consent to. Art. 7 1 b "Processing shall be lawful only if ... processing is necessary for the performance of a contract to which the data subject is party". Everything that is technically necessary to provide the service needs just information, not consent. Consent needs to be freely given and can be retracted at any time - without terminating the service (Art. 7 GDPR and Recital 43). We are not Facebook or Google, we do not force the user to consent to anything. We can't help the technical necessities though and about them we INFORM. "Consent" and "agree" implies that you store data that is not technically necessary to supply the service, which - I hope - no homeserver does. (Except: Consent to statistics/piwik is tracked in the settings which is correct. Consent to bots - which I personally think needs consent - should be in the settings too but that's not the topic here.) |
||
| <input type="hidden" name="session" value="%(session)s" /> | ||
| <input type="submit" value="Agree" /> | ||
| </div> | ||
| </form> | ||
| </body> | ||
| </html> | ||
| """ | ||
|
|
||
| SUCCESS_TEMPLATE = """ | ||
| <html> | ||
| <head> | ||
|
|
@@ -130,6 +153,27 @@ def on_GET(self, request, stagetype): | |
| request.setHeader(b"Content-Type", b"text/html; charset=utf-8") | ||
| request.setHeader(b"Content-Length", b"%d" % (len(html_bytes),)) | ||
|
|
||
| request.write(html_bytes) | ||
| finish_request(request) | ||
| defer.returnValue(None) | ||
| elif stagetype == LoginType.TERMS: | ||
| session = request.args['session'][0] | ||
|
|
||
| html = TERMS_TEMPLATE % { | ||
| 'session': session, | ||
| 'terms_url': "%s/_matrix/consent?v=%s" % ( | ||
| self.hs.config.public_baseurl, | ||
| self.hs.config.user_consent_version, | ||
| ), | ||
| 'myurl': "%s/auth/%s/fallback/web" % ( | ||
| CLIENT_V2_ALPHA_PREFIX, LoginType.TERMS | ||
| ), | ||
| } | ||
| html_bytes = html.encode("utf8") | ||
| request.setResponseCode(200) | ||
| request.setHeader(b"Content-Type", b"text/html; charset=utf-8") | ||
| request.setHeader(b"Content-Length", b"%d" % (len(html_bytes),)) | ||
|
|
||
| request.write(html_bytes) | ||
| finish_request(request) | ||
| defer.returnValue(None) | ||
|
|
@@ -139,7 +183,7 @@ def on_GET(self, request, stagetype): | |
| @defer.inlineCallbacks | ||
| def on_POST(self, request, stagetype): | ||
| yield | ||
| if stagetype == "m.login.recaptcha": | ||
| if stagetype == LoginType.RECAPTCHA: | ||
| if ('g-recaptcha-response' not in request.args or | ||
| len(request.args['g-recaptcha-response'])) == 0: | ||
| raise SynapseError(400, "No captcha response supplied") | ||
|
|
@@ -178,6 +222,41 @@ def on_POST(self, request, stagetype): | |
| request.write(html_bytes) | ||
| finish_request(request) | ||
|
|
||
| defer.returnValue(None) | ||
| elif stagetype == LoginType.TERMS: | ||
| if ('session' not in request.args or | ||
| len(request.args['session'])) == 0: | ||
| raise SynapseError(400, "No session supplied") | ||
|
|
||
| session = request.args['session'][0] | ||
| authdict = {'session': session} | ||
|
|
||
| success = yield self.auth_handler.add_oob_auth( | ||
| LoginType.TERMS, | ||
| authdict, | ||
| self.hs.get_ip_from_request(request) | ||
| ) | ||
|
|
||
| if success: | ||
| html = SUCCESS_TEMPLATE | ||
| else: | ||
| html = TERMS_TEMPLATE % { | ||
| 'session': session, | ||
| 'terms_url': "%s/_matrix/consent?v=%s" % ( | ||
| self.hs.config.public_baseurl, | ||
| self.hs.config.user_consent_version, | ||
| ), | ||
| 'myurl': "%s/auth/%s/fallback/web" % ( | ||
| CLIENT_V2_ALPHA_PREFIX, LoginType.TERMS | ||
| ), | ||
| } | ||
| html_bytes = html.encode("utf8") | ||
| request.setResponseCode(200) | ||
| request.setHeader(b"Content-Type", b"text/html; charset=utf-8") | ||
| request.setHeader(b"Content-Length", b"%d" % (len(html_bytes),)) | ||
|
|
||
| request.write(html_bytes) | ||
| finish_request(request) | ||
| defer.returnValue(None) | ||
| else: | ||
| raise SynapseError(404, "Unknown auth stage type") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.