pas.plugins.authomatic 1.2.0__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/CHANGELOG.md +14 -0
  2. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/PKG-INFO +16 -1
  3. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/setup.py +4 -2
  4. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/__init__.py +14 -6
  5. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/view.py +11 -2
  6. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/update.py +1 -0
  7. pas.plugins.authomatic-1.4.0/src/pas/plugins/authomatic/logging.py +6 -0
  8. pas.plugins.authomatic-1.4.0/src/pas/plugins/authomatic/patches/__init__.py +5 -0
  9. pas.plugins.authomatic-1.4.0/src/pas/plugins/authomatic/patches/authomatic.py +147 -0
  10. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/plugin.py +18 -2
  11. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/services/authomatic.py +17 -9
  12. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_plugin.py +14 -0
  13. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_setup.py +1 -0
  14. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_upgrades.py +1 -0
  15. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/PKG-INFO +16 -1
  16. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/SOURCES.txt +3 -0
  17. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/requires.txt +1 -1
  18. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/.coveragerc +0 -0
  19. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/.editorconfig +0 -0
  20. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/CONTRIBUTORS.md +0 -0
  21. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/LICENSE.txt +0 -0
  22. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/MANIFEST.in +0 -0
  23. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/Makefile +0 -0
  24. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/README.md +0 -0
  25. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/docs/authomatic.svg +0 -0
  26. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/docs/plone-control-panel.png +0 -0
  27. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/docs/plugin-settings.png +0 -0
  28. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/pyproject.toml +0 -0
  29. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/requirements.txt +0 -0
  30. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/setup.cfg +0 -0
  31. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/__init__.py +0 -0
  32. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/__init__.py +0 -0
  33. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/__init__.py +0 -0
  34. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/add_plugin.pt +0 -0
  35. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/authomatic.png +0 -0
  36. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/authomatic.pt +0 -0
  37. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/configure.zcml +0 -0
  38. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/controlpanel.py +0 -0
  39. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/resources/authomatic-logo.svg +0 -0
  40. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/resources/authomatic.css +0 -0
  41. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/resources/authomatic.less +0 -0
  42. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/configure.zcml +0 -0
  43. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/integration/__init__.py +0 -0
  44. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/integration/restapi.py +0 -0
  45. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/integration/zope.py +0 -0
  46. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/interfaces.py +0 -0
  47. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/__init__.py +0 -0
  48. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/de/LC_MESSAGES/pas.plugins.authomatic.po +0 -0
  49. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/es/LC_MESSAGES/pas.plugins.authomatic.po +0 -0
  50. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/fr/LC_MESSAGES/pas.plugins.authomatic.po +0 -0
  51. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/it/LC_MESSAGES/pas.plugins.authomatic.po +0 -0
  52. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/pas.plugins.authomatic-manual.pot +0 -0
  53. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/pas.plugins.authomatic.pot +0 -0
  54. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/pt_BR/LC_MESSAGES/pas.plugins.authomatic.po +0 -0
  55. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/ro/LC_MESSAGES/pas.plugins.authomatic.po +0 -0
  56. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/meta.zcml +0 -0
  57. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/default/browserlayer.xml +0 -0
  58. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/default/controlpanel.xml +0 -0
  59. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/default/metadata.xml +0 -0
  60. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/default/registry.xml +0 -0
  61. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/uninstall/browserlayer.xml +0 -0
  62. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/uninstall/controlpanel.xml +0 -0
  63. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/uninstall/registry.xml +0 -0
  64. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles.zcml +0 -0
  65. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/services/__init__.py +0 -0
  66. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/services/configure.zcml +0 -0
  67. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/services/login.py +0 -0
  68. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/setuphandlers.py +0 -0
  69. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/testing.py +0 -0
  70. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/__init__.py +0 -0
  71. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/mocks.py +0 -0
  72. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_browser_controlpanel.py +0 -0
  73. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_services_authomatic.py +0 -0
  74. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_services_login.py +0 -0
  75. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_setuphandler.py +0 -0
  76. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_useridentities.py +0 -0
  77. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_useridfactories.py +0 -0
  78. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/useridentities.py +0 -0
  79. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/useridfactories.py +0 -0
  80. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/utils.py +0 -0
  81. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/dependency_links.txt +0 -0
  82. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/entry_points.txt +0 -0
  83. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/namespace_packages.txt +0 -0
  84. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/not-zip-safe +0 -0
  85. {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/top_level.txt +0 -0
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.0 (2024-12-13)
4
+
5
+
6
+ - Patch `authomatic.providers.BaseProvider._fetch` to support Python 3.12 @ericof.
7
+
8
+
9
+ ## 1.3.0 (2024-11-21)
10
+
11
+ - Search users by fullname and email. @alecghica
12
+ - Fix login on Volto frontend when already logged-in in Plone Classic. @avoinea
13
+ - Add the possibility to override the ZopeRequestAdapter.
14
+ - Fix the authomatic view when it is reporting an exception that does not have a message attribute
15
+
16
+
3
17
  ## 1.2.0 (2023-09-13)
4
18
 
5
19
  - Add Spanish translation. @macagua
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pas.plugins.authomatic
3
- Version: 1.2.0
3
+ Version: 1.4.0
4
4
  Summary: Provides OAuth2/OpenID login for Plone using Authomatic.
5
5
  Home-page: https://github.com/collective/pas.plugins.authomatic
6
6
  Author: Jens Klein, Matthias Dollfuss, and Érico Andrei
@@ -25,6 +25,7 @@ Classifier: Programming Language :: Python :: 3.8
25
25
  Classifier: Programming Language :: Python :: 3.9
26
26
  Classifier: Programming Language :: Python :: 3.10
27
27
  Classifier: Programming Language :: Python :: 3.11
28
+ Classifier: Programming Language :: Python :: 3.12
28
29
  Classifier: Programming Language :: Python
29
30
  Requires-Python: >=3.7
30
31
  Description-Content-Type: text/markdown
@@ -259,6 +260,20 @@ The project is licensed under the GPLv2.
259
260
 
260
261
  # Changelog
261
262
 
263
+ ## 1.4.0 (2024-12-13)
264
+
265
+
266
+ - Patch `authomatic.providers.BaseProvider._fetch` to support Python 3.12 @ericof.
267
+
268
+
269
+ ## 1.3.0 (2024-11-21)
270
+
271
+ - Search users by fullname and email. @alecghica
272
+ - Fix login on Volto frontend when already logged-in in Plone Classic. @avoinea
273
+ - Add the possibility to override the ZopeRequestAdapter.
274
+ - Fix the authomatic view when it is reporting an exception that does not have a message attribute
275
+
276
+
262
277
  ## 1.2.0 (2023-09-13)
263
278
 
264
279
  - Add Spanish translation. @macagua
@@ -1,4 +1,5 @@
1
1
  """Installer for the pas.plugins.authomatic package."""
2
+
2
3
  from pathlib import Path
3
4
  from setuptools import find_packages
4
5
  from setuptools import setup
@@ -11,7 +12,7 @@ long_description = f"""
11
12
 
12
13
  setup(
13
14
  name="pas.plugins.authomatic",
14
- version="1.2.0",
15
+ version="1.4.0",
15
16
  description="Provides OAuth2/OpenID login for Plone using Authomatic.",
16
17
  long_description=long_description,
17
18
  long_description_content_type="text/markdown",
@@ -31,6 +32,7 @@ setup(
31
32
  "Programming Language :: Python :: 3.9",
32
33
  "Programming Language :: Python :: 3.10",
33
34
  "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
34
36
  "Programming Language :: Python",
35
37
  ],
36
38
  keywords="Python Plone PAS OAuth Authentication",
@@ -50,7 +52,7 @@ setup(
50
52
  python_requires=">=3.7",
51
53
  zip_safe=False,
52
54
  install_requires=[
53
- "authomatic>=1.0.0",
55
+ "authomatic>=1.3.0",
54
56
  "Products.CMFPlone>=5.2",
55
57
  "plone.restapi",
56
58
  "setuptools",
@@ -1,9 +1,10 @@
1
- from AccessControl.Permissions import add_user_folders
2
- from pas.plugins.authomatic.plugin import AuthomaticPlugin
3
- from pas.plugins.authomatic.plugin import manage_addAuthomaticPlugin
4
- from pas.plugins.authomatic.plugin import manage_addAuthomaticPluginForm
5
- from pas.plugins.authomatic.plugin import tpl_dir
6
- from Products.PluggableAuthService import registerMultiPlugin
1
+ from pas.plugins.authomatic.patches import apply_patches
2
+
3
+
4
+ PACKAGE_NAME = "pas.plugins.authomatic"
5
+
6
+
7
+ apply_patches()
7
8
 
8
9
 
9
10
  def initialize(context):
@@ -15,6 +16,13 @@ def initialize(context):
15
16
  Here, we call the Archetypes machinery to register our content types
16
17
  with Zope and the CMF.
17
18
  """
19
+ from AccessControl.Permissions import add_user_folders
20
+ from pas.plugins.authomatic.plugin import AuthomaticPlugin
21
+ from pas.plugins.authomatic.plugin import manage_addAuthomaticPlugin
22
+ from pas.plugins.authomatic.plugin import manage_addAuthomaticPluginForm
23
+ from pas.plugins.authomatic.plugin import tpl_dir
24
+ from Products.PluggableAuthService import registerMultiPlugin
25
+
18
26
  registerMultiPlugin(AuthomaticPlugin.meta_type)
19
27
  context.registerClass(
20
28
  AuthomaticPlugin,
@@ -29,6 +29,12 @@ class AuthomaticView(BrowserView):
29
29
 
30
30
  template = ViewPageTemplateFile("authomatic.pt")
31
31
 
32
+ zope_request_adapter_factory = ZopeRequestAdapter
33
+
34
+ @property
35
+ def zope_request_adapter(self):
36
+ return self.zope_request_adapter_factory(self)
37
+
32
38
  def publishTraverse(self, request, name):
33
39
  if name and not hasattr(self, "provider"):
34
40
  self.provider = name
@@ -111,13 +117,16 @@ class AuthomaticView(BrowserView):
111
117
  pass
112
118
  secret = authomatic_settings().secret
113
119
  auth = Authomatic(cfg, secret=secret)
114
- result = auth.login(ZopeRequestAdapter(self), self.provider)
120
+ result = auth.login(self.zope_request_adapter, self.provider)
115
121
  if not result:
116
122
  logger.info("return from view")
117
123
  # let authomatic do its work
118
124
  return
119
125
  if result.error:
120
- return result.error.message
126
+ try:
127
+ return result.error.message
128
+ except AttributeError:
129
+ return str(result.error)
121
130
  display = cfg[self.provider].get("display", {})
122
131
  provider_name = display.get("title", self.provider)
123
132
  if not self.is_anon:
@@ -1,4 +1,5 @@
1
1
  """Update locales."""
2
+
2
3
  from pathlib import Path
3
4
 
4
5
  import logging
@@ -0,0 +1,6 @@
1
+ from pas.plugins.authomatic import PACKAGE_NAME
2
+
3
+ import logging
4
+
5
+
6
+ logger = logging.getLogger(PACKAGE_NAME)
@@ -0,0 +1,5 @@
1
+ def apply_patches():
2
+ """Apply patches."""
3
+ from .authomatic import patch_base_provider_fetch
4
+
5
+ patch_base_provider_fetch()
@@ -0,0 +1,147 @@
1
+ from authomatic.exceptions import FetchError
2
+ from authomatic.providers import BaseProvider
3
+ from http import client as http_client
4
+ from pas.plugins.authomatic.logging import logger
5
+ from urllib import parse
6
+
7
+ import authomatic.core
8
+ import ssl
9
+
10
+
11
+ def patch_base_provider_fetch():
12
+ def _fetch(
13
+ self,
14
+ url,
15
+ method="GET",
16
+ params=None,
17
+ headers=None,
18
+ body="",
19
+ max_redirects=5,
20
+ content_parser=None,
21
+ certificate_file=None,
22
+ ssl_verify=True,
23
+ ):
24
+ """
25
+ Fetches a URL.
26
+
27
+ :param str url:
28
+ The URL to fetch.
29
+
30
+ :param str method:
31
+ HTTP method of the request.
32
+
33
+ :param dict params:
34
+ Dictionary of request parameters.
35
+
36
+ :param dict headers:
37
+ HTTP headers of the request.
38
+
39
+ :param str body:
40
+ Body of ``POST``, ``PUT`` and ``PATCH`` requests.
41
+
42
+ :param int max_redirects:
43
+ Number of maximum HTTP redirects to follow.
44
+
45
+ :param function content_parser:
46
+ A callable to be used to parse the :attr:`.Response.data`
47
+ from :attr:`.Response.content`.
48
+
49
+ :param str certificate_file:
50
+ Optional certificate file to be used for HTTPS connection.
51
+
52
+ :param bool ssl_verify:
53
+ Verify SSL on HTTPS connection.
54
+ """
55
+ # 'magic' using _kwarg method
56
+ # pylint:disable=no-member
57
+ params = params or {}
58
+ params.update(self.access_params)
59
+
60
+ headers = headers or {}
61
+ headers.update(self.access_headers)
62
+
63
+ url_parsed = parse.urlsplit(url)
64
+ query = parse.urlencode(params)
65
+
66
+ if method in ("POST", "PUT", "PATCH"):
67
+ if not body:
68
+ # Put querystring to body
69
+ body = query
70
+ query = ""
71
+ headers.update({"Content-Type": "application/x-www-form-urlencoded"})
72
+ request_path = parse.urlunsplit(
73
+ ("", "", url_parsed.path or "", query or "", "")
74
+ )
75
+
76
+ self._log_param("host", url_parsed.hostname, last=False)
77
+ self._log_param("method", method, last=False)
78
+ self._log_param("body", body, last=False)
79
+ self._log_param("params", params, last=False)
80
+ self._log_param("headers", headers, last=False)
81
+ self._log_param("certificate", certificate_file, last=False)
82
+ self._log_param("SSL verify", ssl_verify, last=True)
83
+
84
+ # Connect
85
+ if url_parsed.scheme.lower() == "https":
86
+ if ssl_verify:
87
+ context = ssl.create_default_context(
88
+ purpose=ssl.Purpose.SERVER_AUTH, cafile=certificate_file
89
+ )
90
+ else:
91
+ context = ssl._create_unverified_context()
92
+
93
+ connection = http_client.HTTPSConnection(
94
+ url_parsed.hostname, port=url_parsed.port, context=context
95
+ )
96
+ else:
97
+ connection = http_client.HTTPConnection(
98
+ url_parsed.hostname, port=url_parsed.port
99
+ )
100
+
101
+ try:
102
+ connection.request(method, request_path, body, headers)
103
+ except Exception as e: # noQA: B902
104
+ raise FetchError(
105
+ "Fetching URL failed", original_message=str(e), url=request_path
106
+ )
107
+
108
+ response = connection.getresponse()
109
+ location = response.getheader("Location")
110
+
111
+ if response.status in (300, 301, 302, 303, 307) and location:
112
+ if location == url:
113
+ raise FetchError(
114
+ "Url redirects to itself!", url=location, status=response.status
115
+ )
116
+
117
+ if max_redirects > 0:
118
+ remaining_redirects = max_redirects - 1
119
+
120
+ self._log_param("Redirecting to", url)
121
+ self._log_param("Remaining redirects", remaining_redirects)
122
+
123
+ # Call this method again.
124
+ response = self._fetch(
125
+ url=location,
126
+ params=params,
127
+ method=method,
128
+ headers=headers,
129
+ max_redirects=remaining_redirects,
130
+ certificate_file=certificate_file,
131
+ ssl_verify=ssl_verify,
132
+ )
133
+
134
+ else:
135
+ raise FetchError(
136
+ "Max redirects reached!", url=location, status=response.status
137
+ )
138
+ else:
139
+ self._log_param("Got response")
140
+ self._log_param("url", url, last=False)
141
+ self._log_param("status", response.status, last=False)
142
+ self._log_param("headers", response.getheaders(), last=True)
143
+
144
+ return authomatic.core.Response(response, content_parser)
145
+
146
+ BaseProvider._fetch = _fetch
147
+ logger.info("Patched authomatic.providers.BaseProvider._fetch")
@@ -262,10 +262,26 @@ class AuthomaticPlugin(BasePlugin):
262
262
  if not userid:
263
263
  logger.warn("None userid found. This should not happen!")
264
264
  continue
265
- if not userid.startswith(search_id):
266
- continue
265
+
266
+ # search for a match in fullname, email and userid
267
267
  identity = self._useridentities_by_userid[userid]
268
+ search_term = search_id.lower()
268
269
  identity_userid = identity.userid
270
+ identity_fullname = identity.propertysheet.getProperty(
271
+ "fullname", ""
272
+ ).lower()
273
+ identity_email = identity.propertysheet.getProperty("email", "").lower()
274
+ if (
275
+ search_term not in identity_userid
276
+ and search_term not in identity_fullname # noqa: W503
277
+ and search_term not in identity_email # noqa: W503
278
+ ):
279
+ continue
280
+
281
+ # if not userid.startswith(search_id):
282
+ # continue
283
+ # identity = self._useridentities_by_userid[userid]
284
+ # identity_userid = identity.userid
269
285
  ret.append(
270
286
  {
271
287
  "id": identity_userid,
@@ -13,9 +13,13 @@ from zope.interface import alsoProvides
13
13
  from zope.interface import implementer
14
14
  from zope.publisher.interfaces import IPublishTraverse
15
15
 
16
+ import logging
16
17
  import transaction
17
18
 
18
19
 
20
+ logger = logging.getLogger("pas.plugins.authomatic")
21
+
22
+
19
23
  @implementer(IPublishTraverse)
20
24
  class LoginAuthomatic(Service):
21
25
  """Base class for Authomatic login."""
@@ -161,15 +165,13 @@ class Post(LoginAuthomatic):
161
165
  break
162
166
  return plugin
163
167
 
164
- def _add_identity(self, result):
168
+ def _add_identity(self, result, userid=None):
165
169
  """Add an identity to an existing user.
166
170
 
167
171
  :param result: Authomatic login result.
168
172
  """
169
173
  aclu = self._get_acl_users()
170
- aclu.authomatic.remember_identity(
171
- result,
172
- )
174
+ aclu.authomatic.remember_identity(result, userid)
173
175
 
174
176
  def _remember_identity(self, result):
175
177
  """Store identity information.
@@ -237,17 +239,23 @@ class Post(LoginAuthomatic):
237
239
  }
238
240
  elif result:
239
241
  alsoProvides(self.request, IDisableCSRFProtection)
242
+ action = ""
240
243
  if api.user.is_anonymous():
241
244
  self._remember_identity(result)
242
245
  action = "login"
243
246
  else:
244
247
  # Authenticated user, add an identity to it
245
- self._add_identity(result)
246
- action = "add_identity"
248
+ try:
249
+ userid = api.user.get_current().getId()
250
+ self._add_identity(result, userid)
251
+ action = "add_identity"
252
+ except ValueError as err:
253
+ logger.exception(err)
254
+
247
255
  user = api.user.get_current()
248
256
  # Make sure we are not setting cookies here
249
257
  # as it will break the authentication mechanism with JWT tokens
250
258
  self.request.response.cookies = {}
251
- token = self.get_token(user)
252
- self._annotate_transaction(action, user=user)
253
- return {"token": token}
259
+ if action:
260
+ self._annotate_transaction(action, user=user)
261
+ return {"token": self.get_token(user)}
@@ -1,3 +1,4 @@
1
+ from pas.plugins.authomatic.testing import AUTHOMATIC_PLONE_INTEGRATION_TESTING
1
2
  from pas.plugins.authomatic.testing import AUTHOMATIC_ZOPE_FIXTURE
2
3
  from pas.plugins.authomatic.tests.mocks import make_user
3
4
 
@@ -56,6 +57,19 @@ class TestPlugin(unittest.TestCase):
56
57
  self.assertEqual(admin["pluginid"], "users")
57
58
  self.assertEqual(self.aclu.getUserById("admin").getId(), "admin")
58
59
 
60
+
61
+ class TestPlonePlugin(unittest.TestCase):
62
+
63
+ layer = AUTHOMATIC_PLONE_INTEGRATION_TESTING
64
+
65
+ def setUp(self):
66
+ # create plugin
67
+ from pas.plugins.authomatic.setuphandlers import _add_plugin
68
+
69
+ self.aclu = self.layer["app"].acl_users
70
+ _add_plugin(self.aclu, "authomatic")
71
+ self.plugin = self.aclu["authomatic"]
72
+
59
73
  def test_user_enumaration(self):
60
74
  make_user("123joe", testcase=self)
61
75
  make_user("123jane", testcase=self)
@@ -1,4 +1,5 @@
1
1
  """Setup tests for this package."""
2
+
2
3
  from pas.plugins.authomatic.testing import AUTHOMATIC_PLONE_INTEGRATION_TESTING
3
4
  from Products.CMFPlone.utils import get_installer
4
5
 
@@ -1,4 +1,5 @@
1
1
  """Upgrades tests for this package."""
2
+
2
3
  from parameterized import parameterized
3
4
  from pas.plugins.authomatic.testing import AUTHOMATIC_PLONE_INTEGRATION_TESTING
4
5
  from plone.app.testing import setRoles
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pas.plugins.authomatic
3
- Version: 1.2.0
3
+ Version: 1.4.0
4
4
  Summary: Provides OAuth2/OpenID login for Plone using Authomatic.
5
5
  Home-page: https://github.com/collective/pas.plugins.authomatic
6
6
  Author: Jens Klein, Matthias Dollfuss, and Érico Andrei
@@ -25,6 +25,7 @@ Classifier: Programming Language :: Python :: 3.8
25
25
  Classifier: Programming Language :: Python :: 3.9
26
26
  Classifier: Programming Language :: Python :: 3.10
27
27
  Classifier: Programming Language :: Python :: 3.11
28
+ Classifier: Programming Language :: Python :: 3.12
28
29
  Classifier: Programming Language :: Python
29
30
  Requires-Python: >=3.7
30
31
  Description-Content-Type: text/markdown
@@ -259,6 +260,20 @@ The project is licensed under the GPLv2.
259
260
 
260
261
  # Changelog
261
262
 
263
+ ## 1.4.0 (2024-12-13)
264
+
265
+
266
+ - Patch `authomatic.providers.BaseProvider._fetch` to support Python 3.12 @ericof.
267
+
268
+
269
+ ## 1.3.0 (2024-11-21)
270
+
271
+ - Search users by fullname and email. @alecghica
272
+ - Fix login on Volto frontend when already logged-in in Plone Classic. @avoinea
273
+ - Add the possibility to override the ZopeRequestAdapter.
274
+ - Fix the authomatic view when it is reporting an exception that does not have a message attribute
275
+
276
+
262
277
  ## 1.2.0 (2023-09-13)
263
278
 
264
279
  - Add Spanish translation. @macagua
@@ -25,6 +25,7 @@ src/pas/plugins/__init__.py
25
25
  src/pas/plugins/authomatic/__init__.py
26
26
  src/pas/plugins/authomatic/configure.zcml
27
27
  src/pas/plugins/authomatic/interfaces.py
28
+ src/pas/plugins/authomatic/logging.py
28
29
  src/pas/plugins/authomatic/meta.zcml
29
30
  src/pas/plugins/authomatic/plugin.py
30
31
  src/pas/plugins/authomatic/profiles.zcml
@@ -56,6 +57,8 @@ src/pas/plugins/authomatic/locales/fr/LC_MESSAGES/pas.plugins.authomatic.po
56
57
  src/pas/plugins/authomatic/locales/it/LC_MESSAGES/pas.plugins.authomatic.po
57
58
  src/pas/plugins/authomatic/locales/pt_BR/LC_MESSAGES/pas.plugins.authomatic.po
58
59
  src/pas/plugins/authomatic/locales/ro/LC_MESSAGES/pas.plugins.authomatic.po
60
+ src/pas/plugins/authomatic/patches/__init__.py
61
+ src/pas/plugins/authomatic/patches/authomatic.py
59
62
  src/pas/plugins/authomatic/profiles/default/browserlayer.xml
60
63
  src/pas/plugins/authomatic/profiles/default/controlpanel.xml
61
64
  src/pas/plugins/authomatic/profiles/default/metadata.xml
@@ -1,4 +1,4 @@
1
- authomatic>=1.0.0
1
+ authomatic>=1.3.0
2
2
  Products.CMFPlone>=5.2
3
3
  plone.restapi
4
4
  setuptools