This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Update the process for mapping SAML2 users to matrix IDs #6037
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a8ac404
Record mappings from saml users in an external table
richvdh b9d5750
changelog
richvdh 7423fad
better logging
richvdh b65327f
Merge branch 'develop' into rav/saml_mapping_work
richvdh 6db5adc
Merge branch 'rav/saml_config_cleanup' into rav/saml_mapping_work
richvdh 599f786
Update 6037.feature
richvdh 33757ba
More better logging
richvdh 366dc7d
Merge commit '33757bad1' into rav/saml_mapping_work
richvdh ed8b92f
Merge remote-tracking branch 'origin/develop' into rav/saml_mapping_work
richvdh 9b7c4f4
Merge remote-tracking branch 'origin/develop' into rav/saml_mapping_work
richvdh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Make the process for mapping SAML2 users to matrix IDs more flexible. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
from six.moves import range | ||
|
||
from twisted.internet import defer | ||
from twisted.internet.defer import Deferred | ||
|
||
from synapse.api.constants import UserTypes | ||
from synapse.api.errors import Codes, StoreError, SynapseError, ThreepidValidationError | ||
|
@@ -384,6 +385,26 @@ def f(txn): | |
|
||
return self.runInteraction("get_users_by_id_case_insensitive", f) | ||
|
||
async def get_user_by_external_id( | ||
self, auth_provider: str, external_id: str | ||
) -> str: | ||
"""Look up a user by their external auth id | ||
|
||
Args: | ||
auth_provider: identifier for the remote auth provider | ||
external_id: id on that system | ||
|
||
Returns: | ||
str|None: the mxid of the user, or None if they are not known | ||
""" | ||
return await self._simple_select_one_onecol( | ||
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. Why is this an 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. shrug. I can update one of them if you like. 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. Fair, was just wondering if it was a typo or something. Doesn't need to change |
||
table="user_external_ids", | ||
keyvalues={"auth_provider": auth_provider, "external_id": external_id}, | ||
retcol="user_id", | ||
allow_none=True, | ||
desc="get_user_by_external_id", | ||
) | ||
|
||
@defer.inlineCallbacks | ||
def count_all_users(self): | ||
"""Counts all users registered on the homeserver.""" | ||
|
@@ -1032,6 +1053,26 @@ def _register_user( | |
self._invalidate_cache_and_stream(txn, self.get_user_by_id, (user_id,)) | ||
txn.call_after(self.is_guest.invalidate, (user_id,)) | ||
|
||
def record_user_external_id( | ||
self, auth_provider: str, external_id: str, user_id: str | ||
) -> Deferred: | ||
"""Record a mapping from an external user id to a mxid | ||
|
||
Args: | ||
auth_provider: identifier for the remote auth provider | ||
external_id: id on that system | ||
user_id: complete mxid that it is mapped to | ||
""" | ||
return self._simple_insert( | ||
table="user_external_ids", | ||
values={ | ||
"auth_provider": auth_provider, | ||
"external_id": external_id, | ||
"user_id": user_id, | ||
}, | ||
desc="record_user_external_id", | ||
) | ||
|
||
def user_set_password_hash(self, user_id, password_hash): | ||
""" | ||
NB. This does *not* evict any cache because the one use for this | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Any reason this doesn't match what was there before?
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.
yeah, it was broken before.