BasePermission returning True for has_permission and has_object_permission is a huge gotcha
              
              #9778
            
            
              
                Unanswered
              
          
                  
                    
                      jzwick-narmi
                    
                  
                
                  asked this question in
                Potential Issue
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using the negation of a permission, for example an implementation of
~IsOAuthAuthentication, thatBasePermission. has_object_permissionreturs a staticTrueis a very tricky gotcha.Where I would expect this permission to be False, the negation turning the condition to True, it winds up being False when checking object_permissions, so the negation that swaps it back to False, which ultimately fails the boolean evaluation.
BasePermissionshould look like this;This will behave as one would intuitively expect both in the negated permission scenario, and the unnegated. It still returns True by "default", and if
has_permissionis ever False, it's likely not undesirable forhas_object_permissionto also be False.Beta Was this translation helpful? Give feedback.
All reactions