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

[GH-178] Assign moderator to only the user who start the meeting #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
9 changes: 7 additions & 2 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ type EnrichMeetingJwtRequest struct {
// Claims extents cristalhq/jwt standard claims to add jitsi-web-token specific fields
type Claims struct {
jwt.StandardClaims
Context Context `json:"context"`
Room string `json:"room,omitempty"`
Context Context `json:"context"`
Room string `json:"room,omitempty"`
Moderator bool `json:"moderator,omitempty"` // only the user started the meeting is moderator
CreatorID string `json:"creator_id,omitempty"` // store id of user who start the meeting
}

func verifyJwt(secret string, jwtToken string) (*Claims, error) {
Expand Down Expand Up @@ -200,6 +202,7 @@ func (p *Plugin) updateJwtUserInfo(jwtToken string, user *model.User) (string, e
}

claims.Context = newContext
claims.Moderator = sanitizedUser.Id == claims.CreatorID

return signClaims(secret, claims)
}
Expand Down Expand Up @@ -280,6 +283,8 @@ func (p *Plugin) startMeeting(user *model.User, channel *model.Channel, meetingI
claims.ExpiresAt = jwt.NewNumericDate(meetingLinkValidUntil)
claims.Subject = jURL.Hostname()
claims.Room = meetingID
claims.Moderator = false
claims.CreatorID = user.Id

var err2 error
jwtToken, err2 = signClaims(p.getConfiguration().JitsiAppSecret, &claims)
Expand Down
1 change: 1 addition & 0 deletions server/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestSignClaims(t *testing.T) {
claims.ExpiresAt = jwt.NewNumericDate(time.Time{})
claims.Subject = "test"
claims.Room = "test"
claims.Moderator = true

token, err := signClaims("test-secret", &claims)
require.Nil(t, err)
Expand Down