빠른 질문이 있습니다.Django-Tastypie : 인증 및 인증
class MyAuthentication(BasicAuthentication):
def is_authenticated(self, request, **kwargs):
if request.method == 'GET':
return True
else:
#group_name = request.body('group')
#if Group.objects.filter(name = group_name):
# return super(MyAuthentication, self).is_authenticated(request, **kwargs)
return super(MyAuthentication, self).is_authenticated(request, **kwargs)
class MyAuthorization(DjangoAuthorization): #checks permissions
def is_authorized(self, request, object=None):
if request.method == 'GET':
return True
return super(MyAuthorization, self).is_authorized(request, object)
class Sys_teamResource(ModelResource):
class Meta:
queryset = Sys_team.objects.all()
resource_name = 'sys_team'
filtering = { 'sys_team' : ALL }
authentication = MyAuthentication()
authorization = MyAuthorization()
validation = FormValidation(form_class=Sys_team_Form)
allowed_methods = ['get','post','put']
이 코드는 잘 작동하지만 난 return False
으로 return super(MyAuthorization, self).is_authorized(request, object)
을 대체 happenwhen 될지 궁금 : 내 API.py 파일의 경우 나는 다음과 같은 코드가 있습니다. 개념적으로 이것은 인증 된 사용자의 모든 사용 권한을 거부하고 POSTING에서 데이터베이스로의 액세스를 거부해야합니다. 그러나 사용자는 여전히 할 수 있습니다. 그게 왜 궁금 해서요? 또한 위의 주석으로 처리 된 코드와 관련하여 특정 그룹에 속한 경우에만 사용자를 인증하려고합니다. 그러나 request.body('group')
을 시도하면 오류 str 개체가 호출 할 수 없습니다. 어떤 도움이라도 대단히 감사합니다! 감사. 주석 코드 및 STR 개체에 대한