{
  "id": "task_libraries:authorization/python",
  "path": "/exapedia/python-authorization-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python authorization libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python authorization libraries decide whether an authenticated user may perform an action on a resource. A policy engine evaluates each request against roles, attributes, or relationships stored in a policy model. These libraries let apps and AI agents enforce permissions in one place instead of scattering checks through the code."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python authorization libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#authlib",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F120"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F121"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F124"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F122"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#django",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#djangorestframework",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F161"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F162"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F163"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#django-oauth-toolkit",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F183"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F187"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#openfga-sdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F199"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F200"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F208"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#pycasbin",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F214"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F218"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#authzed",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F233"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F242"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F237"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#django-guardian",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F248"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F249"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F255"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F252"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F250"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#openfga-sdk",
          "label": [
            {
              "t": "text",
              "text": "OpenFGA"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads among dedicated authorization libraries in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F200"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Object grant storage",
            "Separate policy server"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#authlib",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F120"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#django",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F150"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F151"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#djangorestframework",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F161"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F171"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F172"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#django-oauth-toolkit",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F183"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#openfga-sdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F199"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#pycasbin",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F214"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F222"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F223"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#authzed",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F233"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F243"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#django-guardian",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F248"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F256"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F257"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "authlib",
          "name": [
            {
              "t": "fact",
              "fact": "F120"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/authlib/authlib"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/authlib"
            },
            {
              "label": "Docs",
              "href": "https://docs.authlib.org/en/stable/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F127"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F121"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F123"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F122"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.authlib.org/en/stable/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F120"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F139"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/authlib/example-oauth2-server",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F138"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "@bp.route(\"/oauth/authorize\", methods=[\"GET\", \"POST\"])\ndef authorize():\n    user = current_user()\n    if not user:\n        return redirect(\n            url_for(\"home.home\", next=request.script_root + request.full_path)\n        )\n\n    try:\n        grant = authorization.get_consent_grant(end_user=user)\n    except OAuth2Error as error:\n        return authorization.handle_error_response(request, error)\n\n    if request.method == \"GET\":\n        return render_template(\"authorize.html\", user=user, grant=grant)\n\n    grant_user = user if \"confirm\" in request.form else None\n    return authorization.create_authorization_response(\n        grant=grant, grant_user=grant_user\n    )\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/authlib/example-oauth2-server/blob/48f26d549359d189b1c1e75ade96f14d860a8bd1/src/website/routes.py#L107-L126",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F137"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=authlib%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F120"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from authlib.oauth2.rfc6750 import BearerTokenValidator\n\nvalidator = BearerTokenValidator()\nprint(validator.scope_insufficient(\"read:docs\", [\"read:docs\"]))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/authlib/authlib/blob/main/authlib/oauth2/rfc6749/resource_protector.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "resource_protector.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F125"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "django",
          "name": [
            {
              "t": "fact",
              "fact": "F140"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/django/django"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/Django"
            },
            {
              "label": "Docs",
              "href": "https://docs.djangoproject.com/en/stable/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F147"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.djangoproject.com/en/stable/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F140"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/wagtail/wagtail",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F159"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def instances_user_has_any_permission_for(self, user, actions):\n    if user.is_active and user.is_superuser:\n        # active superusers can perform any action (including unrecognised ones)\n        # on any instance\n        return self.model._default_manager.all()\n    elif \"change\" in actions or \"delete\" in actions:\n        if user.has_perm(self._get_permission_name(\"change\")):\n            # user can edit all instances\n            return self.model._default_manager.all()\n        elif user.has_perm(self._get_permission_name(\"add\")):\n            # user can edit their own instances\n            return self.model._default_manager.filter(\n                **{self.owner_field_name: user}\n            )\n        else:\n            # user has no permissions at all on this model\n            return self.model._default_manager.none()\n    else:\n        # action is either not recognised, or is the 'add' action which is\n        # not meaningful for existing instances. As such, non-superusers\n        # cannot perform it on any existing instances.\n        return self.model._default_manager.none()\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/wagtail/wagtail/blob/79eeb4b94dae7761c8e8ff76bf0a29c4b17ace32/wagtail/permission_policies/base.py#L404-L425",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F158"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Django%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F140"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from django.conf import settings\nsettings.configure(\n    SECRET_KEY=\"quickstart-example-only\",\n    INSTALLED_APPS=[\"django.contrib.auth\", \"django.contrib.contenttypes\"],\n    DATABASES={\"default\": {\"ENGINE\": \"django.db.backends.sqlite3\", \"NAME\": \":memory:\"}},\n)\nimport django\ndjango.setup()\nfrom django.core.management import call_command\nfrom django.contrib.auth import get_user_model\nfrom django.contrib.auth.models import Permission\n\ncall_command(\"migrate\", verbosity=0)\nuser = get_user_model().objects.create_user(username=\"library_demo\")\npermission = Permission.objects.get(content_type__app_label=\"auth\", codename=\"view_user\")\nuser.user_permissions.add(permission)\nprint(user.has_perm(\"auth.view_user\"))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/django/django/blob/main/django/contrib/auth/models.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "models.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F145"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "djangorestframework",
          "name": [
            {
              "t": "fact",
              "fact": "F161"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/encode/django-rest-framework"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/djangorestframework"
            },
            {
              "label": "Docs",
              "href": "https://www.django-rest-framework.org/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F168"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F162"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F163"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://www.django-rest-framework.org/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F161"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F182"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/netbox-community/netbox",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F181"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def retrieve(self, request, *args, **kwargs):\n    instance = self.get_object()\n    serializer = self.get_serializer(instance)\n    response = Response(serializer.data)\n    if etag := self._get_etag(instance):\n        response['ETag'] = etag\n    return response\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/netbox-community/netbox/blob/691bb37fb891f64803eb7ec56fe5ebba287b0efe/netbox/netbox/api/viewsets/__init__.py#L77-L83",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F180"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=djangorestframework%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F161"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from django.conf import settings\nsettings.configure(\n    SECRET_KEY=\"quickstart-example-only\",\n    INSTALLED_APPS=[\"django.contrib.auth\", \"django.contrib.contenttypes\", \"rest_framework\"],\n)\nimport django\ndjango.setup()\n\nfrom rest_framework.permissions import IsAdminUser\nfrom rest_framework.response import Response\nfrom rest_framework.test import APIRequestFactory\nfrom rest_framework.views import APIView\n\nclass AdminView(APIView):\n    permission_classes = [IsAdminUser]\n\n    def get(self, request):\n        return Response({\"status\": \"ok\"})\n\nresponse = AdminView.as_view()(APIRequestFactory().get(\"/\"))\nprint(response.status_code)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/encode/django-rest-framework/blob/main/rest_framework/permissions.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "permissions.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F166"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "django-oauth-toolkit",
          "name": [
            {
              "t": "fact",
              "fact": "F183"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/django-oauth/django-oauth-toolkit"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/django-oauth-toolkit"
            },
            {
              "label": "Docs",
              "href": "https://django-oauth-toolkit.readthedocs.io/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F190"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F186"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://django-oauth-toolkit.readthedocs.io/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F183"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import os\nimport django\ndjango.setup()\n\nfrom django.http import HttpResponse\nfrom django.test import RequestFactory\nfrom oauth2_provider.views.generic import ProtectedResourceView\n\nclass ApiEndpoint(ProtectedResourceView):\n    def get(self, request, *args, **kwargs):\n        return HttpResponse(\"Hello, OAuth2!\")\n\nrequest = RequestFactory().get(\n    \"/api/hello\", secure=True, HTTP_HOST=\"localhost\",\n    HTTP_AUTHORIZATION=\"Bearer \" + os.environ[\"OAUTH_ACCESS_TOKEN\"],\n)\nprint(ApiEndpoint.as_view()(request).status_code)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/django-oauth/django-oauth-toolkit/blob/master/docs/tutorial/tutorial_02.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=django-oauth-toolkit%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F183"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F188"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "openfga-sdk",
          "name": [
            {
              "t": "fact",
              "fact": "F199"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/openfga/python-sdk"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/openfga-sdk"
            },
            {
              "label": "Docs",
              "href": "https://openfga.dev/docs/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F206"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F200"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F208"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://openfga.dev/docs/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F199"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nimport os\nfrom openfga_sdk import ClientConfiguration, OpenFgaClient\nfrom openfga_sdk.client import ClientCheckRequest\n\nasync def main():\n    configuration = ClientConfiguration(\n        api_url=os.environ[\"FGA_API_URL\"],\n        store_id=os.environ[\"FGA_STORE_ID\"],\n        authorization_model_id=os.environ[\"FGA_AUTHORIZATION_MODEL_ID\"],\n    )\n    async with OpenFgaClient(configuration) as client:\n        response = await client.check(ClientCheckRequest(\n            user=\"user:anne\", relation=\"viewer\", object=\"document:roadmap\",\n        ))\n        print(response.allowed)\n\nasyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/openfga/python-sdk/blob/main/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=openfga-sdk%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F199"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F204"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "pycasbin",
          "name": [
            {
              "t": "fact",
              "fact": "F214"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/apache/casbin-pycasbin"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/pycasbin"
            },
            {
              "label": "Docs",
              "href": "https://casbin.apache.org/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F12"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F217"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://casbin.apache.org/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F214"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F232"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/pycasbin/fastapi-authz",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F231"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def _enforce(self, scope: Scope, receive: Receive) -> bool:\n    \"\"\"\n    Enforce a request\n\n    :param user: user will be sent to enforcer\n    :param request: ASGI Request\n    :return: Enforce Result\n    \"\"\"\n\n    request = Request(scope, receive)\n\n    path = request.url.path\n    method = request.method\n    if 'user' not in scope:\n        raise RuntimeError(\"Casbin Middleware must work with an Authentication Middleware\")\n\n    assert isinstance(request.user, BaseUser)\n\n    user = request.user.display_name if request.user.is_authenticated else 'anonymous'\n\n    return self.enforcer.enforce(user, path, method)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/pycasbin/fastapi-authz/blob/b809e72db587351be9a29102512a573d3f0e8f06/fastapi_authz/middleware.py#L45-L65",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F230"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Public%20Python%20projects%20using%20pycasbin%20for%20object%20permissions%2C%20request%20authorization%2C%20role%20policies%20and%20attribute-based%20access%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F214"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import casbin\nfrom casbin.model import Model\n\nmodel = Model()\nmodel.load_model_from_text(\"\"\"[request_definition]\nr = sub, obj, act\n\n[policy_definition]\np = sub, obj, act\n\n[policy_effect]\ne = some(where (p.eft == allow))\n\n[matchers]\nm = r.sub == p.sub && r.obj == p.obj && r.act == p.act\"\"\")\nenforcer = casbin.Enforcer(model)\nenforcer.add_policy(\"alice\", \"data1\", \"read\")\nprint(enforcer.enforce(\"alice\", \"data1\", \"read\"))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/apache/casbin-pycasbin/blob/master/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F219"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "authzed",
          "name": [
            {
              "t": "fact",
              "fact": "F233"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/authzed/authzed-py"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/authzed"
            },
            {
              "label": "Docs",
              "href": "https://authzed.com/docs/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F240"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F242"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://authzed.com/docs/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F233"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import os\nfrom authzed.api.v1 import (\n    Client, CheckPermissionRequest, CheckPermissionResponse, ObjectReference, SubjectReference,\n)\nfrom grpcutil import bearer_token_credentials\n\nclient = Client(\n    os.environ[\"AUTHZED_ENDPOINT\"],\n    bearer_token_credentials(os.environ[\"AUTHZED_API_TOKEN\"]),\n)\nresponse = client.CheckPermission(CheckPermissionRequest(\n    resource=ObjectReference(object_type=\"blog/post\", object_id=\"1\"),\n    permission=\"reader\",\n    subject=SubjectReference(object=ObjectReference(object_type=\"blog/user\", object_id=\"emilia\")),\n))\nprint(response.permissionship == CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/authzed/authzed-py/blob/main/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=authzed%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F233"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F238"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "django-guardian",
          "name": [
            {
              "t": "fact",
              "fact": "F248"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/django-guardian/django-guardian"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/django-guardian"
            },
            {
              "label": "Docs",
              "href": "https://django-guardian.readthedocs.io/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F35"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F249"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F255"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F251"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F250"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://django-guardian.readthedocs.io/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F248"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F36"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F37"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F38"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F265"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F266"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/rpkilby/django-rest-framework-guardian",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F265"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def filter_queryset(self, request, queryset, view):\n    # We want to defer this import until runtime, rather than import-time.\n    # See https://github.com/encode/django-rest-framework/issues/4608\n    # (Also see #1624 for why we need to make this import explicitly)\n    from guardian.shortcuts import get_objects_for_user\n\n    user = request.user\n    permission = self.perm_format % {\n        'app_label': queryset.model._meta.app_label,\n        'model_name': queryset.model._meta.model_name,\n    }\n\n    return get_objects_for_user(\n        user, permission, queryset,\n        **self.shortcut_kwargs)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/rpkilby/django-rest-framework-guardian/blob/784a9c8958bf12cdceb6f4161f87d9075994318d/src/rest_framework_guardian/filters.py#L14-L28",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F264"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Public%20Python%20projects%20using%20django-guardian%20for%20object%20permissions%2C%20request%20authorization%2C%20role%20policies%20and%20attribute-based%20access%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F248"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from django.conf import settings\nsettings.configure(\n    SECRET_KEY=\"quickstart-example-only\",\n    INSTALLED_APPS=[\"django.contrib.auth\", \"django.contrib.contenttypes\", \"guardian\"],\n    AUTHENTICATION_BACKENDS=[\"django.contrib.auth.backends.ModelBackend\", \"guardian.backends.ObjectPermissionBackend\"],\n    DATABASES={\"default\": {\"ENGINE\": \"django.db.backends.sqlite3\", \"NAME\": \":memory:\"}},\n)\nimport django\ndjango.setup()\nfrom django.core.management import call_command\nfrom django.contrib.auth import get_user_model\nfrom django.contrib.auth.models import Group\nfrom guardian.shortcuts import assign_perm\n\ncall_command(\"migrate\", verbosity=0)\nuser = get_user_model().objects.create_user(username=\"library_demo\")\ngroup = Group.objects.create(name=\"editable_demo\")\nassign_perm(\"change_group\", user, group)\nprint(user.has_perm(\"auth.change_group\", group))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/django-guardian/django-guardian/blob/main/guardian/shortcuts.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F253"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python authorization library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#pycasbin",
          "label": [
            {
              "t": "text",
              "text": "PyCasbin"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits apps that want role or attribute policies in a config file. "
        },
        {
          "t": "link",
          "href": "#openfga-sdk",
          "label": [
            {
              "t": "text",
              "text": "OpenFGA"
            }
          ]
        },
        {
          "t": "text",
          "text": " and "
        },
        {
          "t": "link",
          "href": "#authzed",
          "label": [
            {
              "t": "text",
              "text": "Authzed"
            }
          ]
        },
        {
          "t": "text",
          "text": " suit relationship-based permissions shared across services. "
        },
        {
          "t": "link",
          "href": "#django-guardian",
          "label": [
            {
              "t": "text",
              "text": "django-guardian"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits Django apps that need per-object permissions."
        }
      ]
    },
    {
      "q": "ABAC vs RBAC: what is the difference?",
      "a": [
        {
          "t": "text",
          "text": "Role-based access control grants permissions through roles assigned to users. Attribute-based access control evaluates attributes of the user, the resource, and the request, such as department or time of day."
        }
      ]
    },
    {
      "q": "Authorization vs authentication: what is the difference?",
      "a": [
        {
          "t": "text",
          "text": "Authentication confirms who a user is. Authorization decides what that user may do after sign-in."
        }
      ]
    },
    {
      "q": "What is SpiceDB?",
      "a": [
        {
          "t": "text",
          "text": "SpiceDB is an open-source permissions database inspired by Google Zanzibar. "
        },
        {
          "t": "link",
          "href": "#authzed",
          "label": [
            {
              "t": "text",
              "text": "Authzed"
            }
          ]
        },
        {
          "t": "text",
          "text": " is its Python client library."
        }
      ]
    },
    {
      "q": "What is OpenFGA?",
      "a": [
        {
          "t": "text",
          "text": "OpenFGA is an open-source authorization engine inspired by Google Zanzibar. Its "
        },
        {
          "t": "link",
          "href": "#openfga-sdk",
          "label": [
            {
              "t": "text",
              "text": "Python SDK"
            }
          ]
        },
        {
          "t": "text",
          "text": " writes relationship tuples and checks permissions."
        }
      ]
    },
    {
      "q": "What is ReBAC?",
      "a": [
        {
          "t": "text",
          "text": "Relationship-based access control grants access from relationships between objects, such as a user who owns a folder. OpenFGA and SpiceDB both implement this model."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, pycasbin",
      "display": "PyCasbin",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, pycasbin",
      "display": "2.3M",
      "asOf": "2026-11-16"
    },
    "F3": {
      "label": "License, pycasbin",
      "display": "Apache-2.0",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, pycasbin",
      "display": "2.8.0, Feb 2026",
      "asOf": "2026-02-02"
    },
    "F5": {
      "label": "Package release date, pycasbin",
      "display": "Feb 2026",
      "asOf": "2026-02-02"
    },
    "F6": {
      "label": "Repository stars, pycasbin",
      "display": "1.8K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Object permissions, pycasbin",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Attribute rules, pycasbin",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Group permissions, pycasbin",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Django integration, pycasbin",
      "display": "Via plugin",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "Install, pycasbin",
      "display": "pip install pycasbin casbin_async_sqlalchemy_adapter sqlalchemy aiosqlite",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "What it does, pycasbin",
      "display": "Enforces authorization policies using configurable access-control models.",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths lead, pycasbin",
      "display": "Supports multiple access-control models",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths, pycasbin",
      "display": "Choose role-based, attribute-based, or domain-scoped policy models.",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths lead, pycasbin",
      "display": "Separates models from policy data",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "strengths, pycasbin",
      "display": "Define the authorization model separately from stored policy rules.",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations lead, pycasbin",
      "display": "Authentication stays with the application",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations, pycasbin",
      "display": "Authenticate the caller before enforcing authorization policies.",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "Quickstart, pycasbin",
      "display": "import asyncio\nimport os\n\nimport casbin\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.orm import sessionmaker\n\nfrom casbin_async_sqlalchemy_adapter import Adapter, CasbinRule\n\n\nasync def get_enforcer():\n    engine = create_async_engine(\"sqlite+aiosqlite://\", future=True)\n    adapter = Adapter(engine)\n    await adapter.create_table()\n\n    async_session = sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)\n    async with async_session() as s:\n        s.add(CasbinRule(ptype=\"p\", v0=\"alice\", v1=\"data1\", v2=\"read\"))\n        s.add(CasbinRule(ptype=\"p\", v0=\"bob\", v1=\"data2\", v2=\"write\"))\n        s.add(CasbinRule(ptype=\"p\", v0=\"data2_admin\", v1=\"data2\", v2=\"read\"))\n        s.add(CasbinRule(ptype=\"p\", v0=\"data2_admin\", v1=\"data2\", v2=\"write\"))\n        s.add(CasbinRule(ptype=\"g\", v0=\"alice\", v1=\"data2_admin\"))\n        await s.commit()\n\n    e = casbin.AsyncEnforcer(\"path/to/model.conf\", adapter)\n    await e.load_policy()\n    return e\n\nasync def main():\n    e = await get_enforcer()\n    if e.enforce(\"alice\", \"data1\", \"read\"):\n        print(\"alice can read data1\")\n    else:\n        print(\"alice can not read data1\")\n\nasyncio.run(main())\n",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "Project function, pycasbin",
      "display": "def _enforce(self, scope: Scope, receive: Receive) -> bool:\n    \"\"\"\n    Enforce a request\n\n    :param user: user will be sent to enforcer\n    :param request: ASGI Request\n    :return: Enforce Result\n    \"\"\"\n\n    request = Request(scope, receive)\n\n    path = request.url.path\n    method = request.method\n    if 'user' not in scope:\n        raise RuntimeError(\"Casbin Middleware must work with an Authentication Middleware\")\n\n    assert isinstance(request.user, BaseUser)\n\n    user = request.user.display_name if request.user.is_authenticated else 'anonymous'\n\n    return self.enforcer.enforce(user, path, method)\n",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Project function reference, pycasbin",
      "display": "middleware.py · _enforce()",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project repository, pycasbin",
      "display": "pycasbin/fastapi-authz",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project stars, pycasbin/fastapi-authz",
      "display": "194",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project push date, pycasbin/fastapi-authz",
      "display": "Mar 2024",
      "asOf": "2024-03-29"
    },
    "F25": {
      "label": "Library name, django-guardian",
      "display": "django-guardian",
      "asOf": "2026-11-17"
    },
    "F26": {
      "label": "Monthly downloads, django-guardian",
      "display": "988.7K",
      "asOf": "2026-11-16"
    },
    "F27": {
      "label": "License, django-guardian",
      "display": "BSD-2-Clause",
      "asOf": "2026-11-17"
    },
    "F28": {
      "label": "Package release, django-guardian",
      "display": "3.5.2, Oct 2026",
      "asOf": "2026-10-20"
    },
    "F29": {
      "label": "Package release date, django-guardian",
      "display": "Oct 2026",
      "asOf": "2026-10-20"
    },
    "F30": {
      "label": "Repository stars, django-guardian",
      "display": "3.9K",
      "asOf": "2026-11-17"
    },
    "F31": {
      "label": "Object permissions, django-guardian",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F32": {
      "label": "Group permissions, django-guardian",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Django integration, django-guardian",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "Install, django-guardian",
      "display": "pip install django-guardian",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "What it does, django-guardian",
      "display": "Adds per-object permissions to Django’s authorization backend.",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "strengths lead, django-guardian",
      "display": "Stores permissions per object",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "strengths, django-guardian",
      "display": "Assign a user permission for one object without granting it globally.",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "strengths lead, django-guardian",
      "display": "Supports users and groups",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths, django-guardian",
      "display": "Assign object permissions to individual users or Django groups.",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "limitations lead, django-guardian",
      "display": "Generic relations need deletion cleanup",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "limitations, django-guardian",
      "display": "Delete object-permission rows when deleting objects linked through generic relations.",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "Quickstart, django-guardian",
      "display": "from django.contrib.auth.models import User, Group\njack = User.objects.create_user('jack', 'jack@example.com', 'topsecretagentjack')\nadmins = Group.objects.create(name='admins')\njack.has_perm('change_group', admins)\nfrom guardian.shortcuts import assign_perm\nassign_perm('change_group', jack, obj=admins)\njack.has_perm('change_group', admins)\njack.has_perm('change_group')\n",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "Project function, django-guardian",
      "display": "def filter_queryset(self, request, queryset, view):\n    # We want to defer this import until runtime, rather than import-time.\n    # See https://github.com/encode/django-rest-framework/issues/4608\n    # (Also see #1624 for why we need to make this import explicitly)\n    from guardian.shortcuts import get_objects_for_user\n\n    user = request.user\n    permission = self.perm_format % {\n        'app_label': queryset.model._meta.app_label,\n        'model_name': queryset.model._meta.model_name,\n    }\n\n    return get_objects_for_user(\n        user, permission, queryset,\n        **self.shortcut_kwargs)\n",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "Project function reference, django-guardian",
      "display": "filters.py · filter_queryset()",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "Project repository, django-guardian",
      "display": "rpkilby/django-rest-framework-guardian",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Project stars, rpkilby/django-rest-framework-guardian",
      "display": "164",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Project push date, rpkilby/django-rest-framework-guardian",
      "display": "Jul 2025",
      "asOf": "2025-07-04"
    },
    "F48": {
      "label": "Library name, rules",
      "display": "rules",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Monthly downloads, rules",
      "display": "504.7K",
      "asOf": "2026-11-16"
    },
    "F50": {
      "label": "License, rules",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "Package release, rules",
      "display": "3.5, Sep 2024",
      "asOf": "2024-09-02"
    },
    "F52": {
      "label": "Package release date, rules",
      "display": "Sep 2024",
      "asOf": "2024-09-02"
    },
    "F53": {
      "label": "Repository stars, rules",
      "display": "2.0K",
      "asOf": "2026-11-17"
    },
    "F54": {
      "label": "Object permissions, rules",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F55": {
      "label": "Attribute rules, rules",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "Group permissions, rules",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F57": {
      "label": "Django integration, rules",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "Install, rules",
      "display": "pip install rules",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "What it does, rules",
      "display": "Builds object-level permission rules from composable Python predicates.",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "strengths lead, rules",
      "display": "Defines permissions in Python",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "strengths, rules",
      "display": "Combine callable predicates without requiring a permission database.",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "strengths lead, rules",
      "display": "Integrates with Django authorization",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "strengths, rules",
      "display": "Use object-permission checks from Django views, templates, and admin.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "limitations lead, rules",
      "display": "Rule sets stay separate",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "limitations, rules",
      "display": "Register authorization predicates with add_perm; add_rule populates a different rule set.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "Quickstart, rules",
      "display": "import rules\n\n\ndef role_is(role_id):\n    @rules.predicate\n    def user_has_role(user):\n        return user.role.id == role_id\n\n    return user_has_role\n\n\nrules.add_perm(\"reports.view_report_abc\", role_is(12))\nrules.add_perm(\"reports.view_report_xyz\", role_is(13))\n\n\n",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "Project function, rules",
      "display": "def make_perm(name, pred, overwrite=False):\n    if rules.perm_exists(name):\n        if overwrite:\n            rules.remove_perm(name)\n        else:\n            return\n    rules.add_perm(name, pred)\n",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "Project function reference, rules",
      "display": "permissions.py · make_perm()",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "Project repository, rules",
      "display": "HumanSignal/label-studio",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "Project stars, HumanSignal/label-studio",
      "display": "28.7K",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "Project push date, HumanSignal/label-studio",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F72": {
      "label": "Library name, py-abac",
      "display": "py-ABAC",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Monthly downloads, py-abac",
      "display": "885",
      "asOf": "2026-11-16"
    },
    "F74": {
      "label": "License, py-abac",
      "display": "Apache 2.0 license",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Package release, py-abac",
      "display": "0.4.1, Nov 2020",
      "asOf": "2020-11-18"
    },
    "F76": {
      "label": "Package release date, py-abac",
      "display": "Nov 2020",
      "asOf": "2020-11-18"
    },
    "F77": {
      "label": "Repository stars, py-abac",
      "display": "82",
      "asOf": "2026-11-17"
    },
    "F78": {
      "label": "Object permissions, py-abac",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "Attribute rules, py-abac",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "Install, py-abac",
      "display": "pip install py-abac[mongo]",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "What it does, py-abac",
      "display": "Evaluates attribute-based access-control policies against structured access requests.",
      "asOf": "2026-11-17"
    },
    "F82": {
      "label": "strengths lead, py-abac",
      "display": "Defines policies as structured data",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "strengths, py-abac",
      "display": "Match subject, resource, action, and request-context attributes.",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "strengths lead, py-abac",
      "display": "Selects policy evaluation algorithms",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "strengths, py-abac",
      "display": "Choose allow-overrides, deny-overrides, or highest-priority evaluation.",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "limitations lead, py-abac",
      "display": "Matching denies override by default",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "limitations, py-abac",
      "display": "Select another algorithm when an allow should override a matching deny.",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "Quickstart, py-abac",
      "display": "from pymongo import MongoClient\nfrom py_abac import PDP, Policy, AccessRequest\nfrom py_abac.storage.mongo import MongoStorage\n\n# Policy definition in JSON\npolicy_json = {\n    \"uid\": \"1\",\n    \"description\": \"Max and Nina are allowed to create, delete, get any \"\n                   \"resources only if the client IP matches.\",\n    \"effect\": \"allow\",\n    \"rules\": {\n        \"subject\": [{\"$.name\": {\"condition\": \"Equals\", \"value\": \"Max\"}},\n                    {\"$.name\": {\"condition\": \"Equals\", \"value\": \"Nina\"}}],\n        \"resource\": {\"$.name\": {\"condition\": \"RegexMatch\", \"value\": \".*\"}},\n        \"action\": [{\"$.method\": {\"condition\": \"Equals\", \"value\": \"create\"}},\n                   {\"$.method\": {\"condition\": \"Equals\", \"value\": \"delete\"}},\n                   {\"$.method\": {\"condition\": \"Equals\", \"value\": \"get\"}}],\n        \"context\": {\"$.ip\": {\"condition\": \"CIDR\", \"value\": \"127.0.0.1/32\"}}\n    },\n    \"targets\": {},\n    \"priority\": 0\n}\n# Parse JSON and create policy object\npolicy = Policy.from_json(policy_json)\n\n# Setup policy storage\nclient = MongoClient()\nstorage = MongoStorage(client)\n# Add policy to storage\nstorage.add(policy)\n\n# Create policy decision point\npdp = PDP(storage)\n\n# A sample access request JSON\nrequest_json = {\n    \"subject\": {\n        \"id\": \"\", \n        \"attributes\": {\"name\": \"Max\"}\n    },\n    \"resource\": {\n        \"id\": \"\", \n        \"attributes\": {\"name\": \"myrn:example.com:resource:123\"}\n    },\n    \"action\": {\n        \"id\": \"\", \n        \"attributes\": {\"method\": \"get\"}\n    },\n    \"context\": {\n        \"ip\": \"127.0.0.1\"\n    }\n}\n# Parse JSON and create access request object\nrequest = AccessRequest.from_json(request_json)\n\n# Check if access request is allowed. Evaluates to True since \n# Max is allowed to get any resource when client IP matches.\nassert pdp.is_allowed(request)\n",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "Developer need",
      "display": "Configurable role and attribute policies",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "Why choose pycasbin",
      "display": "multiple role-based and attribute-based models",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "Developer need in introduction",
      "display": "configurable role and attribute policies",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "When to consider rules",
      "display": "authorization should live in Python predicates",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "Developer need",
      "display": "Permission logic in Python code",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "Why choose rules",
      "display": "composable predicates without a permission database",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "Developer need in introduction",
      "display": "permission logic in Python code",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "When to consider django-guardian",
      "display": "permissions should be assigned and stored per object",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Developer need",
      "display": "Stored Django object permissions",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Why choose django-guardian",
      "display": "per-user object grants through Django authorization",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "Developer need in introduction",
      "display": "stored Django object permissions",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Developer need",
      "display": "Structured attribute policy requests",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Why choose py-abac",
      "display": "explicit subject, resource, action, and context rules",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "Developer need in introduction",
      "display": "structured attribute policy requests",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "When to consider pycasbin",
      "display": "explicit role/domain policy models are needed",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Page introduction",
      "display": "Python authorization libraries let application developers control access to application resources.",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "FAQ: Which Python authorization library should I choose?",
      "display": "PyCasbin supports configurable role/domain and attribute-based policies.",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "FAQ: Which Python authorization library should I choose?",
      "display": "rules defines permissions with Python predicates without requiring a database.",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "FAQ: Which Python authorization library should I choose?",
      "display": "django-guardian adds per-object permission grants to Django.",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "FAQ: Which Python authorization library should I choose?",
      "display": "py-ABAC evaluates attribute-based policies.",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "FAQ: Does PyCasbin authenticate a username and password?",
      "display": "Authentication is outside PyCasbin; the application must authenticate the caller.",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "FAQ: Does granting access to one object grant global access?",
      "display": "Guardian demonstrates an object-specific grant that does not give the user the same global permission.",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "FAQ: Why is a rules predicate missing from permission checks?",
      "display": "The shared rule set and Django permission set are separate; adding to one does not add to the other.",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "FAQ: What happens to Guardian permissions after an object is deleted?",
      "display": "With generic object relations, applications should explicitly remove permission rows when deleting protected objects.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: What happens to Guardian permissions after an object is deleted?",
      "display": "The orphaned-permission caveat does not apply in the same way when direct foreign keys are used.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: Can groups receive object permissions?",
      "display": "Guardian stores user and group object-permission records.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: Can groups receive object permissions?",
      "display": "rules provides an is_group_member predicate factory.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: What happens when py-ABAC allow and deny policies both match?",
      "display": "The default PDP evaluation algorithm is deny-overrides.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: What happens when py-ABAC allow and deny policies both match?",
      "display": "Other supported algorithms include allow-overrides and highest-priority.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Can py-ABAC persist policies in a database?",
      "display": "The basic package supports in-memory storage; persistent MongoDB and SQL backends use extras.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Is the current PyCasbin install named casbin?",
      "display": "The current own README installs the pycasbin distribution while Python code still imports casbin.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "Library name, authlib",
      "display": "Authlib",
      "asOf": "2026-11-20"
    },
    "F121": {
      "label": "Monthly downloads, authlib",
      "display": "137.9M",
      "asOf": "2026-11-20"
    },
    "F122": {
      "label": "License, authlib",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F123": {
      "label": "Package release, authlib",
      "display": "1.9.9",
      "asOf": "2026-11-20"
    },
    "F124": {
      "label": "Package release date, authlib",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F125": {
      "label": "Install, authlib",
      "display": "pip install Authlib",
      "asOf": "2026-11-20"
    },
    "F126": {
      "label": "Quickstart, authlib",
      "display": "from authlib.oauth2.rfc6750 import BearerTokenValidator\n\nvalidator = BearerTokenValidator()\nprint(validator.scope_insufficient(\"read:docs\", [\"read:docs\"]))\n",
      "asOf": "2026-11-20"
    },
    "F127": {
      "label": "Official description, authlib",
      "display": "Builds OAuth and OpenID Connect servers and clients.",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Quickstart source file, authlib",
      "display": "authlib/oauth2/rfc6749/resource_protector.py",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "Repository stars, authlib",
      "display": "5.5K",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "Object grant storage, authlib",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Separate policy server, authlib",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Authorization layer and role, authlib",
      "display": "OAuth2 authorization-server and resource-server protocol framework,including consent grants and native scope enforcement. Whole-package downloads cover OAuth/OIDC clients and other protocol uses as well.",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "First-call setup, authlib",
      "display": "[\"Current1.9.9 requires Python>=3.10. This first call is the native scope-set predicate only,not complete bearer-token authentication or expiry/revocation validation. A real resource guard registers the application token lookup/validator and uses ResourceProtector; the advanced example demonstrates authorization-server consent. Required scope groups use OR across entries and AND within a space-separated entry.\"]",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Permission storage and deployment boundary, authlib",
      "display": "{\"Object grant storage\": \"Native OAuth token/scope/consent machinery does not provide a first-class persisted subject/resource-instance ACL store. Caller token models and opaque resource scopes are different from resource relationship/grant records.\", \"Separate policy server\": \"Scope decisions execute inside the application; no separate policy-decision server is mandatory. Registered token lookup can use a database or optional introspection,which are separate configuration choices.\"}",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Actual project arguments and consumed returns, authlib",
      "display": "{\"status\": \"verified\", \"arguments\": \"Whole original Authlib OAuth2 server consent route first requires the actual current_user,then asks the configured native AuthorizationServer for a consent grant with end_user=user. Current1.9.9 accepts that parameter. GET renders the grant; POST passes the exact grant back with grant_user set to the same user on confirmation or None on denial. OAuth2Error is caught and passed with actual Flask request to the current inherited handle_error_response. These methods are defined in current core AuthorizationServer and inherited by the Flask implementation. Same project config registers its client/token lookup and grant handlers; no generic authentication-only token parsing counted as this authorization workflow.\", \"return_shape\": \"get_consent_grant returns the validated grant used by both the template and final authorization response. Current create_authorization_response explicitly accepts grant plus grant_user and returns a framework response. Error response is a native framework response as well. The three operations are alternative GET,POST,and error paths,not three unconditional requests. No server,session,consent,or token endpoint executed.\"}",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Project function, authlib",
      "display": "@bp.route(\"/oauth/authorize\", methods=[\"GET\", \"POST\"])\ndef authorize():\n    user = current_user()\n    if not user:\n        return redirect(\n            url_for(\"home.home\", next=request.script_root + request.full_path)\n        )\n\n    try:\n        grant = authorization.get_consent_grant(end_user=user)\n    except OAuth2Error as error:\n        return authorization.handle_error_response(request, error)\n\n    if request.method == \"GET\":\n        return render_template(\"authorize.html\", user=user, grant=grant)\n\n    grant_user = user if \"confirm\" in request.form else None\n    return authorization.create_authorization_response(\n        grant=grant, grant_user=grant_user\n    )\n",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Project source file, authlib",
      "display": "src/website/routes.py",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Project full_name, authlib",
      "display": "authlib/example-oauth2-server",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Project stargazers_count, authlib",
      "display": "702",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Library name, Django",
      "display": "Django",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Monthly downloads, Django",
      "display": "51.9M",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "License, Django",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Package release, Django",
      "display": "6.1.3",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Package release date, Django",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Install, Django",
      "display": "python -m pip install Django",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Quickstart, Django",
      "display": "from django.conf import settings\nsettings.configure(\n    SECRET_KEY=\"quickstart-example-only\",\n    INSTALLED_APPS=[\"django.contrib.auth\", \"django.contrib.contenttypes\"],\n    DATABASES={\"default\": {\"ENGINE\": \"django.db.backends.sqlite3\", \"NAME\": \":memory:\"}},\n)\nimport django\ndjango.setup()\nfrom django.core.management import call_command\nfrom django.contrib.auth import get_user_model\nfrom django.contrib.auth.models import Permission\n\ncall_command(\"migrate\", verbosity=0)\nuser = get_user_model().objects.create_user(username=\"library_demo\")\npermission = Permission.objects.get(content_type__app_label=\"auth\", codename=\"view_user\")\nuser.user_permissions.add(permission)\nprint(user.has_perm(\"auth.view_user\"))\n",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Official description, Django",
      "display": "Provides a high-level Python web framework.",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Quickstart source file, Django",
      "display": "django/contrib/auth/models.py",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Repository stars, Django",
      "display": "91.8K",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Object grant storage, Django",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Separate policy server, Django",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Authorization layer and role, Django",
      "display": "Full web framework with dedicated public User/Group model-permission APIs and replaceable authorization backends; core lacks per-object grant storage.",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "First-call setup, Django",
      "display": "[\"Current6.1.3 requires Python>=3.12. Run in a fresh process with SQLite support; recipe bootstraps only an in-memory database rather than editing an existing project. It creates a demonstration user,assigns model-wide auth.view_user,and makes one permission check. That permission covers the model,not one user-row object.\"]",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Permission storage and deployment boundary, Django",
      "display": "{\"Object grant storage\": \"Core has model-wide User/Group permissions but no built-in persisted per-instance permission backend. A plugin such as Guardian can implement that separate backend.\", \"Separate policy server\": \"Default ModelBackend evaluates model/user/group permissions through Django ORM inside the app. It requires the configured database,not a separate dedicated policy server; custom backends can choose a different architecture.\"}",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Actual project arguments and consumed returns, Django",
      "display": "{\"status\": \"verified\", \"arguments\": \"Whole Wagtail OwnershipPermissionPolicy.instances_user_has_any_permission_for uses current Django user.has_perm with app-qualified model permission strings produced by the same-file helper. Active superusers get all instances. Change permission grants the whole queryset; otherwise add permission plus the model owner field restricts results to instances owned by that user. Actual model/default manager must provide standard all,filter,and none querysets,and configured owner_field_name must be a valid user relation. Two native has_perm call sites are alternative permission branches; application ownership logic is not falsely described as built-in Django per-object grant storage.\", \"return_shape\": \"has_perm returns bool. The method returns the original model queryset,an owner-filtered queryset,or an empty queryset; it does not execute/eagerly enumerate all rows. Current Django QuerySet.filter accepts the exact dynamic field=user keyword mapping. Inactive/non-superuser handling follows the complete original branches. No source modernization or database operations executed.\"}",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Permission cache after grant changes, Django",
      "display": "ModelBackend caches the first fetched permission set on the User instance. Re-fetch the user before checking a newly added grant; refresh_from_db does not clear that permission cache. The first-call recipe grants before its first check.",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Project function, Django",
      "display": "def instances_user_has_any_permission_for(self, user, actions):\n    if user.is_active and user.is_superuser:\n        # active superusers can perform any action (including unrecognised ones)\n        # on any instance\n        return self.model._default_manager.all()\n    elif \"change\" in actions or \"delete\" in actions:\n        if user.has_perm(self._get_permission_name(\"change\")):\n            # user can edit all instances\n            return self.model._default_manager.all()\n        elif user.has_perm(self._get_permission_name(\"add\")):\n            # user can edit their own instances\n            return self.model._default_manager.filter(\n                **{self.owner_field_name: user}\n            )\n        else:\n            # user has no permissions at all on this model\n            return self.model._default_manager.none()\n    else:\n        # action is either not recognised, or is the 'add' action which is\n        # not meaningful for existing instances. As such, non-superusers\n        # cannot perform it on any existing instances.\n        return self.model._default_manager.none()\n",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Project source file, Django",
      "display": "wagtail/permission_policies/base.py",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Project full_name, Django",
      "display": "wagtail/wagtail",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Project stargazers_count, Django",
      "display": "20.7K",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Library name, djangorestframework",
      "display": "Django REST framework",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Monthly downloads, djangorestframework",
      "display": "30.2M",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "License, djangorestframework",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Package release, djangorestframework",
      "display": "3.18.3",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Package release date, djangorestframework",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Install, djangorestframework",
      "display": "pip install djangorestframework",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Quickstart, djangorestframework",
      "display": "from django.conf import settings\nsettings.configure(\n    SECRET_KEY=\"quickstart-example-only\",\n    INSTALLED_APPS=[\"django.contrib.auth\", \"django.contrib.contenttypes\", \"rest_framework\"],\n)\nimport django\ndjango.setup()\n\nfrom rest_framework.permissions import IsAdminUser\nfrom rest_framework.response import Response\nfrom rest_framework.test import APIRequestFactory\nfrom rest_framework.views import APIView\n\nclass AdminView(APIView):\n    permission_classes = [IsAdminUser]\n\n    def get(self, request):\n        return Response({\"status\": \"ok\"})\n\nresponse = AdminView.as_view()(APIRequestFactory().get(\"/\"))\nprint(response.status_code)\n",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Official description, djangorestframework",
      "display": "Builds web APIs for Django.",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Quickstart source file, djangorestframework",
      "display": "rest_framework/permissions.py",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Repository stars, djangorestframework",
      "display": "30.2K",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Object grant storage, djangorestframework",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Separate policy server, djangorestframework",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Authorization layer and role, djangorestframework",
      "display": "API framework with native permission classes,view/object check lifecycle,and extensible Django permission-backend integration. It does not persist resource ACLs itself.",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "First-call setup, djangorestframework",
      "display": "[\"Use a fresh Python process with supported Django installed by the SDK. This minimal in-process request exercises native IsAdminUser; an anonymous request is denied before the get body. It is not a configured production login/token server and does not persist an object ACL.\"]",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Permission storage and deployment boundary, djangorestframework",
      "display": "{\"Object grant storage\": \"Native permission classes/check hooks do not themselves persist per-instance grants. DjangoObjectPermissions delegates to a supplied Django object-permission backend such as Guardian.\", \"Separate policy server\": \"Native check_permissions/check_object_permissions evaluate configured Python permission classes in the API process. A custom class can call an external server,but none is required by the default SDK architecture.\"}",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Actual project arguments and consumed returns, djangorestframework",
      "display": "{\"status\": \"verified\", \"arguments\": \"Whole NetBox ETagMixin.retrieve calls actual inherited DRF GenericAPIView.get_object through GenericViewSet,then uses the host serializer and constructs native Response(serializer.data). get_object applies the configured filtered queryset and calls check_object_permissions before returning the object. The immutable same file composes ETagMixin with BaseViewSet(GenericViewSet) and restricts authenticated querysets in initial; native get_object is not overridden by these classes. NetBox get_serializer IS overridden and is deliberately not counted as a native DRF invocation. Its application permission backend/query restrictions determine actual visibility,not the ETag helper.\", \"return_shape\": \"get_object returns one authorized object or raises the configured lookup/permission error before response construction. Response accepts the serialized primitive data; setting ETag uses its supported response-header mapping. The helper returns Response with an optional timestamp-derived weak ETag. That ETag is application cache/concurrency metadata,not a grant. No HTTP request or object lookup executed.\"}",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Default permission policy, djangorestframework",
      "display": "Absent explicit DEFAULT_PERMISSION_CLASSES or per-view policy,DRF defaults to AllowAny/unrestricted access. The first-call recipe deliberately sets IsAdminUser.",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Collection and create permission checks, djangorestframework",
      "display": "Generic list views do not automatically run object-level checks on each queryset instance. Filter the queryset for object visibility. Creation does not call get_object,so has_object_permission is not automatically applied; use serializer or perform_create checks.",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Project function, djangorestframework",
      "display": "def retrieve(self, request, *args, **kwargs):\n    instance = self.get_object()\n    serializer = self.get_serializer(instance)\n    response = Response(serializer.data)\n    if etag := self._get_etag(instance):\n        response['ETag'] = etag\n    return response\n",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Project source file, djangorestframework",
      "display": "netbox/netbox/api/viewsets/__init__.py",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Project full_name, djangorestframework",
      "display": "netbox-community/netbox",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Project stargazers_count, djangorestframework",
      "display": "21.9K",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Library name, django-oauth-toolkit",
      "display": "Django OAuth Toolkit",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Monthly downloads, django-oauth-toolkit",
      "display": "6.8M",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "License, django-oauth-toolkit",
      "display": "BSD-2-Clause-Views",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Package release, django-oauth-toolkit",
      "display": "3.4.1",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Package release date, django-oauth-toolkit",
      "display": "Aug 2026",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Install, django-oauth-toolkit",
      "display": "pip install django-oauth-toolkit",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Quickstart, django-oauth-toolkit",
      "display": "import os\nimport django\ndjango.setup()\n\nfrom django.http import HttpResponse\nfrom django.test import RequestFactory\nfrom oauth2_provider.views.generic import ProtectedResourceView\n\nclass ApiEndpoint(ProtectedResourceView):\n    def get(self, request, *args, **kwargs):\n        return HttpResponse(\"Hello, OAuth2!\")\n\nrequest = RequestFactory().get(\n    \"/api/hello\", secure=True, HTTP_HOST=\"localhost\",\n    HTTP_AUTHORIZATION=\"Bearer \" + os.environ[\"OAUTH_ACCESS_TOKEN\"],\n)\nprint(ApiEndpoint.as_view()(request).status_code)\n",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Official description, django-oauth-toolkit",
      "display": "Runs an OAuth authorization server inside Django.",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Quickstart source file, django-oauth-toolkit",
      "display": "docs/tutorial/tutorial_02.rst",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Repository stars, django-oauth-toolkit",
      "display": "3.3K",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Object grant storage, django-oauth-toolkit",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Separate policy server, django-oauth-toolkit",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Authorization layer and role, django-oauth-toolkit",
      "display": "Django OAuth2 authorization/resource server with application/token models and explicit token-scope permission classes; client authorization is distinct from generic resource ACLs.",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "First-call setup, django-oauth-toolkit",
      "display": "[\"Requires an existing configured,migrated Django OAuth Toolkit project and a valid token created by tutorial part1. Set DJANGO_SETTINGS_MODULE and OAUTH_ACCESS_TOKEN,and allow localhost in project ALLOWED_HOSTS or adjust the request host. This recipe adapts the official basic protected resource plus first bearer request to Django RequestFactory,without starting a network server. The view requires a valid token but does not add a nonempty required-scope list. Current3.4.1 old public view import is an explicit compatibility shim.\"]",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Permission storage and deployment boundary, django-oauth-toolkit",
      "display": "{\"Object grant storage\": \"Native persisted OAuth applications,tokens,and scope strings are not a generic subject/resource-instance grant relation store. TokenHasResourceScope concerns configured resource-name scopes,not a built-in per-object ACL table.\", \"Separate policy server\": \"Default authorization/resource-server implementation runs in the Django application with its model store. No additional policy-decision server is mandatory; remote resource-server/introspection deployment is optional.\"}",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Exact package license variant, django-oauth-toolkit",
      "display": "BSD-2-Clause-Views. The two-clause grant includes the additional views-and-conclusions sentence; BSD-2-Clause-FreeBSD is the deprecated SPDX variant name,not a second license.",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Library name, openfga-sdk",
      "display": "OpenFGA",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Monthly downloads, openfga-sdk",
      "display": "3.2M",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "License, openfga-sdk",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Package release, openfga-sdk",
      "display": "0.10.6",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Package release date, openfga-sdk",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Install, openfga-sdk",
      "display": "pip3 install openfga_sdk",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Quickstart, openfga-sdk",
      "display": "import asyncio\nimport os\nfrom openfga_sdk import ClientConfiguration, OpenFgaClient\nfrom openfga_sdk.client import ClientCheckRequest\n\nasync def main():\n    configuration = ClientConfiguration(\n        api_url=os.environ[\"FGA_API_URL\"],\n        store_id=os.environ[\"FGA_STORE_ID\"],\n        authorization_model_id=os.environ[\"FGA_AUTHORIZATION_MODEL_ID\"],\n    )\n    async with OpenFgaClient(configuration) as client:\n        response = await client.check(ClientCheckRequest(\n            user=\"user:anne\", relation=\"viewer\", object=\"document:roadmap\",\n        ))\n        print(response.allowed)\n\nasyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Official description, openfga-sdk",
      "display": "Provides an authorization engine inspired by Google Zanzibar.",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Quickstart source file, openfga-sdk",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Repository stars, openfga-sdk",
      "display": "88",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Object grant storage, openfga-sdk",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Separate policy server, openfga-sdk",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Authorization layer and role, openfga-sdk",
      "display": "Remote relationship-based authorization SDK using explicit store/model/user/relation/object inputs; OpenFGA server performs the decision.",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "First-call setup, openfga-sdk",
      "display": "[\"Requires Python>=3.10 and a running reachable OpenFGA server with an existing store,authorization model,and valid user/relation/object types. Set the three environment variables. This minimal recipe assumes a local/service endpoint that does not require added API credentials; configure the documented Credentials when server authentication is enabled. No store,model,or permission tuple is created by the check.\"]",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Permission storage and deployment boundary, openfga-sdk",
      "display": "{\"Object grant storage\": \"Native SDK writes persisted subject/relation/object tuples to a running OpenFGA store. The server holds/evaluates these relationships; Python SDK is not an embedded local engine.\", \"Separate policy server\": \"SDK sends authorization API requests to an OpenFGA server,including a caller-hosted local instance. Store/model/server setup is required; mock unit responses are not production permission decisions.\"}",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Library name, pycasbin",
      "display": "PyCasbin",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Monthly downloads, pycasbin",
      "display": "2.4M",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "License, pycasbin",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Package release, pycasbin",
      "display": "2.8.0",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Package release date, pycasbin",
      "display": "Feb 2026",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Install, pycasbin",
      "display": "pip install pycasbin",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Quickstart, pycasbin",
      "display": "import casbin\nfrom casbin.model import Model\n\nmodel = Model()\nmodel.load_model_from_text(\"\"\"[request_definition]\nr = sub, obj, act\n\n[policy_definition]\np = sub, obj, act\n\n[policy_effect]\ne = some(where (p.eft == allow))\n\n[matchers]\nm = r.sub == p.sub && r.obj == p.obj && r.act == p.act\"\"\")\nenforcer = casbin.Enforcer(model)\nenforcer.add_policy(\"alice\", \"data1\", \"read\")\nprint(enforcer.enforce(\"alice\", \"data1\", \"read\"))\n",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Repository stars, pycasbin",
      "display": "1.8K",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Object grant storage, pycasbin",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Separate policy server, pycasbin",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Authorization layer and role, pycasbin",
      "display": "Embedded configurable authorization policy engine with ACL,RBAC,and ABAC model families. Official current distribution is pycasbin while import remains casbin.",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "First-call setup, pycasbin",
      "display": "[\"Current official installation uses pycasbin2.8 while its import remains casbin; do not install both casbin and pycasbin distributions into one environment. Recipe loads the unchanged official basic model in memory and adds one native policy,so no external files or policy server are required. Model has subject,object,and action fields. Native default policy is not an authentication system.\"]",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Permission storage and deployment boundary, pycasbin",
      "display": "{\"Object grant storage\": \"Native ACL model/policy stores subject,resource,and action grants. Default file adapter and optional other adapters persist policy; the first-call recipe intentionally uses in-memory policy only.\", \"Separate policy server\": \"Native Enforcer evaluates loaded model/policy inside the application. A policy adapter or watcher can use external persistence/coordination,but a dedicated policy server is not mandatory.\"}",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Actual project arguments and consumed returns, pycasbin",
      "display": "{\"status\": \"verified\", \"arguments\": \"Whole actual fastapi-authz CasbinMiddleware._enforce builds the ASGI Request from scope/receive,requires upstream AuthenticationMiddleware,and chooses its authenticated display name or anonymous subject. The actual Enforcer is provided to middleware; current selected PyCasbin2.8 import remains casbin and enforce accepts subject,path,method via variadic rvals. Configured model must define exactly the corresponding subject/object/action request fields and matching policy; this function does not authenticate a user or infer an ACL. Existing older consumer package pins are context,not a rejection reason.\", \"return_shape\": \"Current sync Enforcer.enforce returns bool and the whole middleware method returns that decision. HTTP request/url extraction is Starlette peer behavior,not another Casbin call. It invokes the synchronous native engine,not AsyncEnforcer. Whole task method is within6–40lines and uses the single-call exception. No ASGI application or policy engine executed.\"}",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Distribution and import namespace, pycasbin",
      "display": "Official README now installs pycasbin2.8.0 but imports casbin. Older casbin1.43.0 distribution has a higher separate download count and remains related; counts are neither added nor presented as unique users. Both distributions should not be installed together because they supply the same import namespace.",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Project function, pycasbin",
      "display": "def _enforce(self, scope: Scope, receive: Receive) -> bool:\n    \"\"\"\n    Enforce a request\n\n    :param user: user will be sent to enforcer\n    :param request: ASGI Request\n    :return: Enforce Result\n    \"\"\"\n\n    request = Request(scope, receive)\n\n    path = request.url.path\n    method = request.method\n    if 'user' not in scope:\n        raise RuntimeError(\"Casbin Middleware must work with an Authentication Middleware\")\n\n    assert isinstance(request.user, BaseUser)\n\n    user = request.user.display_name if request.user.is_authenticated else 'anonymous'\n\n    return self.enforcer.enforce(user, path, method)\n",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Project source file, pycasbin",
      "display": "fastapi_authz/middleware.py",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Project full_name, pycasbin",
      "display": "pycasbin/fastapi-authz",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Project stargazers_count, pycasbin",
      "display": "194",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Library name, authzed",
      "display": "Authzed",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Monthly downloads, authzed",
      "display": "1.3M",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "License, authzed",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Package release, authzed",
      "display": "1.25.0",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Package release date, authzed",
      "display": "Jul 2026",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Install, authzed",
      "display": "pip install authzed",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Quickstart, authzed",
      "display": "import os\nfrom authzed.api.v1 import (\n    Client, CheckPermissionRequest, CheckPermissionResponse, ObjectReference, SubjectReference,\n)\nfrom grpcutil import bearer_token_credentials\n\nclient = Client(\n    os.environ[\"AUTHZED_ENDPOINT\"],\n    bearer_token_credentials(os.environ[\"AUTHZED_API_TOKEN\"]),\n)\nresponse = client.CheckPermission(CheckPermissionRequest(\n    resource=ObjectReference(object_type=\"blog/post\", object_id=\"1\"),\n    permission=\"reader\",\n    subject=SubjectReference(object=ObjectReference(object_type=\"blog/user\", object_id=\"emilia\")),\n))\nprint(response.permissionship == CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION)\n",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Official description, authzed",
      "display": "Provides the client library for SpiceDB.",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Quickstart source file, authzed",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Repository stars, authzed",
      "display": "51",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Object grant storage, authzed",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Separate policy server, authzed",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Authorization layer and role, authzed",
      "display": "SpiceDB/Authzed gRPC SDK for relationship data,schema management,and permission checks; native request/response messages carry explicit permissionship enums.",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "First-call setup, authzed",
      "display": "[\"Current1.25 requires Python>=3.10,<4. Set an actual TLS gRPC endpoint and API token. Server schema must define the shown blog/user,blog/post,and reader permission,and relationships must already exist. This compares the explicit permissionship enum rather than truth-testing an arbitrary response. Local insecure development uses the distinct documented InsecureClient.\"]",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "Permission storage and deployment boundary, authzed",
      "display": "{\"Object grant storage\": \"Native v1 API writes relationship records and schemas to SpiceDB/Authzed,which stores resource/subject relationships and computes permission sets. SDK itself is a service client.\", \"Separate policy server\": \"Native Python client requires a SpiceDB/Authzed gRPC endpoint for permission operations. TLS and local insecure clients are distinct deployment modes; no embedded policy evaluator is bundled.\"}",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Library name, django-guardian",
      "display": "django-guardian",
      "asOf": "2026-11-20"
    },
    "F249": {
      "label": "Monthly downloads, django-guardian",
      "display": "1.1M",
      "asOf": "2026-11-20"
    },
    "F250": {
      "label": "License, django-guardian",
      "display": "BSD-2-Clause; CC-BY-4.0 (icons)",
      "asOf": "2026-11-20"
    },
    "F251": {
      "label": "Package release, django-guardian",
      "display": "3.5.2",
      "asOf": "2026-11-20"
    },
    "F252": {
      "label": "Package release date, django-guardian",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F253": {
      "label": "Install, django-guardian",
      "display": "pip install django-guardian",
      "asOf": "2026-11-20"
    },
    "F254": {
      "label": "Quickstart, django-guardian",
      "display": "from django.conf import settings\nsettings.configure(\n    SECRET_KEY=\"quickstart-example-only\",\n    INSTALLED_APPS=[\"django.contrib.auth\", \"django.contrib.contenttypes\", \"guardian\"],\n    AUTHENTICATION_BACKENDS=[\"django.contrib.auth.backends.ModelBackend\", \"guardian.backends.ObjectPermissionBackend\"],\n    DATABASES={\"default\": {\"ENGINE\": \"django.db.backends.sqlite3\", \"NAME\": \":memory:\"}},\n)\nimport django\ndjango.setup()\nfrom django.core.management import call_command\nfrom django.contrib.auth import get_user_model\nfrom django.contrib.auth.models import Group\nfrom guardian.shortcuts import assign_perm\n\ncall_command(\"migrate\", verbosity=0)\nuser = get_user_model().objects.create_user(username=\"library_demo\")\ngroup = Group.objects.create(name=\"editable_demo\")\nassign_perm(\"change_group\", user, group)\nprint(user.has_perm(\"auth.change_group\", group))\n",
      "asOf": "2026-11-20"
    },
    "F255": {
      "label": "Repository stars, django-guardian",
      "display": "3.9K",
      "asOf": "2026-11-20"
    },
    "F256": {
      "label": "Object grant storage, django-guardian",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F257": {
      "label": "Separate policy server, django-guardian",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F258": {
      "label": "Authorization layer and role, django-guardian",
      "display": "Django per-object permission storage and backend with native grant/query shortcuts; complements model-wide core permissions rather than replacing authentication.",
      "asOf": "2026-11-20"
    },
    "F259": {
      "label": "First-call setup, django-guardian",
      "display": "[\"Use a fresh process and supported Django with SQLite. Disclosed recipe configures the Guardian app/backend,migrates only an in-memory database,and grants permission on one actual built-in Group instance before checking that object. App/server deployment uses normal Django project settings instead. The package Python license and static-icon license have separate scopes.\"]",
      "asOf": "2026-11-20"
    },
    "F260": {
      "label": "Permission storage and deployment boundary, django-guardian",
      "display": "{\"Object grant storage\": \"Native object-permission backend/shortcuts persist grants on Django model instances. Its model tables/migrations and backend configuration are required.\", \"Separate policy server\": \"Native backend evaluates object grants through the configured Django database in the application. Database availability is required,but no separate dedicated policy-decision server is mandatory.\"}",
      "asOf": "2026-11-20"
    },
    "F261": {
      "label": "Actual project arguments and consumed returns, django-guardian",
      "display": "{\"status\": \"verified\", \"arguments\": \"Whole actual DRF-guardian ObjectPermissionsFilter.filter_queryset imports the native guardian shortcut,builds app_label.view_model_name from the supplied queryset model,and passes user,permission,and that queryset as third positional klass argument plus original shortcut_kwargs. Current3.5.2 supports a QuerySet klass and accept_global_perms argument used by the actual enclosing filter. Appropriate object permission backend,Django apps,migrations,and permissions must already be configured. This filters object visibility; it does not by itself grant permissions or authenticate the request.\", \"return_shape\": \"Current shortcut returns a QuerySet restricted by the requested permission rules. Source querysets remain lazy and existing filters preserved. Actual accept_global_perms=False avoids letting global model grants substitute for object grants in this integration; configured superuser/group handling remains native shortcut behavior. Whole17line filter task uses one native call; SDK setup/imports are retained,not counted as extra invocations.\"}",
      "asOf": "2026-11-20"
    },
    "F262": {
      "label": "Code and static-asset license scopes, django-guardian",
      "display": "{\"Python code\": \"BSD-2-Clause\", \"SVG icons\": \"CC-BY-4.0\", \"icon_scope\": \"guardian/static/guardian/img\"}",
      "asOf": "2026-11-20"
    },
    "F263": {
      "label": "Project function, django-guardian",
      "display": "def filter_queryset(self, request, queryset, view):\n    # We want to defer this import until runtime, rather than import-time.\n    # See https://github.com/encode/django-rest-framework/issues/4608\n    # (Also see #1624 for why we need to make this import explicitly)\n    from guardian.shortcuts import get_objects_for_user\n\n    user = request.user\n    permission = self.perm_format % {\n        'app_label': queryset.model._meta.app_label,\n        'model_name': queryset.model._meta.model_name,\n    }\n\n    return get_objects_for_user(\n        user, permission, queryset,\n        **self.shortcut_kwargs)\n",
      "asOf": "2026-11-20"
    },
    "F264": {
      "label": "Project source file, django-guardian",
      "display": "src/rest_framework_guardian/filters.py",
      "asOf": "2026-11-20"
    },
    "F265": {
      "label": "Project full_name, django-guardian",
      "display": "rpkilby/django-rest-framework-guardian",
      "asOf": "2026-11-20"
    },
    "F266": {
      "label": "Project stargazers_count, django-guardian",
      "display": "164",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python authorization libraries PyCasbin rules django-guardian py-abac code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
