Create token generator classes and a registry for them

Review Request #12415 — Created June 24, 2022 and submitted — Latest diff uploaded

Information

Djblets
release-3.x

Reviewers

Currently, Djblets can only generate SHA1 tokens and token generation is
baked into djblets.webapi.managers.WebAPITokenManager. As part of our move to
using an improved token format (API Tokens v2), we need a way to generate
different types of tokens.

This change introduces token generators, which handle the logic for token
generation and allows for multiple ways of generating tokens. There are three
classes implemented:
1. A base class.
2. A class for generating our legacy SHA1 tokens.
3. A class for generating our new token format that has a vendor prefix and
checksum.

This also adds a registry for the token generators.

  • Created unit tests for the token generators.
  • Ran all unit tests in djblets.secrets.tests.

Commits

Files