djangorestframework-api-key icon indicating copy to clipboard operation
djangorestframework-api-key copied to clipboard

Explore swappable API key model functionality

Open florimondmanca opened this issue 3 years ago • 1 comments

This is an illustration of a possible resolution for #180.

  • Allows users to define a default API key model they'd like to use.
  • If "a default API key model" does not make sense for their use case (e.g. maybe they have multiple custom API key models), then the default APIKey model would still get created. I'm not sure there's a sensible way out of this, because allowing dropping the model midways, e.g. via API_KEY_MODEL = None, would add migration questions for existing apps.
  • However, this PR also proposes to not register() any API key models by default, meaning at least they wouldn't see it in the admin. It's possible we want this to be a separate, isolated PR.

This would be a fully backwards-compatible change, as the default behavior would match the existing APIKey-based behavior — except for the admin dropout, which we'd need to document as a change.

cc @virogenesis What do you think about this?

florimondmanca avatar Dec 05 '21 17:12 florimondmanca

Codecov Report

Merging #191 (5f20bf9) into master (dd806cf) will decrease coverage by 0.66%. The diff coverage is 78.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   96.55%   95.88%   -0.67%     
==========================================
  Files          22       22              
  Lines         522      535      +13     
==========================================
+ Hits          504      513       +9     
- Misses         18       22       +4     
Impacted Files Coverage Δ
src/rest_framework_api_key/models.py 96.00% <75.00%> (-4.00%) :arrow_down:
src/rest_framework_api_key/admin.py 76.00% <100.00%> (-0.93%) :arrow_down:
src/rest_framework_api_key/permissions.py 94.73% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dd806cf...5f20bf9. Read the comment docs.

codecov-commenter avatar Dec 05 '21 17:12 codecov-commenter