squad 1.85__py3-none-any.whl → 1.86__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
squad/api/__init__.py CHANGED
@@ -0,0 +1,40 @@
1
+ from django.core.cache import cache
2
+ from rest_framework.throttling import UserRateThrottle
3
+
4
+
5
+ class SocialUserRateThrottle(UserRateThrottle):
6
+ """
7
+ Limits the rate of API calls that may be made by a given social user.
8
+
9
+ The user id will be used as a unique cache key if the user is
10
+ authenticated. For anonymous requests, the IP address of the request will
11
+ be used.
12
+ """
13
+
14
+ scope = "socialuser"
15
+
16
+ def is_social_user(self, user):
17
+ """
18
+ Social account user might use multiple applications (github, gitlab, google, ...)
19
+ to log in. But all of the login applications would likely point to the same
20
+ django user, which is what we want to rate limit here.
21
+ """
22
+
23
+ key = f"socialuser#{user.id}"
24
+ from allauth.socialaccount.models import SocialAccount
25
+ return cache.get_or_set(key, SocialAccount.objects.filter(user_id=user.id).exists())
26
+
27
+ def get_cache_key(self, request, view):
28
+ if request.user and request.user.is_authenticated:
29
+ if not self.is_social_user(request.user):
30
+ # do not throttle non-social users
31
+ return None
32
+
33
+ ident = request.user.pk
34
+ else:
35
+ ident = self.get_ident(request)
36
+
37
+ return self.cache_format % {
38
+ "scope": self.scope,
39
+ "ident": ident
40
+ }
squad/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '1.85'
1
+ __version__ = '1.86'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: squad
3
- Version: 1.85
3
+ Version: 1.86
4
4
  Summary: Software Quality Dashboard
5
5
  Home-page: https://github.com/Linaro/squad
6
6
  Author: Antonio Terceiro
@@ -10,9 +10,9 @@ squad/manage.py,sha256=Z-LXT67p0R-IzwJ9fLIAacEZmU0VUjqDOSg7j2ZSxJ4,1437
10
10
  squad/settings.py,sha256=Wzg1nS96OKZ38qEXtIat9XaZc1HigUJr3ktMuwVhf98,14546
11
11
  squad/socialaccount.py,sha256=vySqPwQ3qVVpahuJ-Snln8K--yzRL3bw4Nx27AsB39A,789
12
12
  squad/urls.py,sha256=JiEfVW8YlzLPE52c2aHzdn5kVVKK4o22w8h5KOA6QhQ,2776
13
- squad/version.py,sha256=XHedXngbS7mTJ6PRZZiqQufUZV1aZtCSDF-zEyvtXKg,21
13
+ squad/version.py,sha256=B5Hli1uR7QsAdJy0glyOu0dG5vGx5eLeZvCrssNL1xI,21
14
14
  squad/wsgi.py,sha256=SF8T0cQ0OPVyuYjO5YXBIQzvSXQHV0M2BTmd4gP1rPs,387
15
- squad/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ squad/api/__init__.py,sha256=CJiVakfAlHVN5mIFRVQYZQfuNUhUgWVbsdYTME4tq7U,1349
16
16
  squad/api/apps.py,sha256=Trk72p-iV1uGn0o5mdJn5HARUoHGbfgO49jwXvpkmdQ,141
17
17
  squad/api/ci.py,sha256=ymG-eMKXpJgrVUiZcqJW-dYZQKvm1LkdR3TUMe4OSoM,6943
18
18
  squad/api/data.py,sha256=obKDV0-neEvj5lPF9VED2gy_hpfhGtLJABYvSY38ing,2379
@@ -431,9 +431,9 @@ squad/run/__main__.py,sha256=DOl8JOi4Yg7DdtwnUeGqtYBJ6P2k-D2psAEuYOjWr8w,66
431
431
  squad/run/listener.py,sha256=jBeOQhPGb4EdIREB1QsCzYuumsfJ-TqJPd3nR-0m59g,200
432
432
  squad/run/scheduler.py,sha256=CDJG3q5C0GuQuxwlMOfWTSSJpDdwbR6rzpbJfuA0xuw,277
433
433
  squad/run/worker.py,sha256=jtML0h5qKDuSbpJ6_rpWP4MT_rsGA7a24AhwGxBquzk,594
434
- squad-1.85.dist-info/COPYING,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
435
- squad-1.85.dist-info/METADATA,sha256=1m8I9voN8Y6StBv8TUFvk2-eFN-EZegBK9YTNy7jXTI,1234
436
- squad-1.85.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
437
- squad-1.85.dist-info/entry_points.txt,sha256=apCDQydHZtvqV334ql6NhTJUAJeZRdtAm0TVcbbAi5Q,194
438
- squad-1.85.dist-info/top_level.txt,sha256=_x9uqE1XppiiytmVTl_qNgpnXus6Gsef69HqfliE7WI,6
439
- squad-1.85.dist-info/RECORD,,
434
+ squad-1.86.dist-info/COPYING,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
435
+ squad-1.86.dist-info/METADATA,sha256=C2Kk_VUQaTRcbivU7miMLSuAnl_bkCHbQ9LoQ4BbKbQ,1234
436
+ squad-1.86.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
437
+ squad-1.86.dist-info/entry_points.txt,sha256=apCDQydHZtvqV334ql6NhTJUAJeZRdtAm0TVcbbAi5Q,194
438
+ squad-1.86.dist-info/top_level.txt,sha256=_x9uqE1XppiiytmVTl_qNgpnXus6Gsef69HqfliE7WI,6
439
+ squad-1.86.dist-info/RECORD,,
File without changes
File without changes