Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permiss TypeError #8

Open
lm1427934400 opened this issue Nov 4, 2017 · 0 comments
Open

Permiss TypeError #8

lm1427934400 opened this issue Nov 4, 2017 · 0 comments

Comments

@lm1427934400
Copy link

当django1.9版本,配置权限@permission_required("userauth.view_user")时,会提示permission TypeError,导致权限验证失败
检查源码发现,内部的权限调用的代码是

def _user_has_perm(user, perm, obj):
"""
A backend can raise PermissionDenied to short-circuit permission checking.
"""
for backend in auth.get_backends():
if not hasattr(backend, 'has_perm'):
continue
try:
if backend.has_perm(user, perm, obj):
return True
except PermissionDenied:
return False
return False

而对用django_auth_ldap的has_perm的函数是
def has_perm(self, user, perm):
return perm in self.get_all_permissions(user)
会导致函数参数不匹配,

可以修改为
def has_perm(self, user, perm,obj=None):
return perm in self.get_all_permissions(user)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant