prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Kinto onboarding experience (part 2)
  These is a followup from #1733 with random feedback with onboarding when trying to use the [accounts plugin](http://docs.kinto-storage.org/en/stable/api/1.x/accounts.html).
  
  
  
  Started with updating my `config/kinto.ini` with:
  
  ```
  kinto.includes = kinto.plugins.default_bucket
                   kinto.plugins.admin
                   kinto.plugins.accounts
  ```
  
  Restarting the server goes smoothly. The admin loads fine and renders a new entry for *Kinto Account Auth*. I never created any Account just yet, though out of curiosity I try to log in using silly:silly:
  
  ![](https://i.imgur.com/0OTeatP.png)
  
  Tadaa:
  
  ![](https://i.imgur.com/7UMpDFv.png)
  
  Wait, what?
  
  Oh. It seems it actually used the Basic Auth strategy instead of the account one for login. This is odd and confusing as fsck.
  
  Actually, I didn't went further with toying around with the admin as it looks broken to me. This is a little sad.
  Kinto onboarding experience (part 2)
  These is a followup from #1733 with random feedback with onboarding when trying to use the [accounts plugin](http://docs.kinto-storage.org/en/stable/api/1.x/accounts.html).
  
  
  
  Started with updating my `config/kinto.ini` with:
  
  ```
  kinto.includes = kinto.plugins.default_bucket
                   kinto.plugins.admin
                   kinto.plugins.accounts
  ```
  
  Restarting the server goes smoothly. The admin loads fine and renders a new entry for *Kinto Account Auth*. I never created any Account just yet, though out of curiosity I try to log in using silly:silly:
  
  ![](https://i.imgur.com/0OTeatP.png)
  
  Tadaa:
  
  ![](https://i.imgur.com/7UMpDFv.png)
  
  Wait, what?
  
  Oh. It seems it actually used the Basic Auth strategy instead of the account one for login. This is odd and confusing as fsck.
  
  Actually, I didn't went further with toying around with the admin as it looks broken to me. This is a little sad.
  
  </issue>
  <code>
  [start of kinto/plugins/accounts/__init__.py]
  1 from kinto.authorization import PERMISSIONS_INHERITANCE_TREE
  2 from pyramid.exceptions import ConfigurationError
  3 
  4 ACCOUNT_CACHE_KEY = 'accounts:{}:verified'
  5 ACCOUNT_POLICY_NAME = 'account'
  6 
  7 
  8 def includeme(config):
  9     config.add_api_capability(
  10         'accounts',
  11         description='Manage user accounts.',
  12         url='https://kinto.readthedocs.io/en/latest/api/1.x/accounts.html')
  13 
  14     config.scan('kinto.plugins.accounts.views')
  15 
  16     PERMISSIONS_INHERITANCE_TREE['root'].update({
  17         'account:create': {}
  18     })
  19     PERMISSIONS_INHERITANCE_TREE['account'] = {
  20         'write': {'account': ['write']},
  21         'read': {'account': ['write', 'read']}
  22     }
  23 
  24     # Add some safety to avoid weird behaviour with basicauth default policy.
  25     settings = config.get_settings()
  26     auth_policies = settings['multiauth.policies']
  27     if 'basicauth' in auth_policies and 'account' in auth_policies:
  28         if auth_policies.index('basicauth') < auth_policies.index('account'):
  29             error_msg = ("'basicauth' should not be mentioned before 'account' "
  30                          "in 'multiauth.policies' setting.")
  31             raise ConfigurationError(error_msg)
  32 
  33     # We assume anyone in account_create_principals is to create
  34     # accounts for other people.
  35     # No one can create accounts for other people unless they are an
  36     # "admin", defined as someone matching account_write_principals.
  37     # Therefore any account that is in account_create_principals
  38     # should be in account_write_principals too.
  39     creators = set(settings.get('account_create_principals', '').split())
  40     admins = set(settings.get('account_write_principals', '').split())
  41     cant_create_anything = creators.difference(admins)
  42     # system.Everyone isn't an account.
  43     cant_create_anything.discard('system.Everyone')
  44     if cant_create_anything:
  45         message = ('Configuration has some principals in account_create_principals '
  46                    'but not in account_write_principals. These principals will only be '
  47                    'able to create their own accounts. This may not be what you want.\n'
  48                    'If you want these users to be able to create accounts for other users, '
  49                    'add them to account_write_principals.\n'
  50                    'Affected users: {}'.format(list(cant_create_anything)))
  51 
  52         raise ConfigurationError(message)
  53
  [end of kinto/plugins/accounts/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/kinto/plugins/accounts/__init__.py b/kinto/plugins/accounts/__init__.py
  --- a/kinto/plugins/accounts/__init__.py
  +++ b/kinto/plugins/accounts/__init__.py
  @@ -1,9 +1,13 @@
  +import re
  +
   from kinto.authorization import PERMISSIONS_INHERITANCE_TREE
   from pyramid.exceptions import ConfigurationError
   
   ACCOUNT_CACHE_KEY = 'accounts:{}:verified'
   ACCOUNT_POLICY_NAME = 'account'
   
  +DOCS_URL = "https://kinto.readthedocs.io/en/stable/api/1.x/accounts.html"
  +
   
   def includeme(config):
       config.add_api_capability(
  @@ -21,13 +25,28 @@
           'read': {'account': ['write', 'read']}
       }
   
  -    # Add some safety to avoid weird behaviour with basicauth default policy.
       settings = config.get_settings()
  +
  +    # Check that the account policy is mentioned in config if included.
  +    accountClass = 'AccountsAuthenticationPolicy'
  +    policy = None
  +    for k, v in settings.items():
  +        m = re.match('multiauth\.policy\.(.*)\.use', k)
  +        if m:
  +            if v.endswith(accountClass):
  +                policy = m.group(1)
  +
  +    if not policy:
  +        error_msg = ("Account policy missing the 'multiauth.policy.*.use' "
  +                     "setting. See {} in docs {}.").format(accountClass, DOCS_URL)
  +        raise ConfigurationError(error_msg)
  +
  +    # Add some safety to avoid weird behaviour with basicauth default policy.
       auth_policies = settings['multiauth.policies']
  -    if 'basicauth' in auth_policies and 'account' in auth_policies:
  -        if auth_policies.index('basicauth') < auth_policies.index('account'):
  -            error_msg = ("'basicauth' should not be mentioned before 'account' "
  -                         "in 'multiauth.policies' setting.")
  +    if 'basicauth' in auth_policies and policy in auth_policies:
  +        if auth_policies.index('basicauth') < auth_policies.index(policy):
  +            error_msg = ("'basicauth' should not be mentioned before '%s' "
  +                         "in 'multiauth.policies' setting.") % policy
               raise ConfigurationError(error_msg)
   
       # We assume anyone in account_create_principals is to create
  
verification_info: {"golden_diff": "diff --git a/kinto/plugins/accounts/__init__.py b/kinto/plugins/accounts/__init__.py\n--- a/kinto/plugins/accounts/__init__.py\n+++ b/kinto/plugins/accounts/__init__.py\n@@ -1,9 +1,13 @@\n+import re\n+\n from kinto.authorization import PERMISSIONS_INHERITANCE_TREE\n from pyramid.exceptions import ConfigurationError\n \n ACCOUNT_CACHE_KEY = 'accounts:{}:verified'\n ACCOUNT_POLICY_NAME = 'account'\n \n+DOCS_URL = \"https://kinto.readthedocs.io/en/stable/api/1.x/accounts.html\"\n+\n \n def includeme(config):\n     config.add_api_capability(\n@@ -21,13 +25,28 @@\n         'read': {'account': ['write', 'read']}\n     }\n \n-    # Add some safety to avoid weird behaviour with basicauth default policy.\n     settings = config.get_settings()\n+\n+    # Check that the account policy is mentioned in config if included.\n+    accountClass = 'AccountsAuthenticationPolicy'\n+    policy = None\n+    for k, v in settings.items():\n+        m = re.match('multiauth\\.policy\\.(.*)\\.use', k)\n+        if m:\n+            if v.endswith(accountClass):\n+                policy = m.group(1)\n+\n+    if not policy:\n+        error_msg = (\"Account policy missing the 'multiauth.policy.*.use' \"\n+                     \"setting. See {} in docs {}.\").format(accountClass, DOCS_URL)\n+        raise ConfigurationError(error_msg)\n+\n+    # Add some safety to avoid weird behaviour with basicauth default policy.\n     auth_policies = settings['multiauth.policies']\n-    if 'basicauth' in auth_policies and 'account' in auth_policies:\n-        if auth_policies.index('basicauth') < auth_policies.index('account'):\n-            error_msg = (\"'basicauth' should not be mentioned before 'account' \"\n-                         \"in 'multiauth.policies' setting.\")\n+    if 'basicauth' in auth_policies and policy in auth_policies:\n+        if auth_policies.index('basicauth') < auth_policies.index(policy):\n+            error_msg = (\"'basicauth' should not be mentioned before '%s' \"\n+                         \"in 'multiauth.policies' setting.\") % policy\n             raise ConfigurationError(error_msg)\n \n     # We assume anyone in account_create_principals is to create\n", "issue": "Kinto onboarding experience (part 2)\nThese is a followup from #1733 with random feedback with onboarding when trying to use the [accounts plugin](http://docs.kinto-storage.org/en/stable/api/1.x/accounts.html).\r\n\r\n\r\n\r\nStarted with updating my `config/kinto.ini` with:\r\n\r\n```\r\nkinto.includes = kinto.plugins.default_bucket\r\n                 kinto.plugins.admin\r\n                 kinto.plugins.accounts\r\n```\r\n\r\nRestarting the server goes smoothly. The admin loads fine and renders a new entry for *Kinto Account Auth*. I never created any Account just yet, though out of curiosity I try to log in using silly:silly:\r\n\r\n![](https://i.imgur.com/0OTeatP.png)\r\n\r\nTadaa:\r\n\r\n![](https://i.imgur.com/7UMpDFv.png)\r\n\r\nWait, what?\r\n\r\nOh. It seems it actually used the Basic Auth strategy instead of the account one for login. This is odd and confusing as fsck.\r\n\r\nActually, I didn't went further with toying around with the admin as it looks broken to me. This is a little sad.\nKinto onboarding experience (part 2)\nThese is a followup from #1733 with random feedback with onboarding when trying to use the [accounts plugin](http://docs.kinto-storage.org/en/stable/api/1.x/accounts.html).\r\n\r\n\r\n\r\nStarted with updating my `config/kinto.ini` with:\r\n\r\n```\r\nkinto.includes = kinto.plugins.default_bucket\r\n                 kinto.plugins.admin\r\n                 kinto.plugins.accounts\r\n```\r\n\r\nRestarting the server goes smoothly. The admin loads fine and renders a new entry for *Kinto Account Auth*. I never created any Account just yet, though out of curiosity I try to log in using silly:silly:\r\n\r\n![](https://i.imgur.com/0OTeatP.png)\r\n\r\nTadaa:\r\n\r\n![](https://i.imgur.com/7UMpDFv.png)\r\n\r\nWait, what?\r\n\r\nOh. It seems it actually used the Basic Auth strategy instead of the account one for login. This is odd and confusing as fsck.\r\n\r\nActually, I didn't went further with toying around with the admin as it looks broken to me. This is a little sad.\n", "before_files": [{"content": "from kinto.authorization import PERMISSIONS_INHERITANCE_TREE\nfrom pyramid.exceptions import ConfigurationError\n\nACCOUNT_CACHE_KEY = 'accounts:{}:verified'\nACCOUNT_POLICY_NAME = 'account'\n\n\ndef includeme(config):\n    config.add_api_capability(\n        'accounts',\n        description='Manage user accounts.',\n        url='https://kinto.readthedocs.io/en/latest/api/1.x/accounts.html')\n\n    config.scan('kinto.plugins.accounts.views')\n\n    PERMISSIONS_INHERITANCE_TREE['root'].update({\n        'account:create': {}\n    })\n    PERMISSIONS_INHERITANCE_TREE['account'] = {\n        'write': {'account': ['write']},\n        'read': {'account': ['write', 'read']}\n    }\n\n    # Add some safety to avoid weird behaviour with basicauth default policy.\n    settings = config.get_settings()\n    auth_policies = settings['multiauth.policies']\n    if 'basicauth' in auth_policies and 'account' in auth_policies:\n        if auth_policies.index('basicauth') < auth_policies.index('account'):\n            error_msg = (\"'basicauth' should not be mentioned before 'account' \"\n                         \"in 'multiauth.policies' setting.\")\n            raise ConfigurationError(error_msg)\n\n    # We assume anyone in account_create_principals is to create\n    # accounts for other people.\n    # No one can create accounts for other people unless they are an\n    # \"admin\", defined as someone matching account_write_principals.\n    # Therefore any account that is in account_create_principals\n    # should be in account_write_principals too.\n    creators = set(settings.get('account_create_principals', '').split())\n    admins = set(settings.get('account_write_principals', '').split())\n    cant_create_anything = creators.difference(admins)\n    # system.Everyone isn't an account.\n    cant_create_anything.discard('system.Everyone')\n    if cant_create_anything:\n        message = ('Configuration has some principals in account_create_principals '\n                   'but not in account_write_principals. These principals will only be '\n                   'able to create their own accounts. This may not be what you want.\\n'\n                   'If you want these users to be able to create accounts for other users, '\n                   'add them to account_write_principals.\\n'\n                   'Affected users: {}'.format(list(cant_create_anything)))\n\n        raise ConfigurationError(message)\n", "path": "kinto/plugins/accounts/__init__.py"}]}