zulip/zerver
Mateusz Mandera 7e1f468f04 saml: Fix exception when syncing missing value to custom profile field.
There was a bug here that would trigger an exception inside
`sync_user_profile_custom_fields`, causing it to get logged with
logging.warning, when an attribute configured for SAML custom profile
field sync was missing from a SAMLResponse or had an empty value.
`sync_user_profile_custom_fields` expects valid values, and None is not
valid.

We could consider a slightly different behavior here instead - when an
attribute is sent with no value in the SAMLResponse, that means the attr
has no value in the IdP's user directory - so perhaps a better behavior
would be to also remove the custom profile field value in Zulip. However
there are two issues with that:

1. It's not necessarily the best behavior, because an organization might
want the "user doesn't have this attribute set at the IdP level" state
to just mean that the user should be free to set the value manually in
Zulip if they wish. And having that value get reset on every login would
then be an issue. The implementation in this commit is consistent with
this philosophy.

2. There's some implementation difficulty - upstream
`self.get_attr(...)`, which we use for reading the attr value from the
SAMLResponse, doesn't distinguish between an attribute being sent with
no value and the attribute not being sent at all - in both cases it
returns None. So we'd need some extra work here with parsing the
SAMLResponse properly, to be able to know when the custom profile field
should get cleared.
2024-08-20 13:57:30 -07:00
..
actions scheduled_messages: Migrate to typed_endpoint. 2024-08-20 10:03:22 -07:00
data_import rocketchat: Fix "OSError: [Errno 36] File name too long" error. 2024-08-14 18:18:31 -07:00
integration_fixtures/nagios
lib scim: Extract ROLE_TYPE_TO_NAME dict to UserProfile. 2024-08-20 11:53:24 -07:00
management management: Add change_auth_backends command. 2024-08-14 14:04:46 -07:00
migrations user_groups: Add can_manage_group field in database. 2024-08-20 09:28:05 -07:00
models scim: Extract ROLE_TYPE_TO_NAME dict to UserProfile. 2024-08-20 11:53:24 -07:00
openapi user_groups: Add support to update can_manage_group setting. 2024-08-20 09:28:05 -07:00
tests saml: Fix exception when syncing missing value to custom profile field. 2024-08-20 13:57:30 -07:00
tornado events: Migrate to typed_endpoint. 2024-07-31 17:10:06 -07:00
transaction_tests ruff: Bump target-version from py38 to py310. 2024-07-13 22:28:22 -07:00
views saml: Add support for syncing user role. 2024-08-20 11:53:24 -07:00
webhooks integration-docs: Update Open Collective for new doc format. 2024-08-15 13:16:14 -07:00
worker thumbnail: Resolve a race condition when rendering messages. 2024-08-01 16:48:16 -07:00
__init__.py
apps.py ruff: Fix UP007 Use `X | Y` for type annotations. 2024-07-13 22:28:22 -07:00
context_processors.py ruff: Fix UP035 Import from `collections.abc`, `typing` instead. 2024-07-13 22:28:22 -07:00
decorator.py decorators: Migrate to typed_endpoint. 2024-08-20 10:15:30 -07:00
filters.py ruff: Fix UP007 Use `X | Y` for type annotations. 2024-07-13 22:28:22 -07:00
forms.py ruff: Fix UP007 Use `X | Y` for type annotations. 2024-07-13 22:28:22 -07:00
logging_handlers.py ruff: Fix UP007 Use `X | Y` for type annotations. 2024-07-13 22:28:22 -07:00
middleware.py ruff: Fix UP035 Import from `collections.abc`, `typing` instead. 2024-07-13 22:28:22 -07:00
signals.py ruff: Bump target-version from py38 to py310. 2024-07-13 22:28:22 -07:00