-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: revert back to use security manager authz for dashboard when get by uuid #23330
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
83e377c
fix: when getting dashboard by uuid, we should use the previous secur…
67f2a5e
using try/except to handle negative int for dashboard id
044603e
pretty
0f747da
fixed id_or_slug_filter for slug,uuid or relationship
98d236c
fixed lint
e1fefcd
fixed lint
0731dfe
also applying DashboardFilter to slug
bdd2abf
cleanup
627cc10
fixed tests
49d07c0
lint
96ea88c
dummy
532a7fd
fixed lint again
732e9ef
adding api tests for get dashboard by uuid
2991530
dummy
c117aaa
dummy
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
import json | ||
import logging | ||
import uuid | ||
from collections import defaultdict | ||
from functools import partial | ||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union | ||
|
@@ -450,11 +451,27 @@ def get(cls, id_or_slug: Union[str, int]) -> Dashboard: | |
return qry.one_or_none() | ||
|
||
|
||
def is_uuid(value: Union[str, int]) -> bool: | ||
try: | ||
uuid.UUID(str(value)) | ||
return True | ||
except ValueError: | ||
return False | ||
|
||
|
||
def is_int(value: Union[str, int]) -> bool: | ||
try: | ||
int(value) | ||
return True | ||
except ValueError: | ||
return False | ||
|
||
|
||
def id_or_slug_filter(id_or_slug: Union[int, str]) -> BinaryExpression: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we change this method name also? |
||
if isinstance(id_or_slug, int): | ||
return Dashboard.id == id_or_slug | ||
if id_or_slug.isdigit(): | ||
if is_int(id_or_slug): | ||
return Dashboard.id == int(id_or_slug) | ||
if is_uuid(id_or_slug): | ||
return Dashboard.uuid == uuid.UUID(str(id_or_slug)) | ||
return Dashboard.slug == id_or_slug | ||
|
||
|
||
|
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we change this method name to
get_by_id_slug_or_uuid
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a better naming could just be
get_by_identifier
but it could touches too many files if we want to change everyid_or_slug
toidentifier
. Note that uuid is also id in general though. So I think this naming should be fine.