Bläddra i källkod

Renaming + Comment + small refactor

Guénaël Muller 6 år sedan
förälder
incheckning
ca774f9e6a

+ 2 - 1
tracim/development.ini.base Visa fil

@@ -246,13 +246,14 @@ jitsi_meet.domain = your_jitsi_meet_instance
246 246
 jitsi_meet.use_token = False
247 247
 # If token mode is choosen, you need to provide a token generator.
248 248
 # "local" value mean that tracim himself will create token for jitsi-meet
249
+# Distant token generator are not yet implemented.
249 250
 jitsi_meet.token_generator = local
250 251
 # identifier share between jitsi_meet and local token_generator
251 252
 jitsi_meet.token_generator.local.app_id = tracim
252 253
 # Secret share between jitsi-meet and local token_generator
253 254
 jitsi_meet.token_generator.local.secret = my_secret
254 255
 # Algorithm used to sign JWT token
255
-jitsi_meet.token_generator.local.algo = HS256
256
+jitsi_meet.token_generator.local.algorithm = HS256
256 257
 # Duration of token validity in second. 5 minutes (300) is a good choice.
257 258
 jitsi_meet.token_generator.local.duration = 300
258 259
 

+ 2 - 2
tracim/tracim/config/app_cfg.py Visa fil

@@ -460,8 +460,8 @@ class CFG(object):
460 460
         self.JITSI_MEET_TOKEN_GENERATOR_LOCAL_SECRET = tg.config.get(
461 461
             'jitsi_meet.token_generator.local.secret'
462 462
         )
463
-        self.JITSI_MEET_TOKEN_GENERATOR_LOCAL_ALG = tg.config.get(
464
-            'jitsi_meet.token_generator.local.alg',
463
+        self.JITSI_MEET_TOKEN_GENERATOR_LOCAL_ALGORITHM = tg.config.get(
464
+            'jitsi_meet.token_generator.local.algorithm',
465 465
             'HS256'
466 466
         )
467 467
         self.JITSI_MEET_TOKEN_GENERATOR_LOCAL_DURATION = int(tg.config.get(

+ 16 - 11
tracim/tracim/lib/jitsi_meet/room.py Visa fil

@@ -16,6 +16,8 @@ class JitsiMeetRoom(object):
16 16
             issuer: typing.Union[User, JitsiMeetUser, None]=None,
17 17
     ) -> None:
18 18
         """
19
+        This class set all to create a JitsiMeetRoom according
20
+        to current config.
19 21
         :param issuer: user who initiated Jitsi Meet talk
20 22
         if None, default user is created. Can be both Tracim User or
21 23
         JitsiMeetUser.
@@ -26,7 +28,7 @@ class JitsiMeetRoom(object):
26 28
         self._set_domain()
27 29
         self._set_token_params()
28 30
         self._set_context(
29
-            receivers=receivers,
31
+            workspace=receivers,
30 32
             issuer=issuer,
31 33
         )
32 34
         self.room = self._generate_room_name(receivers)
@@ -45,17 +47,17 @@ class JitsiMeetRoom(object):
45 47
         """
46 48
         self.use_token = self.tracim_cfg.JITSI_MEET_USE_TOKEN
47 49
         if self.use_token:
48
-            if self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR == 'local':
49
-                self.token_app_id = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_APP_ID  # nopep8
50
-                self.token_secret = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_SECRET  # nopep8
51
-                self.token_alg = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_ALG   # nopep8
52
-                self.token_duration = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_DURATION  # nopep8
53
-            else:
50
+            if self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR != 'local':
54 51
                 raise JitsiMeetNoTokenGenerator
55 52
 
53
+            self.token_app_id = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_APP_ID  # nopep8
54
+            self.token_secret = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_SECRET  # nopep8
55
+            self.token_alg = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_ALGORITHM   # nopep8
56
+            self.token_duration = self.tracim_cfg.JITSI_MEET_TOKEN_GENERATOR_LOCAL_DURATION  # nopep8
57
+
56 58
     def _set_context(
57 59
             self,
58
-            receivers: Workspace,
60
+            workspace: Workspace,
59 61
             issuer: typing.Union[User, JitsiMeetUser, None],
60 62
     ) -> None:
61 63
         """
@@ -63,7 +65,7 @@ class JitsiMeetRoom(object):
63 65
         :param issuer: user who initiated Jitsi Meet talk
64 66
         if None, default user is created. Can be both Tracim User or
65 67
         JitsiMeetUser.
66
-        :param receivers: User or Room who can talk with sender. Now, only
68
+        :param workspace: User or Room who can talk with sender. Now, only
67 69
         Workspace are supported.
68 70
         :return: nothing.
69 71
         """
@@ -84,7 +86,7 @@ class JitsiMeetRoom(object):
84 86
             )
85 87
 
86 88
         # INFO - G.M - 13-02-2018 - Associate
87
-        group = receivers.label
89
+        group = workspace.label
88 90
 
89 91
         self.context = JitsiMeetContext(
90 92
             user=user,
@@ -107,7 +109,7 @@ class JitsiMeetRoom(object):
107 109
         # Jitsi-Meet doesn't like specials_characters
108 110
         return str_as_alpha_num_str(room)
109 111
 
110
-    def generate_token(self) -> str:
112
+    def generate_jwt_token(self) -> str:
111 113
         """
112 114
         Generate Jitsi-Meet related JWT token
113 115
         :return: JWT token as str
@@ -129,6 +131,9 @@ class JitsiMeetRoom(object):
129 131
     def generate_url(self, token=None) -> str:
130 132
         """
131 133
         Generate Jitsi-Meet url with or without token
134
+        examples :
135
+         - https://myjitsiinstance/myroom
136
+         - https://mysecurejitsiinstance/myroom?jwt=[very_long_jwt_token]
132 137
         :return: url as string
133 138
         """
134 139
         if token:

+ 1 - 1
tracim/tracim/templates/videoconf/invite.mak Visa fil

@@ -11,7 +11,7 @@
11 11
         <p>
12 12
         ${_('To invite someone from outside of tracim into this conference, share this link. This link is available for 5 minutes.')}
13 13
         </p>
14
-        <textarea readonly=readonly wrap="off" style="width: 100%;">${jitsi_meet_room.generate_url(jitsi_meet_room.generate_token())}</textarea>
14
+        <textarea readonly=readonly wrap="off" style="width: 100%;">${jitsi_meet_room.generate_url(jitsi_meet_room.generate_jwt_token())}</textarea>
15 15
     </div>
16 16
     <div class="modal-footer">
17 17
         <button type="button" class="btn btn-default" data-dismiss="modal">${_('Close')}</button>

+ 1 - 1
tracim/tracim/templates/videoconf/jitsi_meet.mak Visa fil

@@ -46,7 +46,7 @@
46 46
         // for another way to deal with auto-auth :
47 47
         // see this rejected PR : https://github.com/jitsi/jitsi-meet/pull/2109
48 48
             %if jitsi_meet_room.use_token:
49
-                jwt: '${jitsi_meet_room.generate_token()}',
49
+                jwt: '${jitsi_meet_room.generate_jwt_token()}',
50 50
             %endif
51 51
             roomName : '${jitsi_meet_room.room}',
52 52
             parentNode: document.querySelector('#jitsi'),

+ 4 - 4
tracim/tracim/tests/library/test_jitsi_meet_room.py Visa fil

@@ -67,7 +67,7 @@ class TestJitsiMeetRoom(object):
67 67
                 receivers=Workspace()
68 68
             )
69 69
             jmr.use_token = False
70
-            jmr.generate_token()
70
+            jmr.generate_jwt_token()
71 71
 
72 72
     def test_unit__set_context_return_always_jitsi_meet_user(self):
73 73
         with patch.object(JitsiMeetRoom,
@@ -76,7 +76,7 @@ class TestJitsiMeetRoom(object):
76 76
             jmr = JitsiMeetRoom(
77 77
                 receivers=Workspace()
78 78
             )
79
-            jmr._set_context(issuer=None, receivers=Workspace())
79
+            jmr._set_context(issuer=None, workspace=Workspace())
80 80
             assert jmr.context
81 81
             assert hasattr(jmr.context, 'user')
82 82
             assert isinstance(jmr.context.user, JitsiMeetUser)
@@ -85,7 +85,7 @@ class TestJitsiMeetRoom(object):
85 85
                 receivers=Workspace()
86 86
             )
87 87
             jmr2._set_context(issuer=JitsiMeetUser(jitsi_meet_user_id='user'),
88
-                              receivers=Workspace())
88
+                              workspace=Workspace())
89 89
             assert jmr2.context
90 90
             assert hasattr(jmr2.context, 'user')
91 91
             assert isinstance(jmr2.context.user, JitsiMeetUser)
@@ -93,7 +93,7 @@ class TestJitsiMeetRoom(object):
93 93
             jmr3 = JitsiMeetRoom(
94 94
                 receivers=Workspace()
95 95
             )
96
-            jmr3._set_context(issuer=User(), receivers=Workspace())
96
+            jmr3._set_context(issuer=User(), workspace=Workspace())
97 97
             assert jmr3.context
98 98
             assert hasattr(jmr3.context, 'user')
99 99
             assert isinstance(jmr3.context.user, JitsiMeetUser)