class Meta(object): resource_name = 'user_domains' authentication = ApiKeyAuthentication() object_class = UserDomain include_resource_uri = False
class Meta(object): resource_name = 'domain_usernames' authentication = ApiKeyAuthentication() object_class = User include_resource_uri = False allowed_methods = ['get']
class Meta: queryset = Category.objects.all() resource_name = 'category' authentication = ApiKeyAuthentication()
class Meta: queryset = Candidate.objects.all() resource_name = 'candidate' authentication = ApiKeyAuthentication()
'sex': ALL, 'age': ALL, 'remarks': ALL, 'date_entered': ALL, 'signed': ALL, 'storage_location': ALL, 'body_size': ALL, } max_limit = 0 authentication = Authentication( ) #this means no authentication, which is OK in this case, because only allowed method is GET #####DRP API resources #####common settings to be used for all DRP API resources drp_authentication = ApiKeyAuthentication( ) #will require a username and api_key as url parameters, otherwise return 401 unauthorized drp_authorization = CustomDjangoAuthorization( appname="drp", modelname="drp_occurrence" ) #look to custom Django Authorization class to determine permissions drp_allowed_methods = ['get', 'post'] # class drp_taxonomyResource(ModelResource): # class Meta: # max_limit=0 # queryset = drp_taxonomy.objects.all() # allowed_methods= drp_allowed_methods # resource_name = 'drp_taxonomy' # authorization = drp_authorization # authentication = drp_authentication
class Meta: queryset = Question.objects.all() resource_name = 'question' authentication = ApiKeyAuthentication()
def get(self, request): authentication = ApiKeyAuthentication() if authentication.is_authenticated(request) is not True: return Response(Respostas.NAO_AUTORIZADO.value)
def test_multiauth_apikey_and_basic_auth__no_details_fails(self): auth = MultiAuthentication(BasicAuthentication(), ApiKeyAuthentication()) request = HttpRequest() self.assertEqual(isinstance(auth.is_authenticated(request), HttpUnauthorized), True)
class Meta: queryset = Bulletin.objects.all() resource_name = 'bulletin' authorization = Authorization() authentication = ApiKeyAuthentication() always_return_data = True
class Meta(DeviceResource.Meta): authentication = ApiKeyAuthentication()
class Meta: resource_name = 'customcareer' queryset = CustomCareer.objects.all() authentication = ApiKeyAuthentication() authorization = DjangoAuthorization()