-
Notifications
You must be signed in to change notification settings - Fork 163
feat: Add RBAC Entity Creator #6413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| scope_id: ScopeId | ||
| entity_id: ObjectId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") | ||
|
|
||
|
|
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
84b3973 to
f8603c7
Compare
resolves #6417 (BA-2839)
Checklist: (if applicable)
ai.backend.testdocsdirectory