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.
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/CHANGELOG.md +14 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/PKG-INFO +16 -1
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/setup.py +4 -2
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/__init__.py +14 -6
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/view.py +11 -2
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/update.py +1 -0
- pas.plugins.authomatic-1.4.0/src/pas/plugins/authomatic/logging.py +6 -0
- pas.plugins.authomatic-1.4.0/src/pas/plugins/authomatic/patches/__init__.py +5 -0
- pas.plugins.authomatic-1.4.0/src/pas/plugins/authomatic/patches/authomatic.py +147 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/plugin.py +18 -2
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/services/authomatic.py +17 -9
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_plugin.py +14 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_setup.py +1 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_upgrades.py +1 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/PKG-INFO +16 -1
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/SOURCES.txt +3 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/requires.txt +1 -1
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/.coveragerc +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/.editorconfig +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/CONTRIBUTORS.md +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/LICENSE.txt +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/MANIFEST.in +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/Makefile +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/README.md +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/docs/authomatic.svg +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/docs/plone-control-panel.png +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/docs/plugin-settings.png +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/pyproject.toml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/requirements.txt +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/setup.cfg +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/__init__.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/__init__.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/__init__.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/add_plugin.pt +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/authomatic.png +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/authomatic.pt +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/configure.zcml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/controlpanel.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/resources/authomatic-logo.svg +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/resources/authomatic.css +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/browser/resources/authomatic.less +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/configure.zcml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/integration/__init__.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/integration/restapi.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/integration/zope.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/interfaces.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/__init__.py +0 -0
- {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
- {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
- {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
- {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
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/pas.plugins.authomatic-manual.pot +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/locales/pas.plugins.authomatic.pot +0 -0
- {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
- {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
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/meta.zcml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/default/browserlayer.xml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/default/controlpanel.xml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/default/metadata.xml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/default/registry.xml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/uninstall/browserlayer.xml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/uninstall/controlpanel.xml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles/uninstall/registry.xml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/profiles.zcml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/services/__init__.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/services/configure.zcml +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/services/login.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/setuphandlers.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/testing.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/__init__.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/mocks.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_browser_controlpanel.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_services_authomatic.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_services_login.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_setuphandler.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_useridentities.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/tests/test_useridfactories.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/useridentities.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/useridfactories.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/utils.py +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/dependency_links.txt +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/entry_points.txt +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/namespace_packages.txt +0 -0
- {pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas.plugins.authomatic.egg-info/not-zip-safe +0 -0
- {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.
|
|
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.
|
|
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.
|
|
55
|
+
"authomatic>=1.3.0",
|
|
54
56
|
"Products.CMFPlone>=5.2",
|
|
55
57
|
"plone.restapi",
|
|
56
58
|
"setuptools",
|
{pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/__init__.py
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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(
|
|
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
|
-
|
|
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:
|
|
@@ -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")
|
{pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/plugin.py
RENAMED
|
@@ -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
|
-
|
|
266
|
-
|
|
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
|
-
|
|
246
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
return {"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,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pas.plugins.authomatic
|
|
3
|
-
Version: 1.
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/meta.zcml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/testing.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pas.plugins.authomatic-1.2.0 → pas.plugins.authomatic-1.4.0}/src/pas/plugins/authomatic/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|