swarmauri_auth_idp_cognito 0.2.0.dev5__tar.gz → 0.11.0.dev2__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 (12) hide show
  1. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/PKG-INFO +16 -13
  2. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/README.md +10 -9
  3. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/pyproject.toml +6 -4
  4. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/swarmauri_auth_idp_cognito/CognitoLoginMixin.py +3 -1
  5. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/swarmauri_auth_idp_cognito/CognitoOAuth20AppClient.py +2 -1
  6. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/swarmauri_auth_idp_cognito/CognitoOAuth20Login.py +16 -4
  7. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/swarmauri_auth_idp_cognito/CognitoOAuth21AppClient.py +16 -5
  8. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/swarmauri_auth_idp_cognito/CognitoOAuth21Login.py +14 -4
  9. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/swarmauri_auth_idp_cognito/CognitoOIDC10AppClient.py +2 -1
  10. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/swarmauri_auth_idp_cognito/CognitoOIDC10Login.py +9 -3
  11. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/LICENSE +0 -0
  12. {swarmauri_auth_idp_cognito-0.2.0.dev5 → swarmauri_auth_idp_cognito-0.11.0.dev2}/swarmauri_auth_idp_cognito/__init__.py +0 -0
@@ -1,47 +1,48 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: swarmauri_auth_idp_cognito
3
- Version: 0.2.0.dev5
3
+ Version: 0.11.0.dev2
4
4
  Summary: AWS Cognito OAuth 2.0 / OAuth 2.1 / OIDC 1.0 identity provider implementations for Swarmauri
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
7
7
  Keywords: swarmauri,sdk,experimental,identity,oauth2,oauth21,oidc,cognito,aws,idp
8
8
  Author: Jacob Stewart
9
9
  Author-email: jacob@swarmauri.com
10
- Requires-Python: >=3.10,<3.13
10
+ Requires-Python: >=3.10,<3.15
11
11
  Classifier: Development Status :: 1 - Planning
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: License :: OSI Approved :: Apache Software License
14
14
  Classifier: Natural Language :: English
15
+ Classifier: Topic :: Internet :: WWW/HTTP :: Session
16
+ Classifier: Topic :: Security :: Cryptography
15
17
  Classifier: Programming Language :: Python
16
18
  Classifier: Programming Language :: Python :: 3
17
19
  Classifier: Programming Language :: Python :: 3 :: Only
18
20
  Classifier: Programming Language :: Python :: 3.10
19
21
  Classifier: Programming Language :: Python :: 3.11
20
22
  Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Topic :: Internet :: WWW/HTTP :: Session
22
- Classifier: Topic :: Security :: Cryptography
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
23
25
  Requires-Dist: httpx
24
26
  Requires-Dist: pyjwt[crypto] (>=2.8)
25
27
  Requires-Dist: swarmauri_base
26
28
  Requires-Dist: swarmauri_core
27
29
  Description-Content-Type: text/markdown
28
30
 
29
- ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/master/assets/swarmauri.brand.theme.svg)
31
+ ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
30
32
 
31
33
  <p align="center">
34
+ <a href="https://pepy.tech/project/swarmauri_auth_idp_cognito/">
35
+ <img src="https://static.pepy.tech/badge/swarmauri_auth_idp_cognito/month" alt="PyPI - Downloads"/></a>
36
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_auth_idp_cognito/">
37
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_auth_idp_cognito.svg"/></a>
32
38
  <a href="https://pypi.org/project/swarmauri_auth_idp_cognito/">
33
- <img src="https://img.shields.io/pypi/dm/swarmauri_auth_idp_cognito" alt="PyPI - Downloads"/></a>
34
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/experimental/swarmauri_auth_idp_cognito/">
35
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/experimental/swarmauri_auth_idp_cognito.svg"/></a>
36
- <a href="https://pypi.org/project/swarmauri_auth_idp_cognito/">
37
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_auth_idp_cognito" alt="PyPI - Python Version"/></a>
39
+ <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
38
40
  <a href="https://pypi.org/project/swarmauri_auth_idp_cognito/">
39
41
  <img src="https://img.shields.io/pypi/l/swarmauri_auth_idp_cognito" alt="PyPI - License"/></a>
40
42
  <a href="https://pypi.org/project/swarmauri_auth_idp_cognito/">
41
43
  <img src="https://img.shields.io/pypi/v/swarmauri_auth_idp_cognito?label=swarmauri_auth_idp_cognito&color=green" alt="PyPI - swarmauri_auth_idp_cognito"/></a>
42
- </p>
43
-
44
- ---
44
+ <a href="https://discord.gg/N4UpBuQv8T">
45
+ <img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
45
46
 
46
47
  # Swarmauri Auth IDP Cognito
47
48
 
@@ -125,3 +126,5 @@ To contribute to swarmauri-sdk, review the
125
126
  [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md),
126
127
  including development workflow, testing, and coding standards.
127
128
 
129
+
130
+
@@ -1,19 +1,18 @@
1
- ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/master/assets/swarmauri.brand.theme.svg)
1
+ ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
2
2
 
3
3
  <p align="center">
4
+ <a href="https://pepy.tech/project/swarmauri_auth_idp_cognito/">
5
+ <img src="https://static.pepy.tech/badge/swarmauri_auth_idp_cognito/month" alt="PyPI - Downloads"/></a>
6
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_auth_idp_cognito/">
7
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_auth_idp_cognito.svg"/></a>
4
8
  <a href="https://pypi.org/project/swarmauri_auth_idp_cognito/">
5
- <img src="https://img.shields.io/pypi/dm/swarmauri_auth_idp_cognito" alt="PyPI - Downloads"/></a>
6
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/experimental/swarmauri_auth_idp_cognito/">
7
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/experimental/swarmauri_auth_idp_cognito.svg"/></a>
8
- <a href="https://pypi.org/project/swarmauri_auth_idp_cognito/">
9
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_auth_idp_cognito" alt="PyPI - Python Version"/></a>
9
+ <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
10
10
  <a href="https://pypi.org/project/swarmauri_auth_idp_cognito/">
11
11
  <img src="https://img.shields.io/pypi/l/swarmauri_auth_idp_cognito" alt="PyPI - License"/></a>
12
12
  <a href="https://pypi.org/project/swarmauri_auth_idp_cognito/">
13
13
  <img src="https://img.shields.io/pypi/v/swarmauri_auth_idp_cognito?label=swarmauri_auth_idp_cognito&color=green" alt="PyPI - swarmauri_auth_idp_cognito"/></a>
14
- </p>
15
-
16
- ---
14
+ <a href="https://discord.gg/N4UpBuQv8T">
15
+ <img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
17
16
 
18
17
  # Swarmauri Auth IDP Cognito
19
18
 
@@ -96,3 +95,5 @@ The distribution registers the following entry points:
96
95
  To contribute to swarmauri-sdk, review the
97
96
  [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md),
98
97
  including development workflow, testing, and coding standards.
98
+
99
+
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "swarmauri_auth_idp_cognito"
3
- version = "0.2.0.dev5"
3
+ version = "0.11.0.dev2"
4
4
  description = "AWS Cognito OAuth 2.0 / OAuth 2.1 / OIDC 1.0 identity provider implementations for Swarmauri"
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
7
- requires-python = ">=3.10,<3.13"
7
+ requires-python = ">=3.10,<3.15"
8
8
  repository = "https://github.com/swarmauri/swarmauri-sdk"
9
9
  authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
10
10
  classifiers = [
@@ -12,14 +12,16 @@ classifiers = [
12
12
  "Intended Audience :: Developers",
13
13
  "License :: OSI Approved :: Apache Software License",
14
14
  "Natural Language :: English",
15
+ "Topic :: Internet :: WWW/HTTP :: Session",
16
+ "Topic :: Security :: Cryptography",
15
17
  "Programming Language :: Python",
16
18
  "Programming Language :: Python :: 3",
17
19
  "Programming Language :: Python :: 3 :: Only",
18
20
  "Programming Language :: Python :: 3.10",
19
21
  "Programming Language :: Python :: 3.11",
20
22
  "Programming Language :: Python :: 3.12",
21
- "Topic :: Internet :: WWW/HTTP :: Session",
22
- "Topic :: Security :: Cryptography",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
23
25
  ]
24
26
  dependencies = [
25
27
  "swarmauri_core",
@@ -72,7 +72,9 @@ class CognitoLoginMixin:
72
72
  if headers:
73
73
  request_headers.update(headers)
74
74
  async with self._http_client_factory() as client:
75
- response = await client.post_retry(url, data=data, headers=request_headers)
75
+ response = await client.post_retry(
76
+ url, data=data, headers=request_headers
77
+ )
76
78
  response.raise_for_status()
77
79
  return response.json()
78
80
 
@@ -13,7 +13,8 @@ from swarmauri_base.auth_idp.http import RetryingAsyncClient
13
13
 
14
14
  @ComponentBase.register_type(OAuth20AppClientBase, "CognitoOAuth20AppClient")
15
15
  class CognitoOAuth20AppClient(OAuth20AppClientBase):
16
- """Request machine-to-machine access tokens from Cognito's OAuth 2.0 endpoint."""
16
+ """Request machine-to-machine access tokens from Cognito's OAuth 2.0
17
+ endpoint."""
17
18
 
18
19
  model_config = ConfigDict(extra="forbid")
19
20
 
@@ -6,7 +6,11 @@ from typing import Any, Mapping
6
6
 
7
7
  from pydantic import Field, SecretBytes, SecretStr
8
8
  from swarmauri_base.ComponentBase import ComponentBase
9
- from swarmauri_base.auth_idp import OAuth20LoginBase, make_pkce_pair, sign_state
9
+ from swarmauri_base.auth_idp import (
10
+ OAuth20LoginBase,
11
+ make_pkce_pair,
12
+ sign_state,
13
+ )
10
14
 
11
15
  from .CognitoLoginMixin import CognitoLoginMixin
12
16
 
@@ -35,7 +39,9 @@ class CognitoOAuth20Login(CognitoLoginMixin, OAuth20LoginBase):
35
39
  )
36
40
  return {"url": url, "state": state}
37
41
 
38
- async def exchange_and_identity(self, code: str, state: str) -> Mapping[str, Any]:
42
+ async def exchange_and_identity(
43
+ self, code: str, state: str
44
+ ) -> Mapping[str, Any]:
39
45
  payload = self._state_payload(state)
40
46
  metadata = await self._metadata()
41
47
  form = {
@@ -46,7 +52,9 @@ class CognitoOAuth20Login(CognitoLoginMixin, OAuth20LoginBase):
46
52
  "client_secret": self._client_secret_value(),
47
53
  "code_verifier": payload["verifier"],
48
54
  }
49
- token_json = await self._http_post(metadata["token_endpoint"], data=form)
55
+ token_json = await self._http_post(
56
+ metadata["token_endpoint"], data=form
57
+ )
50
58
  access_token = token_json["access_token"]
51
59
  userinfo_endpoint = metadata.get("userinfo_endpoint") or (
52
60
  f"{self.issuer.rstrip('/')}/oauth2/userInfo"
@@ -58,7 +66,11 @@ class CognitoOAuth20Login(CognitoLoginMixin, OAuth20LoginBase):
58
66
  userinfo_json = await self._http_get(
59
67
  userinfo_endpoint, headers=userinfo_headers
60
68
  )
61
- name = userinfo_json.get("name") or userinfo_json.get("given_name") or "Unknown"
69
+ name = (
70
+ userinfo_json.get("name")
71
+ or userinfo_json.get("given_name")
72
+ or "Unknown"
73
+ )
62
74
  return {
63
75
  "issuer": "cognito-oauth2",
64
76
  "sub": userinfo_json.get("sub"),
@@ -15,7 +15,8 @@ from swarmauri_base.auth_idp.http import RetryingAsyncClient
15
15
 
16
16
  @ComponentBase.register_type(OAuth21AppClientBase, "CognitoOAuth21AppClient")
17
17
  class CognitoOAuth21AppClient(OAuth21AppClientBase):
18
- """Request OAuth 2.1 access tokens using either client secrets or JWT assertions."""
18
+ """Request OAuth 2.1 access tokens using either client secrets or JWT
19
+ assertions."""
19
20
 
20
21
  model_config = ConfigDict(extra="forbid")
21
22
 
@@ -33,10 +34,16 @@ class CognitoOAuth21AppClient(OAuth21AppClientBase):
33
34
  return f"{self.base_url.rstrip('/')}/oauth2/token"
34
35
 
35
36
  def _client_secret_value(self) -> Optional[str]:
36
- return self.client_secret.get_secret_value() if self.client_secret else None
37
+ return (
38
+ self.client_secret.get_secret_value()
39
+ if self.client_secret
40
+ else None
41
+ )
37
42
 
38
43
  @staticmethod
39
- def _load_private_key(jwk_payload: Mapping[str, Any], algorithm: str) -> Any:
44
+ def _load_private_key(
45
+ jwk_payload: Mapping[str, Any], algorithm: str
46
+ ) -> Any:
40
47
  serialized = json.dumps(jwk_payload)
41
48
  if algorithm.upper().startswith("ES"):
42
49
  return jwt.algorithms.ECAlgorithm.from_jwk(serialized)
@@ -63,7 +70,9 @@ class CognitoOAuth21AppClient(OAuth21AppClientBase):
63
70
  payload, key=key, algorithm=algorithm, headers=headers or None
64
71
  )
65
72
  return {
66
- "client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
73
+ "client_assertion_type": (
74
+ "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
75
+ ),
67
76
  "client_assertion": assertion,
68
77
  }
69
78
 
@@ -78,7 +87,9 @@ class CognitoOAuth21AppClient(OAuth21AppClientBase):
78
87
  else:
79
88
  secret = self._client_secret_value()
80
89
  if not secret:
81
- raise ValueError("client_secret or private_key_jwk must be provided")
90
+ raise ValueError(
91
+ "client_secret or private_key_jwk must be provided"
92
+ )
82
93
  auth = (self.client_id, secret)
83
94
  payload = {**form, **body}
84
95
  async with self._http_client_factory() as client:
@@ -6,14 +6,20 @@ from typing import Any, Mapping
6
6
 
7
7
  from pydantic import Field, SecretBytes, SecretStr
8
8
  from swarmauri_base.ComponentBase import ComponentBase
9
- from swarmauri_base.auth_idp import OAuth21LoginBase, make_pkce_pair, sign_state
9
+ from swarmauri_base.auth_idp import (
10
+ OAuth21LoginBase,
11
+ make_pkce_pair,
12
+ sign_state,
13
+ )
10
14
 
11
15
  from .CognitoLoginMixin import CognitoLoginMixin
12
16
 
13
17
 
14
18
  @ComponentBase.register_type(OAuth21LoginBase, "CognitoOAuth21Login")
15
19
  class CognitoOAuth21Login(CognitoLoginMixin, OAuth21LoginBase):
16
- """AWS Cognito OAuth 2.1 Authorization Code flow leveraging OIDC discovery."""
20
+ """
21
+ AWS Cognito OAuth 2.1 Authorization Code flow leveraging OIDC discovery.
22
+ """
17
23
 
18
24
  issuer: str
19
25
  client_id: str
@@ -35,7 +41,9 @@ class CognitoOAuth21Login(CognitoLoginMixin, OAuth21LoginBase):
35
41
  )
36
42
  return {"url": url, "state": state}
37
43
 
38
- async def exchange_and_identity(self, code: str, state: str) -> Mapping[str, Any]:
44
+ async def exchange_and_identity(
45
+ self, code: str, state: str
46
+ ) -> Mapping[str, Any]:
39
47
  payload = self._state_payload(state)
40
48
  metadata = await self._metadata()
41
49
  form = {
@@ -46,7 +54,9 @@ class CognitoOAuth21Login(CognitoLoginMixin, OAuth21LoginBase):
46
54
  "client_secret": self._client_secret_value(),
47
55
  "code_verifier": payload["verifier"],
48
56
  }
49
- token_json = await self._http_post(metadata["token_endpoint"], data=form)
57
+ token_json = await self._http_post(
58
+ metadata["token_endpoint"], data=form
59
+ )
50
60
  claims = await self._decode_id_token(
51
61
  token_json.get("id_token"),
52
62
  jwks_uri=metadata["jwks_uri"],
@@ -13,7 +13,8 @@ from swarmauri_base.auth_idp.http import RetryingAsyncClient
13
13
 
14
14
  @ComponentBase.register_type(OIDC10AppClientBase, "CognitoOIDC10AppClient")
15
15
  class CognitoOIDC10AppClient(OIDC10AppClientBase):
16
- """Request machine-to-machine tokens using Cognito's OIDC discovery metadata."""
16
+ """Request machine-to-machine tokens using Cognito's OIDC discovery
17
+ metadata."""
17
18
 
18
19
  model_config = ConfigDict(extra="forbid")
19
20
 
@@ -13,7 +13,9 @@ from .CognitoLoginMixin import CognitoLoginMixin
13
13
 
14
14
  @ComponentBase.register_type(OIDC10LoginBase, "CognitoOIDC10Login")
15
15
  class CognitoOIDC10Login(CognitoLoginMixin, OIDC10LoginBase):
16
- """AWS Cognito OIDC 1.0 Authorization Code flow with ID token validation."""
16
+ """
17
+ AWS Cognito OIDC 1.0 Authorization Code flow with ID token validation.
18
+ """
17
19
 
18
20
  issuer: str
19
21
  client_id: str
@@ -46,7 +48,9 @@ class CognitoOIDC10Login(CognitoLoginMixin, OIDC10LoginBase):
46
48
  "client_secret": self._client_secret_value(),
47
49
  "code_verifier": payload["verifier"],
48
50
  }
49
- token_json = await self._http_post(metadata["token_endpoint"], data=form)
51
+ token_json = await self._http_post(
52
+ metadata["token_endpoint"], data=form
53
+ )
50
54
  claims = await self._decode_id_token(
51
55
  token_json.get("id_token"),
52
56
  jwks_uri=metadata["jwks_uri"],
@@ -55,7 +59,9 @@ class CognitoOIDC10Login(CognitoLoginMixin, OIDC10LoginBase):
55
59
  )
56
60
  email = claims.get("email")
57
61
  name = claims.get("name") or claims.get("given_name") or "Unknown"
58
- if (not email or name == "Unknown") and metadata.get("userinfo_endpoint"):
62
+ if (not email or name == "Unknown") and metadata.get(
63
+ "userinfo_endpoint"
64
+ ):
59
65
  headers = {
60
66
  "Authorization": f"Bearer {token_json['access_token']}",
61
67
  "Accept": "application/json",