Skip to content

Conversation

johanaam
Copy link
Member

No description provided.

@johanaam johanaam requested review from eilifhl and sindrelm April 20, 2026 12:40
@johanaam johanaam self-assigned this Apr 20, 2026
Copy link
Member

@sindrelm sindrelm left a comment •

Choose a reason for hiding this comment

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

Additional feedback given by codex

  • Revoke the old refresh token before leaving the auth cookie path — /home/sindre/Documents/NTNU/vår26/IDATT2106/nettdetektivene/backend/src/main/kotlin/edu/ntnu/idi/idatt/backend/classroom/api/GamePreviewSessionController.kt:30-33
    startPreviewSession tries to rotate the caller’s refresh token by reading it from request.cookies, but this endpoint lives under /api/v1/classrooms/...
    while the configured refresh cookie path is /api/v1/auth (see src/test/resources/application.properties and .env.example). In a real browser that cookie
    is therefore not sent here, extractRefreshCookie(request) resolves to null, and the previous teacher refresh token stays active after entering preview. That leaves an extra non-preview refresh token valid server-side and defeats the intended session rotation for every normal browser client.
  • Derive viewAs from existing tokens instead of defaulting to teacher — /home/sindre/Documents/NTNU/vår26/IDATT2106/nettdetektivene/backend/src/main/kotlin/edu/ntnu/idi/idatt/backend/iam/security/SecurityConfig.kt:168-169
    For access tokens issued before this change, the new view_as claim is absent. toAuthentication now falls back to ViewAs.TEACHER unconditionally, so any
    still-valid pupil token is rehydrated as viewAs=TEACHER until the user refreshes or logs in again. That makes /api/v1/auth/me return the wrong session
    metadata during rollout and will misclassify legacy sessions anywhere the new field is consumed.

@sindrelm sindrelm self-requested a review April 20, 2026 13:17
Copy link
Member

@sindrelm sindrelm left a comment

Choose a reason for hiding this comment

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

see previous comments

@johanaam johanaam requested a review from sindrelm April 20, 2026 14:23
@johanaam johanaam linked an issue Apr 21, 2026 that may be closed by this pull request
Copy link
Member

@sindrelm sindrelm left a comment

Choose a reason for hiding this comment

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

lgtm!

@sindrelm sindrelm merged commit 141b3bf into main Apr 21, 2026
1 check passed
@sindrelm sindrelm deleted the feat/teacher-game-preview-backend branch April 21, 2026 11:23
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Let teacher test game
2 participants