Files
zulip/zerver/lib/types.py
Mateusz Mandera c54b48452d saml: Support syncing custom profile fields with SAML attributes.
Fixes #17277.

The main limitation of this implementation is that the sync happens if
the user authing already exists. This means that a new user going
through the sign up flow will not have their custom fields synced upon
finishing it. The fields will get synced on their consecutive log in via
SAML in the future. This can be addressed in the future by moving the
syncing code further down the codepaths to login_or_register_remote_user
and plumbing the data through to the user creation process.

We detail that limitation in the documentation.
2021-06-08 14:47:33 -07:00

71 lines
1.8 KiB
Python

from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union
from django.http import HttpResponse
from django.utils.functional import Promise
from typing_extensions import TypedDict
ViewFuncT = TypeVar("ViewFuncT", bound=Callable[..., HttpResponse])
# See zerver/lib/validator.py for more details of Validators,
# including many examples
ResultT = TypeVar("ResultT")
Validator = Callable[[str, object], ResultT]
ExtendedValidator = Callable[[str, str, object], str]
RealmUserValidator = Callable[[int, object, bool], List[int]]
class ProfileDataElementBase(TypedDict):
id: int
name: str
type: int
hint: Optional[str]
field_data: Optional[str]
order: int
class ProfileDataElement(ProfileDataElementBase):
value: str
rendered_value: Optional[str]
ProfileData = List[ProfileDataElement]
FieldElement = Tuple[int, Promise, Validator[Union[int, str, List[int]]], Callable[[Any], Any], str]
ExtendedFieldElement = Tuple[int, Promise, ExtendedValidator, Callable[[Any], Any], str]
UserFieldElement = Tuple[int, Promise, RealmUserValidator, Callable[[Any], Any], str]
ProfileFieldData = Dict[str, Union[Dict[str, str], str]]
class UserDisplayRecipient(TypedDict):
email: str
full_name: str
id: int
is_mirror_dummy: bool
DisplayRecipientT = Union[str, List[UserDisplayRecipient]]
class LinkifierDict(TypedDict):
pattern: str
url_format: str
id: int
class SAMLIdPConfigDict(TypedDict, total=False):
entity_id: str
url: str
attr_user_permanent_id: str
attr_first_name: str
attr_last_name: str
attr_username: str
attr_email: str
attr_org_membership: str
display_name: str
display_icon: str
limit_to_subdomains: List[str]
extra_attrs: List[str]
x509cert: str
x509cert_path: str