authentik.sources.scim.views.v2.exceptions
1from enum import Enum 2 3from pydanticscim.responses import SCIMError as BaseSCIMError 4from rest_framework.exceptions import ValidationError 5 6 7class SCIMErrorTypes(Enum): 8 invalid_filter = "invalidFilter" 9 too_many = "tooMany" 10 uniqueness = "uniqueness" 11 mutability = "mutability" 12 invalid_syntax = "invalidSyntax" 13 invalid_path = "invalidPath" 14 no_target = "noTarget" 15 invalid_value = "invalidValue" 16 invalid_vers = "invalidVers" 17 sensitive = "sensitive" 18 19 20class SCIMError(BaseSCIMError): 21 scimType: SCIMErrorTypes | None = None 22 detail: str | None = None 23 24 25class SCIMValidationError(ValidationError): 26 status_code = 400 27 default_detail = SCIMError(scimType=SCIMErrorTypes.invalid_syntax, status=400) 28 29 def __init__(self, detail: SCIMError | None): 30 if detail is None: 31 detail = self.default_detail 32 detail.status = self.status_code 33 self.detail = detail.model_dump(mode="json", exclude_none=True) 34 35 36class SCIMConflictError(SCIMValidationError): 37 status_code = 409 38 39 def __init__(self, detail: str): 40 super().__init__( 41 SCIMError( 42 detail=detail, 43 scimType=SCIMErrorTypes.uniqueness, 44 status=self.status_code, 45 ) 46 ) 47 48 49class SCIMNotFoundError(SCIMValidationError): 50 status_code = 404 51 52 def __init__(self, detail: str): 53 super().__init__( 54 SCIMError( 55 detail=detail, 56 status=self.status_code, 57 ) 58 )
class
SCIMErrorTypes(enum.Enum):
8class SCIMErrorTypes(Enum): 9 invalid_filter = "invalidFilter" 10 too_many = "tooMany" 11 uniqueness = "uniqueness" 12 mutability = "mutability" 13 invalid_syntax = "invalidSyntax" 14 invalid_path = "invalidPath" 15 no_target = "noTarget" 16 invalid_value = "invalidValue" 17 invalid_vers = "invalidVers" 18 sensitive = "sensitive"
invalid_filter =
<SCIMErrorTypes.invalid_filter: 'invalidFilter'>
too_many =
<SCIMErrorTypes.too_many: 'tooMany'>
uniqueness =
<SCIMErrorTypes.uniqueness: 'uniqueness'>
mutability =
<SCIMErrorTypes.mutability: 'mutability'>
invalid_syntax =
<SCIMErrorTypes.invalid_syntax: 'invalidSyntax'>
invalid_path =
<SCIMErrorTypes.invalid_path: 'invalidPath'>
no_target =
<SCIMErrorTypes.no_target: 'noTarget'>
invalid_value =
<SCIMErrorTypes.invalid_value: 'invalidValue'>
invalid_vers =
<SCIMErrorTypes.invalid_vers: 'invalidVers'>
sensitive =
<SCIMErrorTypes.sensitive: 'sensitive'>
class
SCIMError(pydanticscim.responses.SCIMError):
21class SCIMError(BaseSCIMError): 22 scimType: SCIMErrorTypes | None = None 23 detail: str | None = None
!!! abstract "Usage Documentation" Models
A base class for creating Pydantic models.
Attributes:
__class_vars__: The names of the class variables defined on the model.
__private_attributes__: Metadata about the private attributes of the model.
__signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.
__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
__args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.
__pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
__pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
class
SCIMValidationError(rest_framework.exceptions.ValidationError):
26class SCIMValidationError(ValidationError): 27 status_code = 400 28 default_detail = SCIMError(scimType=SCIMErrorTypes.invalid_syntax, status=400) 29 30 def __init__(self, detail: SCIMError | None): 31 if detail is None: 32 detail = self.default_detail 33 detail.status = self.status_code 34 self.detail = detail.model_dump(mode="json", exclude_none=True)
Base class for REST framework exceptions.
Subclasses should provide .status_code and .default_detail properties.
SCIMValidationError(detail: SCIMError | None)
default_detail =
SCIMError(detail=None, status=400, schemas=('urn:ietf:params:scim:api:messages:2.0:Error',), scimType=<SCIMErrorTypes.invalid_syntax: 'invalidSyntax'>)
37class SCIMConflictError(SCIMValidationError): 38 status_code = 409 39 40 def __init__(self, detail: str): 41 super().__init__( 42 SCIMError( 43 detail=detail, 44 scimType=SCIMErrorTypes.uniqueness, 45 status=self.status_code, 46 ) 47 )
Base class for REST framework exceptions.
Subclasses should provide .status_code and .default_detail properties.
Inherited Members
50class SCIMNotFoundError(SCIMValidationError): 51 status_code = 404 52 53 def __init__(self, detail: str): 54 super().__init__( 55 SCIMError( 56 detail=detail, 57 status=self.status_code, 58 ) 59 )
Base class for REST framework exceptions.
Subclasses should provide .status_code and .default_detail properties.