fractal-server 2.18.3a1__py3-none-any.whl → 2.18.4__py3-none-any.whl

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.
@@ -1 +1 @@
1
- __VERSION__ = "2.18.3a1"
1
+ __VERSION__ = "2.18.4"
@@ -3,6 +3,8 @@ from httpx_oauth.clients.github import GitHubOAuth2
3
3
  from httpx_oauth.clients.google import GoogleOAuth2
4
4
  from httpx_oauth.clients.openid import OpenID
5
5
  from httpx_oauth.clients.openid import OpenIDConfigurationError
6
+ from httpx_oauth.exceptions import GetIdEmailError
7
+ from httpx_oauth.exceptions import GetProfileError
6
8
 
7
9
  from fractal_server.config import OAuthSettings
8
10
  from fractal_server.config import get_oauth_settings
@@ -13,6 +15,29 @@ from . import cookie_backend
13
15
  from . import fastapi_users
14
16
 
15
17
 
18
+ class FractalOpenID(OpenID):
19
+ """
20
+ Subclass of `httpx_oauth.clients.openid.OpenID` with customizable name for
21
+ the `"email"` claim.
22
+ """
23
+
24
+ def __init__(self, *, email_claim: str, **kwargs):
25
+ super().__init__(**kwargs)
26
+ self.email_claim = email_claim
27
+
28
+ # TODO-requires-py312: add `@override` decorator
29
+ async def get_id_email(self, token: str) -> tuple[str, str | None]:
30
+ """
31
+ Identical to the parent-class method (httpx-oauth version 0.16.1),
32
+ apart from making `"email"` configurable.
33
+ """
34
+ try:
35
+ profile = await self.get_profile(token)
36
+ except GetProfileError as e:
37
+ raise GetIdEmailError(response=e.response) from e
38
+ return str(profile["sub"]), profile.get(self.email_claim)
39
+
40
+
16
41
  def _create_client_github(cfg: OAuthSettings) -> GitHubOAuth2:
17
42
  return GitHubOAuth2(
18
43
  client_id=cfg.OAUTH_CLIENT_ID.get_secret_value(),
@@ -29,10 +54,11 @@ def _create_client_google(cfg: OAuthSettings) -> GoogleOAuth2:
29
54
 
30
55
  def _create_client_oidc(cfg: OAuthSettings) -> OpenID:
31
56
  try:
32
- open_id = OpenID(
57
+ open_id = FractalOpenID(
33
58
  client_id=cfg.OAUTH_CLIENT_ID.get_secret_value(),
34
59
  client_secret=cfg.OAUTH_CLIENT_SECRET.get_secret_value(),
35
60
  openid_configuration_endpoint=cfg.OAUTH_OIDC_CONFIG_ENDPOINT.get_secret_value(), # noqa
61
+ email_claim=cfg.OAUTH_EMAIL_CLAIM,
36
62
  )
37
63
  except OpenIDConfigurationError as e:
38
64
  OAUTH_OIDC_CONFIG_ENDPOINT = (
@@ -28,6 +28,11 @@ class OAuthSettings(BaseSettings):
28
28
  String to be used as `redirect_url` argument in
29
29
  `fastapi_users.get_oauth_router`, and then in
30
30
  `httpx_oauth.integrations.fastapi.OAuth2AuthorizeCallback`.
31
+ OAUTH_EMAIL_CLAIM:
32
+ Name of the OIDC claim with the user's email address. This is
33
+ `"email"` by default, but can be customized (e.g. to `"mail"`) to
34
+ fit with the response from the userinfo endpoint - see
35
+ https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse
31
36
  """
32
37
 
33
38
  model_config = SettingsConfigDict(**SETTINGS_CONFIG_DICT)
@@ -43,6 +48,7 @@ class OAuthSettings(BaseSettings):
43
48
  OAUTH_CLIENT_SECRET: SecretStr | None = None
44
49
  OAUTH_OIDC_CONFIG_ENDPOINT: SecretStr | None = None
45
50
  OAUTH_REDIRECT_URL: str | None = None
51
+ OAUTH_EMAIL_CLAIM: str = "email"
46
52
 
47
53
  @model_validator(mode="after")
48
54
  def check_configuration(self: Self) -> Self:
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fractal-server
3
- Version: 2.18.3a1
3
+ Version: 2.18.4
4
4
  Summary: Backend component of the Fractal analytics platform
5
5
  Author: Tommaso Comparin, Marco Franzon, Yuri Chiucconi, Jacopo Nespolo
6
6
  Author-email: Tommaso Comparin <tommaso.comparin@exact-lab.it>, Marco Franzon <marco.franzon@exact-lab.it>, Yuri Chiucconi <yuri.chiucconi@exact-lab.it>, Jacopo Nespolo <jacopo.nespolo@exact-lab.it>
7
7
  License-Expression: BSD-3-Clause
8
+ License-File: LICENSE
8
9
  Requires-Dist: fastapi>=0.120.0,<0.121.0
9
10
  Requires-Dist: sqlmodel==0.0.27
10
11
  Requires-Dist: sqlalchemy[asyncio]>=2.0.23,<2.1
@@ -1,4 +1,4 @@
1
- fractal_server/__init__.py,sha256=2-J9RpG_KXCtJNi4kxk3w5ETlw28IsXy-07Hns9oc6A,25
1
+ fractal_server/__init__.py,sha256=1XYvdP5XhyuSdiA2WGJBMg-1xFdd82EGTGvgLTEc9Hg,23
2
2
  fractal_server/__main__.py,sha256=QeKoAgqoiozLJDa8kSVe-Aso1WWgrk1yLUYWS8RxZVM,11405
3
3
  fractal_server/alembic.ini,sha256=MWwi7GzjzawI9cCAK1LW7NxIBQDUqD12-ptJoq5JpP0,3153
4
4
  fractal_server/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -65,7 +65,7 @@ fractal_server/app/routes/auth/_aux_auth.py,sha256=gKdYTWUzxcU44Iep787zReWwdAs4k
65
65
  fractal_server/app/routes/auth/current_user.py,sha256=uDWttWo9isG69Jv1EGnnr2Ki5ZGd0D76jgjVDQMkn8c,3251
66
66
  fractal_server/app/routes/auth/group.py,sha256=uR98vdQHH-7BFl-Czj85ESPxT2yQymy4qtagaMrnUPU,6491
67
67
  fractal_server/app/routes/auth/login.py,sha256=buVa5Y8T0cd_SW1CqC-zMv-3SfPxGJknf7MYlUyKOl0,567
68
- fractal_server/app/routes/auth/oauth.py,sha256=NxrwOWBGPe7hLPEnD66nfWPGMWzDM80LIrwtmONVw-4,2731
68
+ fractal_server/app/routes/auth/oauth.py,sha256=ocQjyy6OfuEORDYVVzQSgcisSwL-YLZxacq7FuzwJF4,3673
69
69
  fractal_server/app/routes/auth/register.py,sha256=IiUJhgY0ZrTs0RlBRRjoTv4wF5Gb3eXTInFV-dXkpsE,615
70
70
  fractal_server/app/routes/auth/router.py,sha256=Zip_fw9qJWtoXWjluznschyrCKb2n_rf3xWarSXMkgI,692
71
71
  fractal_server/app/routes/auth/users.py,sha256=5BagdH1dz-ZoXdvTgIo9QWBNFPW3p1pIZfY9BBu4eds,7397
@@ -103,7 +103,7 @@ fractal_server/config/_data.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
103
103
  fractal_server/config/_database.py,sha256=0_FvboMkQEKKRxvr9uFdp98oiQwMTFbdCW3loTZNSY0,1846
104
104
  fractal_server/config/_email.py,sha256=vMwLHN9-beYp_-up-WkTpeyNUZk4EHwt3N2l6-PYnx4,4364
105
105
  fractal_server/config/_main.py,sha256=6splUmAPRD1J9HXkeZ-Vqif7Nw4ljJXIugpvRrcwPeI,2476
106
- fractal_server/config/_oauth.py,sha256=UTmlFppDZcOQhr3RvkiG5XMqvr54XRAQ_Y-iR0V8N-8,2024
106
+ fractal_server/config/_oauth.py,sha256=kktD0MEZ_NV4QOK6RmOXDK1x8RCrFEkqC6WLY-DzRIY,2390
107
107
  fractal_server/config/_settings_config.py,sha256=tsyXQOnn9QKCFJD6hRo_dJXlQQyl70DbqgHMJoZ1xnY,144
108
108
  fractal_server/data_migrations/tools.py,sha256=LeMeASwYGtEqd-3wOLle6WARdTGAimoyMmRbbJl-hAM,572
109
109
  fractal_server/exceptions.py,sha256=l6aZDk_6u_9PwDaQSoIFdI40ekpzqOJaxjx5rhW-HVI,141
@@ -267,7 +267,8 @@ fractal_server/types/validators/_workflow_task_arguments_validators.py,sha256=zt
267
267
  fractal_server/urls.py,sha256=QjIKAC1a46bCdiPMu3AlpgFbcv6a4l3ABcd5xz190Og,471
268
268
  fractal_server/utils.py,sha256=-rjg8QTXQcKweXjn0NcmETFs1_uM9PGnbl0Q7c4ERPM,2181
269
269
  fractal_server/zip_tools.py,sha256=Uhn-ax4_9g1PJ32BdyaX30hFpAeVOv2tZYTUK-zVn1E,5719
270
- fractal_server-2.18.3a1.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
271
- fractal_server-2.18.3a1.dist-info/entry_points.txt,sha256=3TpdcjmETRYWJxFyAh3z-9955EWua9jdkSnBwxES1uE,60
272
- fractal_server-2.18.3a1.dist-info/METADATA,sha256=dowEZiXk1xYXEsowmAdTx54gIWNNZ6w8PJYuvUczzdA,4163
273
- fractal_server-2.18.3a1.dist-info/RECORD,,
270
+ fractal_server-2.18.4.dist-info/licenses/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
271
+ fractal_server-2.18.4.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
272
+ fractal_server-2.18.4.dist-info/entry_points.txt,sha256=3TpdcjmETRYWJxFyAh3z-9955EWua9jdkSnBwxES1uE,60
273
+ fractal_server-2.18.4.dist-info/METADATA,sha256=Un1KFSgGTikpOVXkKrM5PQLo3lWQsYUzNN_0cTA1nyM,4183
274
+ fractal_server-2.18.4.dist-info/RECORD,,
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright 2022 (C) Friedrich Miescher Institute for Biomedical Research and University of Zurich
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.