prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Enforce the permission endpoint when the admin plugin is included.
  
  Enforce the permission endpoint when the admin plugin is included.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kinto/__init__.py`
  Content:
  ```
  1 import pkg_resources
  2 import logging
  3 
  4 import kinto.core
  5 from pyramid.config import Configurator
  6 from pyramid.settings import asbool
  7 from pyramid.security import Authenticated, Everyone
  8 
  9 from kinto.authorization import RouteFactory
  10 
  11 
  12 # Module version, as defined in PEP-0396.
  13 __version__ = pkg_resources.get_distribution(__package__).version
  14 
  15 # Implemented HTTP API Version
  16 HTTP_API_VERSION = '1.16'
  17 
  18 # Main kinto logger
  19 logger = logging.getLogger(__name__)
  20 
  21 
  22 DEFAULT_SETTINGS = {
  23     'flush_endpoint_enabled': False,
  24     'retry_after_seconds': 3,
  25     'cache_backend': 'kinto.core.cache.memory',
  26     'permission_backend': 'kinto.core.permission.memory',
  27     'storage_backend': 'kinto.core.storage.memory',
  28     'project_docs': 'https://kinto.readthedocs.io/',
  29     'bucket_create_principals': Authenticated,
  30     'permissions_read_principals': Everyone,
  31     'multiauth.authorization_policy': (
  32         'kinto.authorization.AuthorizationPolicy'),
  33     'experimental_collection_schema_validation': False,
  34     'experimental_permissions_endpoint': False,
  35     'http_api_version': HTTP_API_VERSION,
  36     'bucket_id_generator': 'kinto.views.NameGenerator',
  37     'collection_id_generator': 'kinto.views.NameGenerator',
  38     'group_id_generator': 'kinto.views.NameGenerator',
  39     'record_id_generator': 'kinto.views.RelaxedUUID'
  40 }
  41 
  42 
  43 def main(global_config, config=None, **settings):
  44     if not config:
  45         config = Configurator(settings=settings, root_factory=RouteFactory)
  46 
  47     # Force project name, since it determines settings prefix.
  48     config.add_settings({'kinto.project_name': 'kinto'})
  49 
  50     kinto.core.initialize(config,
  51                           version=__version__,
  52                           default_settings=DEFAULT_SETTINGS)
  53 
  54     settings = config.get_settings()
  55 
  56     # Expose capability
  57     schema_enabled = asbool(
  58         settings['experimental_collection_schema_validation']
  59     )
  60     if schema_enabled:
  61         config.add_api_capability(
  62             "schema",
  63             description="Validates collection records with JSON schemas.",
  64             url="https://kinto.readthedocs.io/en/latest/api/1.x/"
  65                 "collections.html#collection-json-schema")
  66 
  67     # Scan Kinto views.
  68     kwargs = {}
  69 
  70     flush_enabled = asbool(settings['flush_endpoint_enabled'])
  71     if flush_enabled:
  72         config.add_api_capability(
  73             "flush_endpoint",
  74             description="The __flush__ endpoint can be used to remove all "
  75                         "data from all backends.",
  76             url="https://kinto.readthedocs.io/en/latest/configuration/"
  77                 "settings.html#activating-the-flush-endpoint")
  78     else:
  79         kwargs['ignore'] = ['kinto.views.flush']
  80 
  81     # Permissions endpoint enabled if permission backend is setup.
  82     permissions_endpoint_enabled = (
  83         asbool(settings['experimental_permissions_endpoint']) and
  84         hasattr(config.registry, 'permission'))
  85     if permissions_endpoint_enabled:
  86         config.add_api_capability(
  87             "permissions_endpoint",
  88             description="The permissions endpoint can be used to list all "
  89                         "user objects permissions.",
  90             url="https://kinto.readthedocs.io/en/latest/configuration/"
  91                 "settings.html#activating-the-permissions-endpoint")
  92     else:
  93         kwargs.setdefault('ignore', []).append('kinto.views.permissions')
  94 
  95     config.scan("kinto.views", **kwargs)
  96 
  97     app = config.make_wsgi_app()
  98 
  99     # Install middleware (no-op if disabled)
  100     return kinto.core.install_middlewares(app, settings)
  101
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/kinto/__init__.py b/kinto/__init__.py
  --- a/kinto/__init__.py
  +++ b/kinto/__init__.py
  @@ -79,8 +79,9 @@
           kwargs['ignore'] = ['kinto.views.flush']
   
       # Permissions endpoint enabled if permission backend is setup.
  +    is_admin_enabled = 'kinto.plugins.admin' in settings['includes']
       permissions_endpoint_enabled = (
  -        asbool(settings['experimental_permissions_endpoint']) and
  +        (is_admin_enabled or asbool(settings['experimental_permissions_endpoint'])) and
           hasattr(config.registry, 'permission'))
       if permissions_endpoint_enabled:
           config.add_api_capability(
  
verification_info: {"golden_diff": "diff --git a/kinto/__init__.py b/kinto/__init__.py\n--- a/kinto/__init__.py\n+++ b/kinto/__init__.py\n@@ -79,8 +79,9 @@\n         kwargs['ignore'] = ['kinto.views.flush']\n \n     # Permissions endpoint enabled if permission backend is setup.\n+    is_admin_enabled = 'kinto.plugins.admin' in settings['includes']\n     permissions_endpoint_enabled = (\n-        asbool(settings['experimental_permissions_endpoint']) and\n+        (is_admin_enabled or asbool(settings['experimental_permissions_endpoint'])) and\n         hasattr(config.registry, 'permission'))\n     if permissions_endpoint_enabled:\n         config.add_api_capability(\n", "issue": "Enforce the permission endpoint when the admin plugin is included.\n\nEnforce the permission endpoint when the admin plugin is included.\n\n", "before_files": [{"content": "import pkg_resources\nimport logging\n\nimport kinto.core\nfrom pyramid.config import Configurator\nfrom pyramid.settings import asbool\nfrom pyramid.security import Authenticated, Everyone\n\nfrom kinto.authorization import RouteFactory\n\n\n# Module version, as defined in PEP-0396.\n__version__ = pkg_resources.get_distribution(__package__).version\n\n# Implemented HTTP API Version\nHTTP_API_VERSION = '1.16'\n\n# Main kinto logger\nlogger = logging.getLogger(__name__)\n\n\nDEFAULT_SETTINGS = {\n    'flush_endpoint_enabled': False,\n    'retry_after_seconds': 3,\n    'cache_backend': 'kinto.core.cache.memory',\n    'permission_backend': 'kinto.core.permission.memory',\n    'storage_backend': 'kinto.core.storage.memory',\n    'project_docs': 'https://kinto.readthedocs.io/',\n    'bucket_create_principals': Authenticated,\n    'permissions_read_principals': Everyone,\n    'multiauth.authorization_policy': (\n        'kinto.authorization.AuthorizationPolicy'),\n    'experimental_collection_schema_validation': False,\n    'experimental_permissions_endpoint': False,\n    'http_api_version': HTTP_API_VERSION,\n    'bucket_id_generator': 'kinto.views.NameGenerator',\n    'collection_id_generator': 'kinto.views.NameGenerator',\n    'group_id_generator': 'kinto.views.NameGenerator',\n    'record_id_generator': 'kinto.views.RelaxedUUID'\n}\n\n\ndef main(global_config, config=None, **settings):\n    if not config:\n        config = Configurator(settings=settings, root_factory=RouteFactory)\n\n    # Force project name, since it determines settings prefix.\n    config.add_settings({'kinto.project_name': 'kinto'})\n\n    kinto.core.initialize(config,\n                          version=__version__,\n                          default_settings=DEFAULT_SETTINGS)\n\n    settings = config.get_settings()\n\n    # Expose capability\n    schema_enabled = asbool(\n        settings['experimental_collection_schema_validation']\n    )\n    if schema_enabled:\n        config.add_api_capability(\n            \"schema\",\n            description=\"Validates collection records with JSON schemas.\",\n            url=\"https://kinto.readthedocs.io/en/latest/api/1.x/\"\n                \"collections.html#collection-json-schema\")\n\n    # Scan Kinto views.\n    kwargs = {}\n\n    flush_enabled = asbool(settings['flush_endpoint_enabled'])\n    if flush_enabled:\n        config.add_api_capability(\n            \"flush_endpoint\",\n            description=\"The __flush__ endpoint can be used to remove all \"\n                        \"data from all backends.\",\n            url=\"https://kinto.readthedocs.io/en/latest/configuration/\"\n                \"settings.html#activating-the-flush-endpoint\")\n    else:\n        kwargs['ignore'] = ['kinto.views.flush']\n\n    # Permissions endpoint enabled if permission backend is setup.\n    permissions_endpoint_enabled = (\n        asbool(settings['experimental_permissions_endpoint']) and\n        hasattr(config.registry, 'permission'))\n    if permissions_endpoint_enabled:\n        config.add_api_capability(\n            \"permissions_endpoint\",\n            description=\"The permissions endpoint can be used to list all \"\n                        \"user objects permissions.\",\n            url=\"https://kinto.readthedocs.io/en/latest/configuration/\"\n                \"settings.html#activating-the-permissions-endpoint\")\n    else:\n        kwargs.setdefault('ignore', []).append('kinto.views.permissions')\n\n    config.scan(\"kinto.views\", **kwargs)\n\n    app = config.make_wsgi_app()\n\n    # Install middleware (no-op if disabled)\n    return kinto.core.install_middlewares(app, settings)\n", "path": "kinto/__init__.py"}], "after_files": [{"content": "import pkg_resources\nimport logging\n\nimport kinto.core\nfrom pyramid.config import Configurator\nfrom pyramid.settings import asbool\nfrom pyramid.security import Authenticated, Everyone\n\nfrom kinto.authorization import RouteFactory\n\n\n# Module version, as defined in PEP-0396.\n__version__ = pkg_resources.get_distribution(__package__).version\n\n# Implemented HTTP API Version\nHTTP_API_VERSION = '1.16'\n\n# Main kinto logger\nlogger = logging.getLogger(__name__)\n\n\nDEFAULT_SETTINGS = {\n    'flush_endpoint_enabled': False,\n    'retry_after_seconds': 3,\n    'cache_backend': 'kinto.core.cache.memory',\n    'permission_backend': 'kinto.core.permission.memory',\n    'storage_backend': 'kinto.core.storage.memory',\n    'project_docs': 'https://kinto.readthedocs.io/',\n    'bucket_create_principals': Authenticated,\n    'permissions_read_principals': Everyone,\n    'multiauth.authorization_policy': (\n        'kinto.authorization.AuthorizationPolicy'),\n    'experimental_collection_schema_validation': False,\n    'experimental_permissions_endpoint': False,\n    'http_api_version': HTTP_API_VERSION,\n    'bucket_id_generator': 'kinto.views.NameGenerator',\n    'collection_id_generator': 'kinto.views.NameGenerator',\n    'group_id_generator': 'kinto.views.NameGenerator',\n    'record_id_generator': 'kinto.views.RelaxedUUID'\n}\n\n\ndef main(global_config, config=None, **settings):\n    if not config:\n        config = Configurator(settings=settings, root_factory=RouteFactory)\n\n    # Force project name, since it determines settings prefix.\n    config.add_settings({'kinto.project_name': 'kinto'})\n\n    kinto.core.initialize(config,\n                          version=__version__,\n                          default_settings=DEFAULT_SETTINGS)\n\n    settings = config.get_settings()\n\n    # Expose capability\n    schema_enabled = asbool(\n        settings['experimental_collection_schema_validation']\n    )\n    if schema_enabled:\n        config.add_api_capability(\n            \"schema\",\n            description=\"Validates collection records with JSON schemas.\",\n            url=\"https://kinto.readthedocs.io/en/latest/api/1.x/\"\n                \"collections.html#collection-json-schema\")\n\n    # Scan Kinto views.\n    kwargs = {}\n\n    flush_enabled = asbool(settings['flush_endpoint_enabled'])\n    if flush_enabled:\n        config.add_api_capability(\n            \"flush_endpoint\",\n            description=\"The __flush__ endpoint can be used to remove all \"\n                        \"data from all backends.\",\n            url=\"https://kinto.readthedocs.io/en/latest/configuration/\"\n                \"settings.html#activating-the-flush-endpoint\")\n    else:\n        kwargs['ignore'] = ['kinto.views.flush']\n\n    # Permissions endpoint enabled if permission backend is setup.\n    is_admin_enabled = 'kinto.plugins.admin' in settings['includes']\n    permissions_endpoint_enabled = (\n        (is_admin_enabled or asbool(settings['experimental_permissions_endpoint'])) and\n        hasattr(config.registry, 'permission'))\n    if permissions_endpoint_enabled:\n        config.add_api_capability(\n            \"permissions_endpoint\",\n            description=\"The permissions endpoint can be used to list all \"\n                        \"user objects permissions.\",\n            url=\"https://kinto.readthedocs.io/en/latest/configuration/\"\n                \"settings.html#activating-the-permissions-endpoint\")\n    else:\n        kwargs.setdefault('ignore', []).append('kinto.views.permissions')\n\n    config.scan(\"kinto.views\", **kwargs)\n\n    app = config.make_wsgi_app()\n\n    # Install middleware (no-op if disabled)\n    return kinto.core.install_middlewares(app, settings)\n", "path": "kinto/__init__.py"}]}