From 7734ed185ef63ed8801565f65288186d4bdeb07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Fri, 5 Apr 2024 16:05:17 +0200 Subject: [PATCH] refactor: the id attribute is attached to the Model class --- canaille/backends/models.py | 18 ++++++++++++++++++ canaille/core/models.py | 34 ---------------------------------- canaille/oidc/basemodels.py | 4 ---- 3 files changed, 18 insertions(+), 38 deletions(-) diff --git a/canaille/backends/models.py b/canaille/backends/models.py index 14133511..6cd39ab9 100644 --- a/canaille/backends/models.py +++ b/canaille/backends/models.py @@ -11,6 +11,24 @@ class Model: It details all the common attributes shared by every models. """ + id: Optional[str] + """A unique identifier for a SCIM resource as defined by the service + provider. Id will be :py:data:`None` until the + :meth:`~canaille.backends.models.BackendModel.save` method is called. + + Each representation of the resource MUST include a non-empty "id" + value. This identifier MUST be unique across the SCIM service + provider's entire set of resources. It MUST be a stable, non- + reassignable identifier that does not change when the same resource + is returned in subsequent requests. The value of the "id" attribute + is always issued by the service provider and MUST NOT be specified + by the client. The string "bulkId" is a reserved keyword and MUST + NOT be used within any unique identifier value. The attribute + characteristics are "caseExact" as "true", a mutability of + "readOnly", and a "returned" characteristic of "always". See + Section 9 for additional considerations regarding privacy. + """ + created: Optional[datetime.datetime] """The :class:`~datetime.datetime` that the resource was added to the service provider.""" diff --git a/canaille/core/models.py b/canaille/core/models.py index 903b7eee..f9967ac1 100644 --- a/canaille/core/models.py +++ b/canaille/core/models.py @@ -19,23 +19,6 @@ class User(Model): implementation in Canaille. """ - id: str - """A unique identifier for a SCIM resource as defined by the service - provider. - - Each representation of the resource MUST include a non-empty "id" - value. This identifier MUST be unique across the SCIM service - provider's entire set of resources. It MUST be a stable, non- - reassignable identifier that does not change when the same resource - is returned in subsequent requests. The value of the "id" attribute - is always issued by the service provider and MUST NOT be specified - by the client. The string "bulkId" is a reserved keyword and MUST - NOT be used within any unique identifier value. The attribute - characteristics are "caseExact" as "true", a mutability of - "readOnly", and a "returned" characteristic of "always". See - Section 9 for additional considerations regarding privacy. - """ - user_name: str """A service provider's unique identifier for the user, typically used by the user to directly authenticate to the service provider. @@ -304,23 +287,6 @@ class Group(Model): `_. """ - id: str - """A unique identifier for a SCIM resource as defined by the service - provider. - - Each representation of the resource MUST include a non-empty "id" - value. This identifier MUST be unique across the SCIM service - provider's entire set of resources. It MUST be a stable, non- - reassignable identifier that does not change when the same resource - is returned in subsequent requests. The value of the "id" attribute - is always issued by the service provider and MUST NOT be specified - by the client. The string "bulkId" is a reserved keyword and MUST - NOT be used within any unique identifier value. The attribute - characteristics are "caseExact" as "true", a mutability of - "readOnly", and a "returned" characteristic of "always". See - Section 9 for additional considerations regarding privacy. - """ - display_name: str """A human-readable name for the Group. diff --git a/canaille/oidc/basemodels.py b/canaille/oidc/basemodels.py index a5c56aba..cacb4f8c 100644 --- a/canaille/oidc/basemodels.py +++ b/canaille/oidc/basemodels.py @@ -16,7 +16,6 @@ class Client(Model): specifications. """ - id: str description: Optional[str] = None preconsent: Optional[bool] = False audience: List["Client"] = [] @@ -289,7 +288,6 @@ class Client(Model): class AuthorizationCode(Model): """OpenID Connect temporary authorization code definition.""" - id: str authorization_code_id: str code: str client: "Client" @@ -308,7 +306,6 @@ class AuthorizationCode(Model): class Token(Model): """OpenID Connect token definition.""" - id: str token_id: str access_token: str client: "Client" @@ -325,7 +322,6 @@ class Token(Model): class Consent(Model): """Long-term user consent to an application.""" - id: str consent_id: str subject: User client: "Client"