[Full Stack] Implement Data Isolation by User (Multi-Tenancy)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 0
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Description:
This is the final and most critical step for multi-user support. Authentication alone is not enough; we must ensure that a user's data (their products, sales, etc.) is completely invisible and inaccessible to other users.
Tasks (Backend):
Entity Relationships: Add a @ManyToOne relationship to the User entity in all primary business entities: Product, Sale, Customer, Expense, Category, Provider.
Service Layer Refactoring: Modify all service methods (findAll, findById, create, update, delete) to always include a filter for the currently authenticated user's ID. The user can be retrieved from the SecurityContextHolder.
Example: productRepository.findByIdAndUserId(productId, userId).
When creating a new resource (e.g., createProduct), the authenticated User must be associated with it before saving.
Database Update: Ensure the database schema is updated (via ddl-auto: update in dev or a migration script) to add the new user_id foreign key columns.
Acceptance Criteria:
Test Scenario:
User A registers and logs in.
User A creates 3 products and 1 customer.
User A logs out.
User B registers and logs in.
User B navigates to the products page. They must see 0 products.
User B navigates to the customers page. They must see 0 customers.
An attempt by User A to directly access a resource owned by User B via the API (if the ID is known) must result in a 404 Not Found.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Product, Sale, Customer, Expense, Category, and Provider entities and their service methods, then inspect how SecurityContextHolder and the database schema are configured. Done means every listed resource is associated with its authenticated user, service operations are user-scoped, user_id relationships exist, and the described User A/User B scenario returns empty results and 404 for unauthorized access.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, postgresql, spring-boot
- Domain
- api, authentication, authorization, backend, database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100