mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-06 16:55:18 -04:00
Add SSO attribute requirements for OIDC providers (#9609)
Allows limiting who can login using OIDC via the claims made from the IdP.
This commit is contained in:
parent
8000cf1315
commit
dd5e5dc1d6
5 changed files with 209 additions and 1 deletions
|
@ -280,6 +280,7 @@ class OidcProvider:
|
|||
self._config = provider
|
||||
self._callback_url = hs.config.oidc_callback_url # type: str
|
||||
|
||||
self._oidc_attribute_requirements = provider.attribute_requirements
|
||||
self._scopes = provider.scopes
|
||||
self._user_profile_method = provider.user_profile_method
|
||||
|
||||
|
@ -859,6 +860,18 @@ class OidcProvider:
|
|||
)
|
||||
|
||||
# otherwise, it's a login
|
||||
logger.debug("Userinfo for OIDC login: %s", userinfo)
|
||||
|
||||
# Ensure that the attributes of the logged in user meet the required
|
||||
# attributes by checking the userinfo against attribute_requirements
|
||||
# In order to deal with the fact that OIDC userinfo can contain many
|
||||
# types of data, we wrap non-list values in lists.
|
||||
if not self._sso_handler.check_required_attributes(
|
||||
request,
|
||||
{k: v if isinstance(v, list) else [v] for k, v in userinfo.items()},
|
||||
self._oidc_attribute_requirements,
|
||||
):
|
||||
return
|
||||
|
||||
# Call the mapper to register/login the user
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue