kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Wrap PasswordResetTokenGenerator in TokenGenerator instead of subclassing it

Open rtibbles opened this issue 4 weeks ago • 2 comments

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

Overview

TokenGenerator subclasses Django's PasswordResetTokenGenerator, but every caller passes it a user id, not a User. Only the _make_hash_value override names the parameter user_id. make_token and check_token still call it user, matching the inherited User-typed signatures, which has misled reviewers about what the methods accept. TokenGenerator should wrap PasswordResetTokenGenerator instead of subclassing it, so its interface takes a user id explicitly.

Complexity: Low Target branch: develop

Context

  • TokenGenerator fully overrides make_token and check_token. From the base class it only uses _make_token_with_timestamp (the salted HMAC) and the secret / algorithm / key_salt set up in __init__.
  • Django's _make_token_with_timestamp(user, timestamp) passes user straight to _make_hash_value, which Kolibri overrides to return f"{user_id}{timestamp}".
  • Callers: kolibri/core/auth/viewsets/session.py, kolibri/core/device/tasks.py, kolibri/plugins/user_profile/tasks.py, kolibri/plugins/user_profile/viewsets/user_profile.py.

The Change

  • TokenGenerator should expose only make_token(user_id) and check_token(user_id, token).
  • Token behaviour should stay the same: HMAC-signed with the Django secret, valid for TOKEN_EXPIRE_LIMIT seconds.

Acceptance Criteria

  • [ ] TokenGenerator does not subclass PasswordResetTokenGenerator.
  • [ ] make_token and check_token name their first parameter user_id.
  • [ ] The existing tests in kolibri/core/utils/test/test_token_generator.py and kolibri/plugins/user_profile/test/test_api.py pass unchanged.

References

AI usage

I chose the scope (wrap rather than rename) and the criteria. Claude Code read the Django base class and callers and drafted the sections.

rtibbles avatar Nov 05 '26 19:11 rtibbles

Hello team,

I noticed that this issue has not yet been opened for contribution or assigned to any contributor. I am very interested in working on it as my first contribution to Kolibri.

I would be grateful if you could consider allowing me to work on this issue and assign it to me. I am eager to contribute and learn from the process.

Thank you!

ShreyasK95 avatar Nov 09 '26 11:11 ShreyasK95

Hi! 👋

Thanks so much for your interest! This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues. If there are no unassigned 'help wanted' issues available, please wait until new ones are added.

We really appreciate your willingness to help. 😊

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Nov 09 '26 11:11 learning-equality-bot