Share one role check across coach class summary, notifications and lesson report

Open
#16,079 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
10/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, python

Research direction

Start with the three permission classes in kolibri/plugins/coach/viewsets/class_summary.py, classroom_notifications.py and lesson_report.py, then compare them with KolibriAuthPermissions. The change replaces them with one coach permission class and makes the lesson report return 404 for unreadable ids. Also update the notAuthorized logic in packages/kolibri/components/pages/NotificationsRoot/index.vue. The work is done when the Context table holds for all three endpoints and the 403 assertions in their tests are replaced. The issue says it is not open for contribution, so check with maintainers before starting.

Written by the indexing model from the issue text.

Description

APP: Coach DEV: backend DEV: frontend

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

The coach class summary, notifications and lesson report endpoints each check the coach's role with their own copy of the same code, and they disagree on status codes. The lesson report returns 403 for a lesson the user doesn't coach and 404 for one that doesn't exist, which reveals which lesson ids exist. The lesson report should rely on Lesson's read permissions, and the class summary and notifications endpoints should share one classroom role check.

Complexity: Low
Target branch: develop

Context

On #15993's head (900ae66a8e):

class summary notifications lesson report
Coach, own classroom or lesson 200 200 200
Coach, another classroom's 403 403 403
Unknown id 403 403 404
Malformed id 403 403 404
Learner 403 403 403, or 404 for unknown or malformed
The Change
  • Lesson report: replace LessonReportPermissions with KolibriAuthPermissions, and add KolibriAuthPermissionsFilter to filter_backends so get_object() only finds readable lessons.
  • Class summary and notifications: replace ClassSummaryPermissions and ClassroomNotificationsPermissions with one coach plugin permission class that checks for a coach or admin role on the classroom. Each view tells it where its classroom id comes from: the URL pk for class summary, the classroom_id query parameter for notifications.
  • Keep IsAuthenticated ahead of each permission class.
  • Update NotificationsRoot's notAuthorized to treat a 404 from these endpoints as it treats a 403.
Out of Scope
  • The difficult questions endpoints, which #16069 covers.
Acceptance Criteria
  • Class summary, notifications and lesson report return 404 for a classroom or lesson the user isn't a coach or admin for, including unknown and malformed ids.
  • Unauthenticated requests to all three get 403.
  • A coach or admin of the classroom gets the same responses as before.
  • Opening Coach at #/<class_id>/home for a classroom the user doesn't coach shows the same message as before.
  • Tests cover each row of the Context table for all three endpoints, replacing their 403 assertions.

AI usage

I had Claude Code probe each endpoint's status codes on #15993's head and trace the frontend's 403 handling. I chose the scope, the shared permission class and 404 for every refused id. Claude Code drafted the sections with me.

Dominant language
Python
Stars
1.2k
Forks
1.1k
Avg merge
2d 9h
Merged PRs (30d)
87

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from learningequality/kolibri

All issues in learningequality/kolibri

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.