Repository navigation
Fixes for test task - #244
Open
JuliaDvirnik wants to merge 1 commit into
Open
JuliaDvirnik wants to merge 1 commit into
JuliaDvirnik wants to merge 1 commit into
Conversation
- added greenland to requirements - fixed DB connection pool - use 1 shared pull instead of 1 per request 2. Fixes for client privacy: - added tenant in cache key - added new endpoint dashboard/properties to fix the list of properties - removed fake-data fallback - removed 'default tenant' - property ownership check - DB level isolation with low-level security - removed X-Simulated-Tenant header - closed unauthenticated endpoints 3. Accuracy: - revenue by month and year in property timezone - switched from float to decimal - used real currency
Comment on lines
159
to
169
| user: AuthenticatedUser = Depends(authenticate_request) | ||
| ): | ||
| """Get departments for a specific user""" | ||
| if user_id != user.id and not user.is_admin: | ||
| raise HTTPException( | ||
| status_code=status.HTTP_403_FORBIDDEN, | ||
| detail="Not allowed to view another user's departments" | ||
| ) | ||
| try: | ||
| departments = await get_user_departments(user_id) | ||
| # Return just the department IDs for simplicity |
There was a problem hiding this comment.
Bug: Administrators without a statically mapped tenant receive tokens with null tenant_id, causing immediate 403 errors on tenant-dependent dashboard endpoints.
Severity: HIGH
Suggested Fix
Update TenantResolver.resolve_tenant_id or authenticate_request to derive tenant_id from database associations such as user_tenants or token metadata, or permit admin bypass / tenant selection in dashboard endpoints.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: backend/app/api/v1/auth_info.py#L159-L169
Potential issue: `TenantResolver.resolve_tenant_id` does not resolve tenant IDs for
database-backed users and only returns tenants for hardcoded emails. While `login.py`
permits administrators to log in when `tenant_id` is null, their issued token lacks a
`tenant_id`. Consequently, subsequent requests to dashboard endpoints like
`/dashboard/properties` and `/dashboard/summary` fail with a 403 Forbidden error because
`get_user_tenant_id` requires a non-null `tenant_id` and does not check administrator
privileges.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed bugs:
TODO (What i have found but don't fix):