Skip to content
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

πŸ§”πŸ½ Freddy branch #1042

Merged
merged 35 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1eeada6
πŸ§‘πŸ»β€πŸ¦° Fixing issues (#820)
SolMon9099 Nov 18, 2023
481527a
πŸ§”πŸΌ Fixing pashto (#830)
SolMon9099 Nov 21, 2023
89f93e7
πŸ’ž Translations for main (#835)
git-translate[bot] Nov 25, 2023
5ef968d
πŸ‘¨β€πŸ‘¨β€πŸ‘¦ Fixing issues (#838)
SolMon9099 Dec 6, 2023
79231b4
πŸ§‘πŸΌβ€βœˆοΈ Fixing issues (#842)
SolMon9099 Dec 7, 2023
1cd1a5e
πŸ‘©πŸΏβ€πŸŽ¨ Fixing issues (#844)
SolMon9099 Dec 7, 2023
fa52d41
🦿 Fixing issues (#846)
SolMon9099 Dec 9, 2023
43a1f17
πŸ” Fixing issues (#860)
SolMon9099 Dec 19, 2023
3ad6bc6
πŸ‘±πŸ»β€β™€οΈ Fixing issues (#871)
SolMon9099 Dec 20, 2023
9bdecbe
πŸ§’πŸ» Docker, pytest and cypress setups (#876)
HamzaAnis Jan 4, 2024
4e39f17
πŸ‘·πŸ»β€β™‚οΈ Training record (#885)
SolMon9099 Jan 19, 2024
67e1d5b
πŸ€΅πŸΎβ€β™‚οΈ Fixing issue 2 (#895)
SolMon9099 Jan 24, 2024
a4c71a6
πŸ¦™ Fixing issue 2 (#897)
SolMon9099 Jan 24, 2024
2acf037
πŸ› Fix partner form bug (#903)
SolMon9099 Jan 30, 2024
76b501e
πŸ’ Fixing issue 2 (#917)
SolMon9099 Feb 4, 2024
d96693d
πŸŒ– Fixing issue 2 (#922)
SolMon9099 Feb 5, 2024
6d8c901
πŸ‘©πŸ½β€πŸ”§ Fixing issue 2 (#924)
SolMon9099 Feb 5, 2024
4be2749
πŸ‘±πŸΌβ€β™€οΈ Fixing issue 2 (#928)
SolMon9099 Feb 8, 2024
202dc5a
😞 Fixing issue 2 (#955)
SolMon9099 Feb 20, 2024
141c0e0
πŸ€½πŸ½β€β™‚οΈ Hub (#968)
SolMon9099 Feb 28, 2024
143234c
πŸ™‹πŸΎ Resolved the Conflicts (#973)
Humayun0008 Mar 2, 2024
296e565
🀎 Hub (#994)
SolMon9099 Mar 8, 2024
cae95b2
🎑 Hub (#1000)
SolMon9099 Mar 8, 2024
dc40994
πŸ‘«πŸΏ Hub2 (#1012)
SolMon9099 Mar 14, 2024
937f817
πŸ›ŒπŸ» Hub3 (#1019)
SolMon9099 Mar 22, 2024
a8ec7b5
☝🏾 Hub group chat (#1027)
SolMon9099 May 1, 2024
9cacf5c
🧚 Add meeting link generation feature (#1030)
binary-exe May 6, 2024
804bdc5
πŸ§œβ€β™‚οΈ Adding iframe meeting feature using 8x8 Jaas (#1036)
binary-exe May 29, 2024
9708df4
fix select mode of mentee application form
WebMon9099 May 29, 2024
56908f4
fix format
WebMon9099 May 30, 2024
d2d68cd
Merge remote-tracking branch 'origin/main' into Freddy_branch
WebMon9099 May 30, 2024
d99a6a2
fix format
WebMon9099 May 30, 2024
074aa6e
Merge branch 'dev' into Freddy_branch
WebMon9099 May 30, 2024
d710d47
Fix format
WebMon9099 May 30, 2024
e7f31a9
fix format
WebMon9099 May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions backend/api/utils/jaas_jwt_builder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import time, uuid
from authlib.jose import jwt


class JaaSJwtBuilder:
"""
The JaaSJwtBuilder class helps with the generation of the JaaS JWT.
The JaaSJwtBuilder class helps with the generation of the JaaS JWT.
"""

EXP_TIME_DELAY_SEC = 7200
Expand All @@ -13,30 +14,32 @@ class JaaSJwtBuilder:
# Used as a delay for the nbf claim value.

def __init__(self) -> None:
self.header = { 'alg' : 'RS256' }
self.header = {"alg": "RS256"}
self.userClaims = {}
self.featureClaims = {}
self.payloadClaims = {}

def withDefaults(self):
"""Returns the JaaSJwtBuilder with default valued claims."""
return self.withExpTime(int(time.time() + JaaSJwtBuilder.EXP_TIME_DELAY_SEC)) \
.withNbfTime(int(time.time() - JaaSJwtBuilder.NBF_TIME_DELAY_SEC)) \
.withLiveStreamingEnabled(True) \
.withRecordingEnabled(True) \
.withOutboundCallEnabled(True) \
.withTranscriptionEnabled(True) \
.withModerator(True) \
.withRoomName('*') \
.withUserId(str(uuid.uuid4()))
return (
self.withExpTime(int(time.time() + JaaSJwtBuilder.EXP_TIME_DELAY_SEC))
.withNbfTime(int(time.time() - JaaSJwtBuilder.NBF_TIME_DELAY_SEC))
.withLiveStreamingEnabled(True)
.withRecordingEnabled(True)
.withOutboundCallEnabled(True)
.withTranscriptionEnabled(True)
.withModerator(True)
.withRoomName("*")
.withUserId(str(uuid.uuid4()))
)

def withApiKey(self, apiKey):
"""
Returns the JaaSJwtBuilder with the kid claim(apiKey) set.

:param apiKey A string as the API Key https://jaas.8x8.vc/#/apikeys
"""
self.header['kid'] = apiKey
self.header["kid"] = apiKey
return self

def withUserAvatar(self, avatarUrl):
Expand All @@ -45,7 +48,7 @@ def withUserAvatar(self, avatarUrl):

:param avatarUrl A string representing the url to get the user avatar.
"""
self.userClaims['avatar'] = avatarUrl
self.userClaims["avatar"] = avatarUrl
return self

def withModerator(self, isModerator):
Expand All @@ -54,7 +57,7 @@ def withModerator(self, isModerator):

:param isModerator A boolean if set to True, user is moderator and False otherwise.
"""
self.userClaims['moderator'] = 'true' if isModerator == True else 'false'
self.userClaims["moderator"] = "true" if isModerator == True else "false"
return self

def withUserName(self, userName):
Expand All @@ -63,7 +66,7 @@ def withUserName(self, userName):

:param userName A string representing the user's name.
"""
self.userClaims['name'] = userName
self.userClaims["name"] = userName
return self

def withUserEmail(self, userEmail):
Expand All @@ -72,7 +75,7 @@ def withUserEmail(self, userEmail):

:param userEmail A string representing the user's email address.
"""
self.userClaims['email'] = userEmail
self.userClaims["email"] = userEmail
return self

def withLiveStreamingEnabled(self, isEnabled):
Expand All @@ -81,7 +84,7 @@ def withLiveStreamingEnabled(self, isEnabled):

:param isEnabled A boolean if set to True, live streaming is enabled and False otherwise.
"""
self.featureClaims['livestreaming'] = 'true' if isEnabled == True else 'false'
self.featureClaims["livestreaming"] = "true" if isEnabled == True else "false"
return self

def withRecordingEnabled(self, isEnabled):
Expand All @@ -90,7 +93,7 @@ def withRecordingEnabled(self, isEnabled):

:param isEnabled A boolean if set to True, recording is enabled and False otherwise.
"""
self.featureClaims['recording'] = 'true' if isEnabled == True else 'false'
self.featureClaims["recording"] = "true" if isEnabled == True else "false"
return self

def withTranscriptionEnabled(self, isEnabled):
Expand All @@ -99,7 +102,7 @@ def withTranscriptionEnabled(self, isEnabled):

:param isEnabled A boolean if set to True, transcription is enabled and False otherwise.
"""
self.featureClaims['transcription'] = 'true' if isEnabled == True else 'false'
self.featureClaims["transcription"] = "true" if isEnabled == True else "false"
return self

def withOutboundCallEnabled(self, isEnabled):
Expand All @@ -108,7 +111,7 @@ def withOutboundCallEnabled(self, isEnabled):

:param isEnabled A boolean if set to True, outbound calls are enabled and False otherwise.
"""
self.featureClaims['outbound-call'] = 'true' if isEnabled == True else 'false'
self.featureClaims["outbound-call"] = "true" if isEnabled == True else "false"
return self

def withExpTime(self, expTime):
Expand All @@ -117,7 +120,7 @@ def withExpTime(self, expTime):

:param expTime Unix time in seconds since epochs plus a delay. Expiration time of the JWT.
"""
self.payloadClaims['exp'] = expTime
self.payloadClaims["exp"] = expTime
return self

def withNbfTime(self, nbfTime):
Expand All @@ -126,7 +129,7 @@ def withNbfTime(self, nbfTime):

:param nbfTime Unix time in seconds since epochs.
"""
self.payloadClaims['nbfTime'] = nbfTime
self.payloadClaims["nbfTime"] = nbfTime
return self

def withRoomName(self, roomName):
Expand All @@ -135,7 +138,7 @@ def withRoomName(self, roomName):

:param roomName A string representing the room to join.
"""
self.payloadClaims['room'] = roomName
self.payloadClaims["room"] = roomName
return self

def withAppID(self, AppId):
Expand All @@ -144,7 +147,7 @@ def withAppID(self, AppId):

:param AppId A string representing the unique AppID (previously tenant).
"""
self.payloadClaims['sub'] = AppId
self.payloadClaims["sub"] = AppId
return self

def withUserId(self, userId):
Expand All @@ -153,7 +156,7 @@ def withUserId(self, userId):

:param A string representing the user, should be unique from your side.
"""
self.userClaims['id'] = userId
self.userClaims["id"] = userId
return self

def signWith(self, key):
Expand All @@ -162,8 +165,8 @@ def signWith(self, key):

:param key A string representing the private key in PEM format.
"""
context = { 'user': self.userClaims, 'features': self.featureClaims }
self.payloadClaims['context'] = context
self.payloadClaims['iss'] = 'chat'
self.payloadClaims['aud'] = 'jitsi'
context = {"user": self.userClaims, "features": self.featureClaims}
self.payloadClaims["context"] = context
self.payloadClaims["iss"] = "chat"
self.payloadClaims["aud"] = "jitsi"
return jwt.encode(self.header, self.payloadClaims, key)
29 changes: 17 additions & 12 deletions backend/api/views/meeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

API_KEY = os.environ.get("EIGHT_X_EIGHT_API_KEY")
APP_ID = os.environ.get("EIGHT_X_EIGHT_APP_ID")
ENCODED_PRIVATE_KEY = os.environ.get('EIGHT_X_EIGHT_ENCODED_PRIVATE_KEY')
ENCODED_PRIVATE_KEY = os.environ.get("EIGHT_X_EIGHT_ENCODED_PRIVATE_KEY")


@meeting.route("/generateToken", methods=["GET"])
def generateToken():
Expand All @@ -23,17 +24,21 @@ def generateToken():
PRIVATE_KEY = base64.b64decode(ENCODED_PRIVATE_KEY)
print(PRIVATE_KEY)
jaasJwt = JaaSJwtBuilder()
token = jaasJwt.withDefaults() \
.withApiKey(API_KEY) \
.withUserName("User Name") \
.withUserEmail("[email protected]") \
.withModerator(False) \
.withAppID(APP_ID) \
.withUserAvatar("https://asda.com/avatar") \
.signWith(PRIVATE_KEY)

return create_response(data={"token": token.decode('utf-8'), "appID": APP_ID})
token = (
jaasJwt.withDefaults()
.withApiKey(API_KEY)
.withUserName("User Name")
.withUserEmail("[email protected]")
.withModerator(False)
.withAppID(APP_ID)
.withUserAvatar("https://asda.com/avatar")
.signWith(PRIVATE_KEY)
)

return create_response(data={"token": token.decode("utf-8"), "appID": APP_ID})

except Exception as error:
print(error)
return create_response(status=422, message=f'Failed to generate token for meeting')
return create_response(
status=422, message=f"Failed to generate token for meeting"
)
4 changes: 2 additions & 2 deletions backend/tests/test_explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_find_mentee(client):

accounts = result["accounts"]

# There is no need to write assertion on db level data because its change frequently (Database assertion)
# There is no need to write assertion on db level data because its change frequently (Database assertion)
# get the public mentee instances in the database
mentee_users = MenteeProfile.objects.filter(is_private=False).count()

Expand All @@ -41,7 +41,7 @@ def test_find_mentor(client):
assert "accounts" in result

accounts = result["accounts"]
#get the mentor instances in the database
# get the mentor instances in the database
mentor_users = MentorProfile.objects.count()
assert len(accounts) > 0
assert (
Expand Down
Loading
Loading