This report performs a deep-dive audit of the Hub's user and group identity models in user.py, focusing on Account Security, Group Isolation, and Preference Consistency.
| Factor | Status | Observation |
|---|---|---|
| III. Config | ✅ Success | Role Sanitization: The default role of user (Line 29) correctly follows the principle of least privilege, ensuring that new OIDC-registered accounts do not gain administrative access by default. |
| VI. Processes | 🟡 Warning | Flattened Preference Blob: The preferences column (Line 34) is a single JSON field. While flexible, this pattern is susceptible to "Last-Writer-Wins" data loss if a user has multiple concurrent browser tabs open updating different preference subsections (like "Custom CSS" vs "LLM Providers"). |
app/db/models/user.pyThe source of truth for user identity, credentials, and organizational memberships.
[!CAUTION] Relational Inconsistency Hazard (Groups) Line 30:
group_id = Column(String, ForeignKey('groups.id'), nullable=True)There is no explicitondeleteconstraint. If aGroupis deleted via a direct SQL query or a low-level DB tool, theUsertable will contain invalidgroup_idstrings (dangling pointers).Recommendation: Set
ondelete="SET NULL"for thegroup_idforeign key and implement an application-level "Default Group" (e.g.,ungrouped) to ensure all users always belong to a valid organizational policy.
Identified Problems:
password_hash field (Line 27) should be omitted from any generic model_dump using Pydantic to prevent accidental leakage in user-profile endpoints.email (Line 25) should likely be unique for the "Local Login" flow, it is not marked as unique=True. This could lead to account duplication and credential confusion in certain Hub configurations.group_id relationship with ondelete="SET NULL" to maintain database referential integrity during bulk organizational restructuring.email column as unique=True to prevent the creation of duplicate accounts that share the same identity during OIDC resolution.preferences blob (using jsonb_set for Postgres or similar logic) to handle concurrent sub-preference changes safely.This concludes Feature 25. I have persisted this report to /app/docs/reviews/feature_review_identity_models.md. Shall I proceed to audit the Asset and Node models?