Skip to content

Commit 0b21e7f

Browse files
authored
Merge pull request #642 from jbernal0019/master
Pass user's auth token to plugins as env variable
2 parents 33e1921 + 27ba2da commit 0b21e7f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

chris_backend/plugininstances/services/manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from django.utils import timezone
5656
from django.conf import settings
5757
from django.db.utils import IntegrityError
58+
from rest_framework.authtoken.models import Token
5859

5960
from core.storage import connect_storage
6061
from core.utils import json_zip2str
@@ -217,8 +218,11 @@ def _compute_env_vars(self):
217218
username = plugin_inst.owner.username
218219
email = plugin_inst.owner.email
219220

221+
token,_ = Token.objects.get_or_create(user=plugin_inst.owner)
222+
220223
env = [f'CHRIS_JID={job_id}', f'CHRIS_PLG_INST_ID={plugin_inst.id}',
221-
f'CHRIS_USER_USERNAME={username}', f'CHRIS_USER_EMAIL={email}']
224+
f'CHRIS_USER_USERNAME={username}', f'CHRIS_USER_EMAIL={email}',
225+
f'CHRIS_USER_TOKEN={token.key}']
222226

223227
if plugin_type != 'fs':
224228
prev_id = plugin_inst.previous.id

0 commit comments

Comments
 (0)