Opened 9 years ago

Closed 9 years ago

#26470 closed Cleanup/optimization (fixed)

Checks performed during Permission creation should use the check framework.

Reported by: Simon Charette Owned by: nobody
Component: contrib.auth Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The django.contrib.auth.management.check_permission function that is connected to the post_migrate signal performs static model analysis checks that should rely on the check framework. At the moment a ValidationError or a CommandError is raised when a check fails.

The checks performed are the following:

  1. Check that custom permissions don't clash with built-ins and are not duplicated;
  2. Check that models verbose_name doesn't exceed a certain length based on the Permission.name.max_length;
  3. Check that permissions name doesn't exceed a certain length based on the Permission.name.max_length.

For 2. and 3. I suggest we make them issue a check.Warning with a message noting that the name will be truncated to N characters instead of crashing with an IntegrityError if the check is ignored/disabled.

Change History (7)

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedReady for checkin

Those checks were added before the permission name max_length was increased from 50 to 255 (#8162). Therefore I expect few if any users to exceed that limit these days. I don't see much benefit to adding truncation logic as proposed.

comment:3 by Simon Charette, 9 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

Alright, I'll add them as errors later today in this case.

comment:4 by Simon Charette, 9 years ago

Just ported the permission names max length checks as well.

comment:5 by Simon Charette, 9 years ago

Patch needs improvement: unset

comment:6 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Simon Charette <charette.s@…>, 9 years ago

Resolution: fixed
Status: newclosed

In a872194:

Fixed #26470 -- Converted auth permission validation to system checks.

Thanks Tim for the review.

Note: See TracTickets for help on using tickets.
Back to Top