Skip to content

Add authentication to collaborative sessions#307

Open
Process-ing wants to merge 6 commits into
feature/collaborative-sessionsfrom
feature/session-validation
Open

Add authentication to collaborative sessions#307
Process-ing wants to merge 6 commits into
feature/collaborative-sessionsfrom
feature/session-validation

Conversation

@Process-ing

@Process-ing Process-ing commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Closes #278

What does this PR do?

This PR adds validation of the user session when entering a collaborative session. Users now need to be authenticated (using federated authentication) to enter/create collaborative sessions.

How to test

Note

This PR is related to frontend PR #723 and you must change your frontend branch to the one in that PR to correctly test what's in this PR

  1. While unauthenticated, try to create a collaborative session (it should redirect to the login form)
  2. Enter your SIGARRA login
  3. Retry to enter a session, it should now succeed

Comment thread django/university/urls.py
path("auth/socket-token/", SocketToken.as_view()),
path('csrf/', Csrf.as_view()),
path('admin/courses/', AdminExchangeCoursesView.as_view()),
path('student/schedule', StudentScheduleView.as_view(), name="auth-student-schedule"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add in the is_authenticated decorator since after the security issues its better to guard everything

participant_name = query_params.get('participant_name', ["Anonymous"])[0]
participant = Participant(sid, participant_name)
participant_name = query_params.get('participant_name', ['Anonymous'])[0]
participant = Participant(sid, participant_name, username)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

username is passed as the 3rd arg, which maps to selected_slots in the constructor signature (sid, name, selected_slots, nmec=None). So nmec ends up None for every participant.

Suggested change
participant = Participant(sid, participant_name, username)
participant = Participant(sid, participant_name, [], username)

)

token = jwt.encode(
{"username": request.user.username, "exp": expiration.timestamp()},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datetime.timestamp() returns a float and from what I looked up the JWT exp claim should be an integer and some libraries will reject a float.

if sessions_server.get_session(session.session_id) is not None:

await emit_session_update(sid, session)
await emit_session_update(sid, session)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check why did we remove if sessions_server.get_session(session.session_id) is not None ? Was it redundant ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants