Add AuthStatusView for user login and data management#326
Add AuthStatusView for user login and data management#326
Conversation
Implement AuthStatusView for user authentication and data display.
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Adds AuthStatusView, a PyQt6-based dashboard for user authentication and data table browsing with the following features:
- Login form with username/password authentication via
/auth/loginendpoint - JWT token display with real-time expiration countdown
- Dynamic table selection from environment variable
TABLES_LIST - Table data loading and display with search/filter functionality
- Extensive
sip.isdeleted()checks to prevent crashes from deleted Qt widgets
Key Issues:
- Missing
PyJWTdependency inGUI/requirements.txt(line 3 importsjwt) - Authorization header will be malformed if API returns
Noneforaccess_token(line 175) - Direct use of
requests.postinstead ofself.api.httpwhich has retry logic (line 169)
Confidence Score: 3/5
- Safe to merge after fixing missing dependency and null token handling
- Score reflects one critical issue (missing PyJWT dependency will cause runtime ImportError) and one logic bug (None token will create malformed auth header). The defensive
sip.isdeleted()checks throughout show good Qt awareness. Style improvements recommended but not blocking. GUI/src/vast/views/auth_status_view.pyrequires adding PyJWT to requirements.txt and fixing null token handling on line 175
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| GUI/src/vast/views/auth_status_view.py | 3/5 | New PyQt6 dashboard for user authentication and table data viewing. Missing PyJWT dependency and has minor logic issue with None token handling. |
Sequence Diagram
sequenceDiagram
participant User
participant AuthStatusView
participant API
participant Backend
User->>AuthStatusView: Enter credentials & click Login
AuthStatusView->>Backend: POST /auth/login (username, password)
Backend-->>AuthStatusView: 200 OK (access_token, refresh_token)
AuthStatusView->>AuthStatusView: Decode JWT to extract expiry
AuthStatusView->>API: Update Authorization header
AuthStatusView->>User: Display tokens & success message
User->>AuthStatusView: Select table & click Load
AuthStatusView->>Backend: GET /api/tables/{table_name}
Backend-->>AuthStatusView: 200 OK (table data)
AuthStatusView->>AuthStatusView: Normalize & populate table
AuthStatusView->>User: Display data in QTableWidget
User->>AuthStatusView: Type in search box
AuthStatusView->>AuthStatusView: Filter cached data
AuthStatusView->>User: Display filtered results
loop Every 1 second
AuthStatusView->>AuthStatusView: Calculate token expiry time
AuthStatusView->>User: Update tooltip with remaining time
end
1 file reviewed, 4 comments
| @@ -0,0 +1,316 @@ | |||
|
|
|||
| from __future__ import annotations | |||
| import os, time, jwt, requests, json | |||
There was a problem hiding this comment.
syntax: jwt library (PyJWT) not in GUI/requirements.txt
| import os, time, jwt, requests, json | |
| import os, time, requests, json |
Add PyJWT to requirements.txt or remove JWT decoding (lines 177-180)
| try: | ||
| url = f"{self.api.base}/auth/login" | ||
| data = {"username": user, "password": password} | ||
| r = requests.post(url, data=data, timeout=10) |
There was a problem hiding this comment.
style: Uses requests.post directly instead of self.api.http which has retry logic, proper headers, and session management
| r = requests.post(url, data=data, timeout=10) | |
| r = self.api.http.post(url, data=data, timeout=10) |
| self.expiry_ts = payload.get("exp") | ||
| except Exception: | ||
| self.expiry_ts = None | ||
| msg_prefix = "✅ Access Token updated!\n\n" if old_token and self.access_token != old_token else "" |
There was a problem hiding this comment.
style: Checks if token differs from old, but emoji will show even on first login when old_token is None
| self.access_token = js.get("access_token") | ||
| self.refresh_token = js.get("refresh_token") | ||
| self.api.http.headers.update({"Authorization": f"Bearer {self.access_token}"}) |
There was a problem hiding this comment.
logic: If access_token is None from the API response, the authorization header will contain the string "None"
Add null check before updating header
Implement AuthStatusView for user authentication and data display.