django-restit 4.2.75__py3-none-any.whl → 4.2.77__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.
account/models/member.py CHANGED
@@ -720,6 +720,10 @@ class Member(User, RestModel, MetaDataModel):
720
720
  self.security_token = crypto.randomString(8)
721
721
  self.save()
722
722
 
723
+ def forceLogout(self):
724
+ self.refreshSecurityToken()
725
+ self.sendEvent("logged_out", "Your user session has been terminated.")
726
+
723
727
  def generateAuthCode(self, length=6, expires=AUTH_CODE_EXPIRES_SECS):
724
728
  for i in range(0, 100):
725
729
  code = crypto.randomCode(length)
@@ -880,8 +884,8 @@ class Member(User, RestModel, MetaDataModel):
880
884
  if token is None:
881
885
  token = AuthToken(member=self, role="default")
882
886
  token.generateToken()
883
- elif action == "refresh_keys":
884
- self.refreshSecurityToken()
887
+ elif action == "refresh_keys" or action == "force_logout":
888
+ self.forceLogout()
885
889
 
886
890
  def set_full_name(self, value):
887
891
  self.set_name(value)
@@ -1217,7 +1221,7 @@ class Member(User, RestModel, MetaDataModel):
1217
1221
  rh.log_print("no session for key", key)
1218
1222
  return None
1219
1223
  session_data = session.get_decoded()
1220
- rh.log_print(session_data)
1224
+ # rh.log_print(session_data)
1221
1225
  uid = session_data.get('_auth_user_id', None)
1222
1226
  if uid is None:
1223
1227
  return None
account/rpc/auth.py CHANGED
@@ -13,6 +13,7 @@ from datetime import datetime, timedelta
13
13
 
14
14
  ALLOW_BASIC_LOGIN = settings.get("ALLOW_BASIC_LOGIN", False)
15
15
  FORGET_ALWAYS_TRUE = settings.get("FORGET_ALWAYS_TRUE", True)
16
+ JWT_UPDATE_REFRESH_TOKEN = settings.get("JWT_UPDATE_REFRESH_TOKEN", False)
16
17
 
17
18
 
18
19
  @rd.urlPOST(r'^login$')
@@ -122,7 +123,9 @@ def jwt_refresh(request):
122
123
  member.canLogin(request)
123
124
  token.refresh()
124
125
  request.jwt_token = token.access_token # this tells the middleware to store in cookie
125
- return rv.restGet(request, dict(access=token.access_token, refresh=token.refresh_token))
126
+ if JWT_UPDATE_REFRESH_TOKEN:
127
+ rtoken = token.refresh_token
128
+ return rv.restGet(request, dict(access=token.access_token, refresh=rtoken))
126
129
 
127
130
 
128
131
  def getMemberByUsername(username):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-restit
3
- Version: 4.2.75
3
+ Version: 4.2.77
4
4
  Summary: A Rest Framework for DJANGO
5
5
  License: MIT
6
6
  Author: Ian Starnes
@@ -28,7 +28,7 @@ account/models/device.py,sha256=TloXvvrx3khF3BeGFuVYn6DhXjOW0AMZb4F9Fl5nBII,5491
28
28
  account/models/feeds.py,sha256=vI7fG4ASY1M0Zjke24RdnfDcuWeATl_yR_25jPmT64g,2011
29
29
  account/models/group.py,sha256=iDD_oSgswKV_t_gXZuVK80MvICrZZqdANm2jtGtOFy8,21985
30
30
  account/models/legacy.py,sha256=zYdtv4LC0ooxPVqWM-uToPwV-lYWQLorSE6p6yn1xDw,2720
31
- account/models/member.py,sha256=VoMxjh4p6y9nDhTBX8O571RQD16wEesG8K4z10ran1o,52796
31
+ account/models/member.py,sha256=v2cM7g5XoOQi_ZAlGcOcKn24zZCfAFokxUFIqNshDxc,52960
32
32
  account/models/membership.py,sha256=90EpAhOsGaqphDAkONP6j_qQ0OWSRaQsI8H7E7fgMkE,9249
33
33
  account/models/notify.py,sha256=Qzi8gLsVi8nDx8gpL4dyr0MPExYYGIDxZvHFUdCs7H4,15072
34
34
  account/models/passkeys.py,sha256=TJxITUi4DT4_1tW2K7ZlOcRjJuMVl2NtKz7pKQU8-Tw,1516
@@ -40,7 +40,7 @@ account/passkeys/__init__.py,sha256=FwXYJXwSJXfkLojGBcVpF1dFpgFhzDdd9N_3naYQ0cc,
40
40
  account/passkeys/core.py,sha256=xj-vXjSrfWDvc5MYtEmXzwaMkNHl-cXrQKVrN9soRCg,4126
41
41
  account/periodic.py,sha256=-u0n-7QTJgDOkasGhBAPwHAwjpqWGA-MZLEFkVTqCGU,874
42
42
  account/rpc/__init__.py,sha256=SGF0M_-H0dKh3b1apSX29BotNWAvITYccGQVC0MIjL8,336
43
- account/rpc/auth.py,sha256=3BJMQZ6dxE0U3HvFbedx0kBGzLzZjP8XkkcUcBobRTk,16483
43
+ account/rpc/auth.py,sha256=p62tyihWvSY2zn7eaVxKcCG9qLnnZBIkwdRH81sS5_Y,16615
44
44
  account/rpc/device.py,sha256=mB14a6qvJIBnCa9ivLhPXwEt5Gk2foyqsKBtZxC506k,3070
45
45
  account/rpc/group.py,sha256=FD9GymgPY68y-gtDLsZxYVdwQJeLGpqcP4hjcDUh-GM,4022
46
46
  account/rpc/member.py,sha256=VNRSD38mmTUCbq3cCSy3qRyquzeVEwW_8zzrtS0-vAA,1817
@@ -386,7 +386,7 @@ rest/fields.py,sha256=_v1TJVc6vyWlqmwFRJ6mtuR5Fo-lS0KcUhPWIrzKZUo,9719
386
386
  rest/forms.py,sha256=66Wm5cdy8tKib_mGicjq_yd-gNVMFWRECnrDksnNnwU,6316
387
387
  rest/helpers.py,sha256=l_vA0mdY4gZmOwzmqt-qB3DcF3aKkmteerXzJd2Qq7Q,28369
388
388
  rest/joke.py,sha256=0PpKaX2iN7jlS62kgjfmmqkFBYLPURz15aQ8R7OJkJ8,260
389
- rest/jwtoken.py,sha256=2BjRrnQSzm7ydHgYl6LIjfGW1YPmqjt-gDIo21O0WTk,2388
389
+ rest/jwtoken.py,sha256=6AIe9IpsOn44sodiV0OPYeTZZNhS8VRiakV-rOuCyGw,2444
390
390
  rest/log.py,sha256=hd1_4HBOS395sfXJIL6BTw9yekm1SLgBwYx_PdfIhKA,20930
391
391
  rest/mail.py,sha256=Rm40hWDYop0tMqxdN-J2NT-dCnP-f4SfCZxSO02ajzs,7965
392
392
  rest/mailman.py,sha256=v5O1G5s3HiAKmz-J1z0uT6_q3xsONPpxVl9saEyQQ2I,9174
@@ -452,7 +452,7 @@ taskqueue/migrations/0001_initial.py,sha256=JwYib8CK5ftSXlfxKZUcKEEVsXktNB5q3h-2
452
452
  taskqueue/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
453
453
  taskqueue/models.py,sha256=N3_9jWHPGzs6UxlAzpjst6qPhvIs1RELTy1cMXMeXsA,22407
454
454
  taskqueue/periodic.py,sha256=2i0271khrCow3hDmlNEcoAZnesBVl40jd7MIim2Cxs4,3543
455
- taskqueue/rpc.py,sha256=If5E9D9AR2RqW4lHRaDuD9L9b9ZfL_PaBQ6iX91ehvU,5736
455
+ taskqueue/rpc.py,sha256=Lf5VUoqCRkfWUAIvx_s508mjAtDPwpiWyxg0ryqWbQA,5793
456
456
  taskqueue/tq.py,sha256=PzSoDrawYcqZylruEgsK95gcJ4J_VhdM6rxg9V6_X8E,942
457
457
  taskqueue/transports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
458
458
  taskqueue/transports/email.py,sha256=H4GaomiyCck5R_AOcsrMawCl-_Bp_Zg-uWto9t1Xcoo,623
@@ -502,7 +502,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
502
502
  ws4redis/settings.py,sha256=K0yBiLUuY81iDM4Yr-k8hbvjn5VVHu5zQhmMK8Dtz0s,1536
503
503
  ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
504
504
  ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
505
- django_restit-4.2.75.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
506
- django_restit-4.2.75.dist-info/METADATA,sha256=JzZ59EQ9VakJIy_mZyWZ5SbCrdnxqSpI53sVs484TFU,7645
507
- django_restit-4.2.75.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
508
- django_restit-4.2.75.dist-info/RECORD,,
505
+ django_restit-4.2.77.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
506
+ django_restit-4.2.77.dist-info/METADATA,sha256=uVn8E8Ts3Hiv_mvZKMK3nZois8Z1zy79o0BhcdbtGrY,7645
507
+ django_restit-4.2.77.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
508
+ django_restit-4.2.77.dist-info/RECORD,,
rest/jwtoken.py CHANGED
@@ -9,13 +9,16 @@ JWT_EXP_1_DAY = 86400
9
9
  JWT_EXP_2_DAY = 172800
10
10
  JWT_EXP_7_DAY = 604800
11
11
  JWT_EXP_30_MIN = 1800
12
+ JWT_EXP_15_MIN = 900
12
13
  JWT_KEY = settings.SECRET_KEY
13
14
  JWT_EXPIRES = settings.get("JWT_EXPIRES", JWT_EXP_30_MIN)
14
15
  JWT_REFRESH_EXPIRES = settings.get("JWT_REFRESH_EXPIRES", JWT_EXP_2_DAY)
15
16
 
16
17
 
17
18
  class JWToken():
18
- def __init__(self, token=None, user_id=None, key=JWT_KEY, device_id=None, alg="HS256", access_expires_in=JWT_EXPIRES, refresh_expires_in=JWT_REFRESH_EXPIRES):
19
+ def __init__(self, token=None, user_id=None, key=JWT_KEY,
20
+ device_id=None, alg="HS256", access_expires_in=JWT_EXPIRES,
21
+ refresh_expires_in=JWT_REFRESH_EXPIRES):
19
22
  # takes full JWT token header.payload.signature
20
23
  self.token = token
21
24
  self.key = key
taskqueue/rpc.py CHANGED
@@ -87,6 +87,7 @@ def rest_on_test(request):
87
87
 
88
88
 
89
89
  @rd.url(r'^task/status$')
90
+ @rd.login_required
90
91
  def rest_on_task_status(request):
91
92
  out = UberDict()
92
93
  last_completed = tq.Task.objects.filter(state=tq.TASK_STATE_COMPLETED).last()
@@ -109,6 +110,7 @@ def rest_on_task_status(request):
109
110
 
110
111
 
111
112
  @rd.urlGET('workers')
113
+ @rd.login_required
112
114
  def rest_on_runners(request):
113
115
  workers = tq.TaskWorkerClient.GET_ONLINE()
114
116
  if request.DATA.get("graph") == "detailed":
@@ -124,6 +126,7 @@ def rest_on_runners(request):
124
126
  # write a django query to
125
127
 
126
128
  @rd.url(r'^task/stats$')
129
+ @rd.login_required
127
130
  def rest_on_stats(request):
128
131
  now = datetime.now()
129
132
  when = now - timedelta(days=request.DATA.get("days", 7, field_type=int))