{"id":20105468,"url":"https://github.com/nnseva/django-access-tastypie","last_synced_at":"2025-05-06T09:31:29.591Z","repository":{"id":57418716,"uuid":"109839266","full_name":"nnseva/django-access-tastypie","owner":"nnseva","description":"The application provides an authorization backend for the Tastypie package to use access rules defined by the Django-Access package","archived":false,"fork":false,"pushed_at":"2024-01-25T14:09:19.000Z","size":32,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-21T23:36:47.350Z","etag":null,"topics":["access","authority","authorization-backend","django","django-access","django-tastypie","dynamic","evaluation","evaluation-based","guard","instance-level","permissions","rights","rights-management","row-level","runtime","tastypie"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nnseva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-11-07T13:29:05.000Z","updated_at":"2023-12-25T00:52:16.000Z","dependencies_parsed_at":"2024-01-16T12:01:25.789Z","dependency_job_id":null,"html_url":"https://github.com/nnseva/django-access-tastypie","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.1428571428571429,"last_synced_commit":"edeb606f126d1380a993c807858539fc8e16b2da"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnseva%2Fdjango-access-tastypie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnseva%2Fdjango-access-tastypie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnseva%2Fdjango-access-tastypie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnseva%2Fdjango-access-tastypie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nnseva","download_url":"https://codeload.github.com/nnseva/django-access-tastypie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252657237,"owners_count":21783789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["access","authority","authorization-backend","django","django-access","django-tastypie","dynamic","evaluation","evaluation-based","guard","instance-level","permissions","rights","rights-management","row-level","runtime","tastypie"],"created_at":"2024-11-13T17:47:08.061Z","updated_at":"2025-05-06T09:31:29.340Z","avatar_url":"https://github.com/nnseva.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Tests](https://github.com/nnseva/django-access-tastypie/actions/workflows/test.yml/badge.svg)](https://github.com/nnseva/django-access-tastypie/actions/workflows/test.yml)\n\n# Django-Access-Tastypie\n\nThe Django-Access-Tastypie package provides an authorization backend for the [Django-Tastypie](https://django-tastypie.readthedocs.io/en/latest/) package to use access rules defined by the [Django-Access](https://github.com/nnseva/django-access) package.\n\n## Installation\n\n*Stable version* from the PyPi package repository\n```bash\npip install django-access-tastypie\n```\n\n*Last development version* from the GitHub source version control system\n```bash\npip install git+git://github.com/nnseva/django-access-tastypie.git\n```\n\n## Configuration\n\nInclude the `tastypie`, `access`, and `access_tastypie` applications into the `INSTALLED_APPS` list, like:\n\n```python\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    ...\n    'tastypie',\n    'access',\n    'access_tastypie',\n    ...\n]\n```\n\n## Using\n\n### Define access rules\n\nDefine access rules as it is described in the [Django-Access](https://github.com/nnseva/django-access) package documentation.\n\n### Modified model resource\n\nYou should use modified `ModelResource` successors in your project.\n\nThe `access_tastypie.resources.AccessModelResourceMixin` may be used to mix into any existent `tastypie.resources.ModelResource` successor.\n\nThe `access_tastypie.resources.AccessModelResource` may be used as a base class for your own model resource instead of `tastypie.resources.ModelResource` class. Really it is a pure combination of `access_tastypie.resources.AccessModelResourceMixin` and`tastypie.resources.ModelResource` base classes.\n\n### Authorization backend\n\nYou should use `access_tastypie.authorization.AccessAuthorization` authorization backend **instead** of `tastypie.authorization.DjangoAuthorization`. It will totally replace authorization algorithm to take access rules defined for your project in account while requesting your api.\n\n## Example\n\nHaving in mind the [example](https://github.com/nnseva/django-access#examples) defined for the [Django-Access](https://github.com/nnseva/django-access), let we describe the api resources as the following:\n\n```python\nfrom tastypie.resources import ModelResource, ALL_WITH_RELATIONS\nfrom tastypie.authentication import MultiAuthentication, SessionAuthentication\n\nfrom access_tastypie.authorization import AccessAuthorization\nfrom access_tastypie.resources import AccessModelResource\n\nfrom django.contrib.auth import models as auth_models\n\nclass UserResource(AccessModelResource):\n    class Meta:\n        queryset = auth_models.User.objects.all()\n        filtering = dict([(f.name, ALL_WITH_RELATIONS) for f in queryset.model._meta.get_fields()])\n        authentication = MultiAuthentication(\n            SessionAuthentication()\n        )\n        authorization = AccessAuthorization()\n        resource_name = 'user'\n        always_return_data = True\n        excludes = ['password']\n\nclass GroupResource(AccessModelResource):\n    class Meta:\n        queryset = auth_models.Group.objects.all()\n        filtering = dict([(f.name, ALL_WITH_RELATIONS) for f in queryset.model._meta.get_fields()])\n        authentication = MultiAuthentication(\n            SessionAuthentication()\n        )\n        authorization = AccessAuthorization()\n        resource_name = 'group'\n        always_return_data = True\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnnseva%2Fdjango-access-tastypie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnnseva%2Fdjango-access-tastypie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnnseva%2Fdjango-access-tastypie/lists"}