feat: Add RBAC Entity Creator#6413
Conversation
| scope_id: ScopeId | ||
| entity_id: ObjectId |
There was a problem hiding this comment.
It's easy to miss this, so it would be good to apply the matters related to scope and entity as abstractmethod.
572c9c0 to
c00f6fe
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an RBAC (Role-Based Access Control) entity creator that manages the association between scopes and entities in the system. The implementation provides a reusable base class for creating RBAC-related database entries with proper conflict handling.
- Introduces
RBACCreatoras an abstract base class for RBAC entity creation operations - Implements automatic scope-entity association creation with conflict resolution
- Adds logging for integrity constraint violations during RBAC row creation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @abstractmethod | ||
| def scope_id(self) -> ScopeId: | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def object_id(self) -> ObjectId: | ||
| raise NotImplementedError | ||
|
|
||
|
|
||
| TCreatedEntity = TypeVar("TCreatedEntity") | ||
|
|
||
|
|
There was a problem hiding this comment.
The IntegrityError exception is caught after .on_conflict_do_nothing() is used, making this catch block unreachable. The on_conflict_do_nothing() clause prevents IntegrityError from being raised for conflicts. Remove the try-except block or remove the on_conflict_do_nothing() clause if you need to handle conflicts explicitly.
| @abstractmethod | |
| def scope_id(self) -> ScopeId: | |
| raise NotImplementedError | |
| @abstractmethod | |
| def object_id(self) -> ObjectId: | |
| raise NotImplementedError | |
| TCreatedEntity = TypeVar("TCreatedEntity") | |
| await db_session.execute( | |
| pg_insert(AssociationScopesEntitiesRow) | |
| .values(creator.fields_to_store()) | |
| .on_conflict_do_nothing() | |
| ) |
c00f6fe to
f068e50
Compare
f068e50 to
84b3973
Compare
cecf94f to
9e5097e
Compare
9e5097e to
f407ed5
Compare
1a10632 to
2d8c9ea
Compare
f407ed5 to
4865ecb
Compare
Co-authored-by: octodog <mu001@lablup.com>
9552aac to
4af738e
Compare
|
Closed this PR because #7581 covers the same issue |
resolves #6417 (BA-2839)
Checklist: (if applicable)
ai.backend.testdocsdirectory