-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[WIKI-419] chore: new asset duplicate endpoint added #7172
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
Changes from 44 commits
d52cce1
0e369f8
9704f21
cdd6a7b
3cb427f
8605789
f8df5c0
c54aa7a
96f95ac
8ad1529
992dac3
9fc0fa7
10bca48
fe68d0f
155857c
7b116b7
4a06133
5670144
94e8763
66abe90
8fdef1b
60c28b0
6a2ab08
203ef14
ee9a19a
76921fb
919d49d
f08bbfc
2d4318b
2b0f0ef
ff28596
60bb7e0
eb588d6
2bed639
1a88225
426d5f3
334074d
098a753
c0ebe35
af96742
548e060
bb43f2f
9de753f
0b40e6d
d420ce7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,14 @@ | |
|
|
||
| # Rest Framework settings | ||
| REST_FRAMEWORK = { | ||
| "DEFAULT_AUTHENTICATION_CLASSES": ("rest_framework.authentication.SessionAuthentication",), | ||
| "DEFAULT_AUTHENTICATION_CLASSES": ( | ||
| "rest_framework.authentication.SessionAuthentication", | ||
| ), | ||
| "DEFAULT_THROTTLE_CLASSES": ("rest_framework.throttling.AnonRateThrottle",), | ||
|
Contributor
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. 🧩 Analysis chainVerify impact on existing anonymous endpoints Adding 🏁 Script executed: #!/bin/bash
# Description: Find endpoints that allow anonymous access by searching for permission_classes overrides
# Search for AllowAny, IsAuthenticatedOrReadOnly, and custom permission classes
rg -n -C3 --type=py 'permission_classes\s*=.*\b(AllowAny|IsAuthenticatedOrReadOnly)\b' -g '!**/test/**' -g '!**/tests/**'
# Also check for views that explicitly allow anonymous access
rg -n -C3 --type=py 'authentication_classes\s*=\s*\[\s*\]' -g '!**/test/**' -g '!**/tests/**'Length of output: 15033 🏁 Script executed: #!/bin/bash
# Find AllowAny endpoints and check if they have custom throttle_classes in the same view
# Get all files with AllowAny permission
files=$(rg -l --type=py 'permission_classes.*AllowAny' -g '!**/test/**' -g '!**/tests/**')
echo "=== AllowAny endpoints without custom throttle_classes ==="
for file in $files; do
# Check if file has both AllowAny and throttle_classes on same view
if rg -U --type=py '(?s)class\s+\w+.*?permission_classes.*?AllowAny.*?^\s*$' "$file" | grep -q 'throttle_classes'; then
continue
else
# Print the class name and surrounding context
rg -n -B2 -A5 --type=py 'permission_classes.*AllowAny' "$file"
echo "---"
fi
done | head -100Length of output: 2929 🏁 Script executed: #!/bin/bash
# Find the DEFAULT_THROTTLE_RATES setting to see the actual rate limit
echo "=== DEFAULT_THROTTLE_RATES configuration ==="
rg -n -A10 'DEFAULT_THROTTLE_RATES' apps/api/plane/settings/common.py
echo -e "\n=== DEFAULT_THROTTLE_CLASSES context ==="
rg -n -B5 -A5 'DEFAULT_THROTTLE_CLASSES' apps/api/plane/settings/common.pyLength of output: 1131 🏁 Script executed: #!/bin/bash
# Check the DEFAULT_THROTTLE_RATES configuration
echo "=== Finding DEFAULT_THROTTLE_RATES ==="
rg -n -B3 -A8 "DEFAULT_THROTTLE_RATES" apps/api/plane/settings/common.py
echo -e "\n=== Also check if there's a 'anon' rate defined ==="
rg -n "'anon'" apps/api/plane/settings/common.pyLength of output: 800 Add custom throttle_classes to critical endpoints that lack protection Adding
These should either override 🤖 Prompt for AI Agents |
||
| "DEFAULT_THROTTLE_RATES": { | ||
| "anon": "30/minute", | ||
| "asset_id": "5/minute", | ||
| }, | ||
| "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",), | ||
| "DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",), | ||
| "DEFAULT_FILTER_BACKENDS": ("django_filters.rest_framework.DjangoFilterBackend",), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from rest_framework.throttling import SimpleRateThrottle | ||
|
|
||
|
|
||
| class AssetRateThrottle(SimpleRateThrottle): | ||
| scope = "asset_id" | ||
|
|
||
| def get_cache_key(self, request, view): | ||
| asset_id = view.kwargs.get("asset_id") | ||
| if not asset_id: | ||
| return None | ||
| return f"throttle_asset_{asset_id}" |
Uh oh!
There was an error while loading. Please reload this page.