codeant-ai-for-open-source[bot] commented on code in PR #40676:
URL: https://github.com/apache/superset/pull/40676#discussion_r3384762610


##########
superset/security/manager.py:
##########
@@ -3681,6 +3684,43 @@ def get_guest_user_from_request(self, req: Request) -> 
Optional[GuestUser]:
 
         return self.get_guest_user_from_token(cast(GuestToken, token))
 
+    @staticmethod
+    def _is_guest_token_revoked(token: dict[str, Any]) -> bool:
+        """Return True if the token predates a revocation on any of its
+        embedded-dashboard resources (``guest_token_revoked_before``)."""
+        issued_at = token.get("iat")
+        if not issued_at:
+            return False
+
+        # pylint: disable=import-outside-toplevel
+        from superset.daos.dashboard import EmbeddedDashboardDAO
+
+        for resource in token.get("resources") or []:
+            if resource.get("type") != GuestTokenResourceType.DASHBOARD.value:
+                continue
+            embedded = EmbeddedDashboardDAO.find_by_id(str(resource.get("id")))
+            revoked_before = getattr(embedded, "guest_token_revoked_before", 
None)
+            if revoked_before is not None and issued_at < revoked_before:

Review Comment:
   **🟠 Architect Review — HIGH**
   
   Guest-token revocation only looks up embedded dashboards by UUID via 
EmbeddedDashboardDAO.find_by_id(resource["id"]), so tokens whose dashboard 
resources still carry a dashboard ID (not an embedded UUID) never see a 
guest_token_revoked_before cutoff and remain valid until exp.
   
   **Suggestion:** Align _is_guest_token_revoked with the existing 
resource-resolution pattern (Dashboard.get(...) fallback to 
EmbeddedDashboardDAO.find_by_id(...)), so revocation consults 
guest_token_revoked_before for both dashboard-ID and embedded-UUID resources 
during the UUID migration period.
   
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5c986fd005714ff99883ded45c9f9b37&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=5c986fd005714ff99883ded45c9f9b37&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is an **Architect / Logical Review** comment left during a code review. 
These reviews are first-class, important findings — not optional suggestions. 
Do NOT dismiss this as a 'big architectural change' just because the title says 
architect review; most of these can be resolved with a small, localized fix 
once the intent is understood.
   
   **Path:** superset/security/manager.py
   **Line:** 3698:3703
   **Comment:**
        *HIGH: Guest-token revocation only looks up embedded dashboards by UUID 
via EmbeddedDashboardDAO.find_by_id(resource["id"]), so tokens whose dashboard 
resources still carry a dashboard ID (not an embedded UUID) never see a 
guest_token_revoked_before cutoff and remain valid until exp.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   If a suggested approach is provided above, use it as the authoritative 
instruction. If no explicit code suggestion is given, you MUST still draft and 
apply your own minimal, localized fix — do not punt back with 'no suggestion 
provided, review manually'. Keep the change as small as possible: add a guard 
clause, gate on a loading state, reorder an await, wrap in a conditional, etc. 
Do not refactor surrounding code or expand scope beyond the finding.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to