-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
9fc1f51
to
0ba778b
Compare
9f4c012
to
9e1468d
Compare
@mjattiot thanks for the contribution... first step is to merge recent |
63233f9
to
aa3af51
Compare
Mmmh I have just rebased from develop but I still see some checks failing. Could you help me understand why it fails ? |
For example, look at the 'homeserver.log' under the artifacts tab at https://buildkite.com/matrix-dot-org/synapse/builds/5660#0ab2e7e5-c876-46dc-ab5f-bd3ad395a2f2. Looks like a syntax error of some sort. |
a88bf54
to
93ef60b
Compare
I had some syntax errors because I was using f-strings which are not compatible with python 3.5. |
The problem is the call to |
95dc1fa
to
1b845fd
Compare
@richvdh thank you for your insights and sorry for the response delay. |
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.
Thanks very much for continuing your work on this.
I've started some review here, but there's quite a lot here: I suggest you have a look at my comments so far.
I think you're actually implementing two different things here:
- making a logout request to the IdP when we receive a request from a matrix client to
/_matrix/client/r0/logout
. - invalidating synapse access tokens when we receive a
_matrix/saml2/logout
request from the IdP
I don't think there is any reason that we have to implement both of these at the same time, so I suggest that, to make it easier for us to work on the PR, you split up this PR so that we are just doing one at a time.
@@ -89,7 +89,7 @@ | |||
# python 3.5.2, as per https://github.com/itamarst/eliot/issues/418 | |||
'eliot<1.8.0;python_version<"3.5.3"', | |||
], | |||
"saml2": ["pysaml2>=4.5.0"], | |||
"saml2": ["pysaml2>=4.9.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.
if there's a particular reason we need this (something not supported in 4.5?) please could you add a comment to say so, in the same way as some of the other entries?
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.
no particular reason but 4.5.0 has been released in october 2017, and according to release notes, 4.9.0 don't change any API. So I assume it would have been better to bump the minor version for stability improvement. Up to you, I can revert
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.
generally we don't bump our minimum required dependencies unless there is a need to solve a particular problem. Bumping the version for no reason makes things difficult for distribution package maintainers.
synapse/handlers/saml_handler.py
Outdated
resp_bytes, BINDING_HTTP_REDIRECT | ||
) | ||
logger.info("Received SAML logout response %s", resp_saml) | ||
if resp_saml.response.status.status_code.value == STATUS_SUCCESS: |
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.
suggest inverting this condition
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.
what do you mean ?
if STATUS_SUCCESS == resp_saml.response.status.status_code.value: ?
f0d7670
to
0b0150a
Compare
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.
Hello @richvdh , sorry for the late response, I have been quite busy.
I rebased to develop, reviewed all your comments, corrected accordingly for most of them and reviewed some logic. If you have time in coming weeks, please feel free to have another pass.
# local cache. In that case we select the last session and remove | ||
# other ones. | ||
def _find_session_from_user(self, username): | ||
subjects = self._saml_client.users.subjects() |
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 is clearly the weakness of my implementation. In case the server restarts, local sessions are lost, therefore we cannot retrieve the "session_index" of a user and we cannot proceed with a logout.
However I found this weakness acceptable in terms of user experience : if the server crashes and a user presses logout button, it won't logged him out but in the background it will restore a session index in local cache. Therefore if the user presses the button a second time the logout will work. It's an usual behavior for a user to re-press a button if the first time it doesn't work. But I admit it's not ideal.
If we want to make it works smoothly after a crash we need a way to persist this sessions cache. I am not familiar enough with Synapse to know which is the best way to implement persistence cleanly but if you show me the way I can implement it.
except Exception as e: | ||
raise SynapseError( | ||
500, "error while creating SAML logout request: %s" % (e,) | ||
) |
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.
Not sure. self._saml_client.do_logout() can raise a LogoutError we want to catch it and convert it to a Synapse Error instead.
synapse/handlers/saml_handler.py
Outdated
resp_bytes, BINDING_HTTP_REDIRECT | ||
) | ||
logger.info("Received SAML logout response %s", resp_saml) | ||
if resp_saml.response.status.status_code.value == STATUS_SUCCESS: |
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.
what do you mean ?
if STATUS_SUCCESS == resp_saml.response.status.status_code.value: ?
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 I've answered your questions, but again: I think this PR is quite big, and I'd like to see it split into two parts: one to handle _matrix/saml2/logout
, and the other to extend /_matrix/client/r0/logout
In fact, it's not entirely clear to me that a logout request from a matrix client should be unconditionally passed to on to the saml server as a single-logout-request. Just because I want to log out of Matrix doesn't necessarily mean I want to log out of everything?
I suggest you focus on handling logout requests from the SAML server first, and then we can consider if we need the more complicated second case.
this is bitrotting rapidly. I'm going to close it for now. we'd still welcome contributions in this area; if you'd like to resume work we can reopen. |
Pull Request Checklist
Signed-off-by: Maxime Jattiot mjattiot@opensense.fr