swarmauri_auth_idp_gitea 0.2.0.dev4__tar.gz → 0.11.0.dev1__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.
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/PKG-INFO +16 -13
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/README.md +10 -9
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/pyproject.toml +6 -4
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/swarmauri_auth_idp_gitea/GiteaOAuth20Login.py +6 -2
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/swarmauri_auth_idp_gitea/GiteaOAuth21AppClient.py +14 -4
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/swarmauri_auth_idp_gitea/GiteaOAuth21Login.py +6 -2
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/swarmauri_auth_idp_gitea/GiteaOAuthLoginMixin.py +8 -3
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/swarmauri_auth_idp_gitea/GiteaOIDC10AppClient.py +3 -1
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/swarmauri_auth_idp_gitea/GiteaOIDC10Login.py +12 -3
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/LICENSE +0 -0
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/swarmauri_auth_idp_gitea/GiteaOAuth20AppClient.py +0 -0
- {swarmauri_auth_idp_gitea-0.2.0.dev4 → swarmauri_auth_idp_gitea-0.11.0.dev1}/swarmauri_auth_idp_gitea/__init__.py +0 -0
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swarmauri_auth_idp_gitea
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0.dev1
|
|
4
4
|
Summary: Gitea 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,gitea,git,idp
|
|
8
8
|
Author: Jacob Stewart
|
|
9
9
|
Author-email: jacob@swarmauri.com
|
|
10
|
-
Requires-Python: >=3.10,<3.
|
|
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:
|
|
22
|
-
Classifier:
|
|
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
|
-

|
|
30
32
|
|
|
31
33
|
<p align="center">
|
|
34
|
+
<a href="https://pepy.tech/project/swarmauri_auth_idp_gitea/">
|
|
35
|
+
<img src="https://static.pepy.tech/badge/swarmauri_auth_idp_gitea/month" alt="PyPI - Downloads"/></a>
|
|
36
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_auth_idp_gitea/">
|
|
37
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_auth_idp_gitea.svg"/></a>
|
|
32
38
|
<a href="https://pypi.org/project/swarmauri_auth_idp_gitea/">
|
|
33
|
-
<img src="https://img.shields.io/
|
|
34
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/experimental/swarmauri_auth_idp_gitea/">
|
|
35
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/experimental/swarmauri_auth_idp_gitea.svg"/></a>
|
|
36
|
-
<a href="https://pypi.org/project/swarmauri_auth_idp_gitea/">
|
|
37
|
-
<img src="https://img.shields.io/pypi/pyversions/swarmauri_auth_idp_gitea" 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_gitea/">
|
|
39
41
|
<img src="https://img.shields.io/pypi/l/swarmauri_auth_idp_gitea" alt="PyPI - License"/></a>
|
|
40
42
|
<a href="https://pypi.org/project/swarmauri_auth_idp_gitea/">
|
|
41
43
|
<img src="https://img.shields.io/pypi/v/swarmauri_auth_idp_gitea?label=swarmauri_auth_idp_gitea&color=green" alt="PyPI - swarmauri_auth_idp_gitea"/></a>
|
|
42
|
-
|
|
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 Gitea
|
|
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
|
covering development workflow, testing, and coding standards.
|
|
127
128
|
|
|
129
|
+
|
|
130
|
+
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
+
<a href="https://pepy.tech/project/swarmauri_auth_idp_gitea/">
|
|
5
|
+
<img src="https://static.pepy.tech/badge/swarmauri_auth_idp_gitea/month" alt="PyPI - Downloads"/></a>
|
|
6
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_auth_idp_gitea/">
|
|
7
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_auth_idp_gitea.svg"/></a>
|
|
4
8
|
<a href="https://pypi.org/project/swarmauri_auth_idp_gitea/">
|
|
5
|
-
<img src="https://img.shields.io/
|
|
6
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/experimental/swarmauri_auth_idp_gitea/">
|
|
7
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/experimental/swarmauri_auth_idp_gitea.svg"/></a>
|
|
8
|
-
<a href="https://pypi.org/project/swarmauri_auth_idp_gitea/">
|
|
9
|
-
<img src="https://img.shields.io/pypi/pyversions/swarmauri_auth_idp_gitea" 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_gitea/">
|
|
11
11
|
<img src="https://img.shields.io/pypi/l/swarmauri_auth_idp_gitea" alt="PyPI - License"/></a>
|
|
12
12
|
<a href="https://pypi.org/project/swarmauri_auth_idp_gitea/">
|
|
13
13
|
<img src="https://img.shields.io/pypi/v/swarmauri_auth_idp_gitea?label=swarmauri_auth_idp_gitea&color=green" alt="PyPI - swarmauri_auth_idp_gitea"/></a>
|
|
14
|
-
|
|
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 Gitea
|
|
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
|
covering development workflow, testing, and coding standards.
|
|
98
|
+
|
|
99
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_auth_idp_gitea"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.11.0.dev1"
|
|
4
4
|
description = "Gitea 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.
|
|
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
|
-
"
|
|
22
|
-
"
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
23
25
|
]
|
|
24
26
|
dependencies = [
|
|
25
27
|
"swarmauri_core",
|
|
@@ -18,11 +18,15 @@ class GiteaOAuth20Login(GiteaOAuthLoginMixin, OAuth20LoginBase):
|
|
|
18
18
|
payload = await self._auth_payload()
|
|
19
19
|
return {"url": payload["url"], "state": payload["state"]}
|
|
20
20
|
|
|
21
|
-
async def exchange_and_identity(
|
|
21
|
+
async def exchange_and_identity(
|
|
22
|
+
self, code: str, state: str
|
|
23
|
+
) -> Mapping[str, Any]:
|
|
22
24
|
tokens = await self._exchange_tokens(code, state)
|
|
23
25
|
profile = await self._fetch_profile(tokens["access_token"])
|
|
24
26
|
name = (
|
|
25
|
-
profile.get("full_name")
|
|
27
|
+
profile.get("full_name")
|
|
28
|
+
or profile.get("username")
|
|
29
|
+
or profile.get("login")
|
|
26
30
|
)
|
|
27
31
|
return {
|
|
28
32
|
"issuer": "gitea-oauth2",
|
|
@@ -35,10 +35,16 @@ class GiteaOAuth21AppClient(OAuth21AppClientBase):
|
|
|
35
35
|
return f"{self.base_url.rstrip('/')}/login/oauth/access_token"
|
|
36
36
|
|
|
37
37
|
def _client_secret_value(self) -> Optional[str]:
|
|
38
|
-
return
|
|
38
|
+
return (
|
|
39
|
+
self.client_secret.get_secret_value()
|
|
40
|
+
if self.client_secret
|
|
41
|
+
else None
|
|
42
|
+
)
|
|
39
43
|
|
|
40
44
|
@staticmethod
|
|
41
|
-
def _load_private_key(
|
|
45
|
+
def _load_private_key(
|
|
46
|
+
jwk_payload: Mapping[str, Any], algorithm: str
|
|
47
|
+
) -> Any:
|
|
42
48
|
serialized = json.dumps(jwk_payload)
|
|
43
49
|
if algorithm.upper().startswith("ES"):
|
|
44
50
|
return jwt.algorithms.ECAlgorithm.from_jwk(serialized)
|
|
@@ -65,7 +71,9 @@ class GiteaOAuth21AppClient(OAuth21AppClientBase):
|
|
|
65
71
|
payload, key=key, algorithm=algorithm, headers=headers or None
|
|
66
72
|
)
|
|
67
73
|
return {
|
|
68
|
-
"client_assertion_type":
|
|
74
|
+
"client_assertion_type": (
|
|
75
|
+
"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
|
|
76
|
+
),
|
|
69
77
|
"client_assertion": assertion,
|
|
70
78
|
}
|
|
71
79
|
|
|
@@ -80,7 +88,9 @@ class GiteaOAuth21AppClient(OAuth21AppClientBase):
|
|
|
80
88
|
else:
|
|
81
89
|
secret = self._client_secret_value()
|
|
82
90
|
if not secret:
|
|
83
|
-
raise ValueError(
|
|
91
|
+
raise ValueError(
|
|
92
|
+
"client_secret or private_key_jwk must be provided"
|
|
93
|
+
)
|
|
84
94
|
auth = (self.client_id, secret)
|
|
85
95
|
payload = {**form, **body}
|
|
86
96
|
async with self._http_client_factory() as client:
|
|
@@ -18,11 +18,15 @@ class GiteaOAuth21Login(GiteaOAuthLoginMixin, OAuth21LoginBase):
|
|
|
18
18
|
payload = await self._auth_payload()
|
|
19
19
|
return {"url": payload["url"], "state": payload["state"]}
|
|
20
20
|
|
|
21
|
-
async def exchange_and_identity(
|
|
21
|
+
async def exchange_and_identity(
|
|
22
|
+
self, code: str, state: str
|
|
23
|
+
) -> Mapping[str, Any]:
|
|
22
24
|
tokens = await self._exchange_tokens(code, state)
|
|
23
25
|
profile = await self._fetch_profile(tokens["access_token"])
|
|
24
26
|
name = (
|
|
25
|
-
profile.get("full_name")
|
|
27
|
+
profile.get("full_name")
|
|
28
|
+
or profile.get("username")
|
|
29
|
+
or profile.get("login")
|
|
26
30
|
)
|
|
27
31
|
return {
|
|
28
32
|
"issuer": "gitea-oauth21",
|
|
@@ -57,7 +57,9 @@ class GiteaOAuthLoginMixin:
|
|
|
57
57
|
)
|
|
58
58
|
return {"url": url, "state": state, "verifier": verifier}
|
|
59
59
|
|
|
60
|
-
async def _exchange_tokens(
|
|
60
|
+
async def _exchange_tokens(
|
|
61
|
+
self, code: str, state: str
|
|
62
|
+
) -> Mapping[str, Any]:
|
|
61
63
|
payload = verify_state(self._state_secret_value(), state)
|
|
62
64
|
form = {
|
|
63
65
|
"grant_type": "authorization_code",
|
|
@@ -83,7 +85,9 @@ class GiteaOAuthLoginMixin:
|
|
|
83
85
|
}
|
|
84
86
|
api_base = self._api_base_url()
|
|
85
87
|
async with self._http_client_factory() as client:
|
|
86
|
-
response = await client.get_retry(
|
|
88
|
+
response = await client.get_retry(
|
|
89
|
+
f"{api_base}/user", headers=headers
|
|
90
|
+
)
|
|
87
91
|
response.raise_for_status()
|
|
88
92
|
profile = response.json()
|
|
89
93
|
if not profile.get("email"):
|
|
@@ -98,7 +102,8 @@ class GiteaOAuthLoginMixin:
|
|
|
98
102
|
(
|
|
99
103
|
entry
|
|
100
104
|
for entry in emails
|
|
101
|
-
if entry.get("primary")
|
|
105
|
+
if entry.get("primary")
|
|
106
|
+
and entry.get("verified")
|
|
102
107
|
),
|
|
103
108
|
None,
|
|
104
109
|
)
|
|
@@ -14,7 +14,9 @@ from swarmauri_base.auth_idp.http import RetryingAsyncClient
|
|
|
14
14
|
|
|
15
15
|
@ComponentBase.register_type(OIDC10AppClientBase, "GiteaOIDC10AppClient")
|
|
16
16
|
class GiteaOIDC10AppClient(OIDC10AppClientBase):
|
|
17
|
-
"""
|
|
17
|
+
"""
|
|
18
|
+
Request client credentials tokens using Gitea's OIDC discovery metadata.
|
|
19
|
+
"""
|
|
18
20
|
|
|
19
21
|
model_config = ConfigDict(extra="forbid")
|
|
20
22
|
|
|
@@ -91,8 +91,12 @@ class GiteaOIDC10Login(OIDC10LoginBase):
|
|
|
91
91
|
jwks = jwks_response.json()
|
|
92
92
|
claims = await self._decode_id_token(tokens, jwks, metadata)
|
|
93
93
|
email = claims.get("email")
|
|
94
|
-
name =
|
|
95
|
-
|
|
94
|
+
name = (
|
|
95
|
+
claims.get("name") or claims.get("preferred_username") or "Unknown"
|
|
96
|
+
)
|
|
97
|
+
if (not email or name == "Unknown") and metadata.get(
|
|
98
|
+
"userinfo_endpoint"
|
|
99
|
+
):
|
|
96
100
|
async with self._http_client_factory() as client:
|
|
97
101
|
userinfo_response = await client.get_retry(
|
|
98
102
|
metadata["userinfo_endpoint"],
|
|
@@ -127,7 +131,12 @@ class GiteaOIDC10Login(OIDC10LoginBase):
|
|
|
127
131
|
if not kid:
|
|
128
132
|
raise ValueError("missing kid in id_token header")
|
|
129
133
|
key_entry = next(
|
|
130
|
-
(
|
|
134
|
+
(
|
|
135
|
+
entry
|
|
136
|
+
for entry in jwks.get("keys", [])
|
|
137
|
+
if entry.get("kid") == kid
|
|
138
|
+
),
|
|
139
|
+
None,
|
|
131
140
|
)
|
|
132
141
|
if not key_entry:
|
|
133
142
|
raise ValueError("signing key not found")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|