aoidc 0.0.1__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.
- aoidc-0.0.1/.envrc +1 -0
- aoidc-0.0.1/.gitignore +171 -0
- aoidc-0.0.1/LICENSE +21 -0
- aoidc-0.0.1/PKG-INFO +62 -0
- aoidc-0.0.1/README.md +42 -0
- aoidc-0.0.1/aoidc/__init__.py +1 -0
- aoidc-0.0.1/aoidc/__main__.py +32 -0
- aoidc-0.0.1/aoidc/config.py +21 -0
- aoidc-0.0.1/aoidc/errors/__init__.py +13 -0
- aoidc-0.0.1/aoidc/jwt.py +34 -0
- aoidc-0.0.1/aoidc/oauth2/context.py +14 -0
- aoidc-0.0.1/aoidc/oauth2/enums.py +84 -0
- aoidc-0.0.1/aoidc/oauth2/rfc_7591_dynamic_client/__init__.py +0 -0
- aoidc-0.0.1/aoidc/oauth2/rfc_7591_dynamic_client/enums.py +16 -0
- aoidc-0.0.1/aoidc/oauth2/rfc_7636_pkce/__init__.py +0 -0
- aoidc-0.0.1/aoidc/oauth2/rfc_7636_pkce/enums.py +2 -0
- aoidc-0.0.1/aoidc/oauth2/rfc_8414_server_metadata/__init__.py +0 -0
- aoidc-0.0.1/aoidc/oauth2/rfc_8414_server_metadata/enum.py +9 -0
- aoidc-0.0.1/aoidc/oauth2/rfc_8414_server_metadata/metadata.py +294 -0
- aoidc-0.0.1/aoidc/oauth2/rfc_8414_server_metadata/subtypes.py +146 -0
- aoidc-0.0.1/aoidc/oidc/__init__.py +0 -0
- aoidc-0.0.1/aoidc/oidc/discovery/__init__.py +38 -0
- aoidc-0.0.1/aoidc/oidc/discovery/metadata.py +147 -0
- aoidc-0.0.1/aoidc/oidc/oidc.py +101 -0
- aoidc-0.0.1/aoidc/utils.py +61 -0
- aoidc-0.0.1/aoidc/version.py +1 -0
- aoidc-0.0.1/flake.lock +117 -0
- aoidc-0.0.1/flake.nix +102 -0
- aoidc-0.0.1/pyproject.toml +55 -0
- aoidc-0.0.1/uv.lock +500 -0
aoidc-0.0.1/.envrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
use flake .
|
aoidc-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# VSCode
|
|
171
|
+
.vscode/
|
aoidc-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rubikoid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
aoidc-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aoidc
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Suckless implementation of OIDC with asyncs in mind
|
|
5
|
+
Author-email: Rubikoid <rubikoid@rubikoid.ru>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
9
|
+
Classifier: Framework :: AsyncIO
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Security
|
|
13
|
+
Requires-Python: <4,>=3.12
|
|
14
|
+
Requires-Dist: httpx<1,>=0.28.1
|
|
15
|
+
Requires-Dist: joserfc<2,>=1.6.1
|
|
16
|
+
Requires-Dist: msgspec<1,>=0.19.0
|
|
17
|
+
Requires-Dist: pydantic-settings<3,>=2.8.1
|
|
18
|
+
Requires-Dist: pydantic<3,>=2.10.6
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# aOIDC
|
|
22
|
+
|
|
23
|
+
Suckless implementation of [OpenID Connect Core](https://openid.net/specs/openid-connect-core-1_0-final.html) for python with asyncio support in mind.
|
|
24
|
+
|
|
25
|
+
🚧 Currently under development 🚧
|
|
26
|
+
|
|
27
|
+
Also implemented:
|
|
28
|
+
|
|
29
|
+
- [ ] [RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749): The OAuth 2.0 Authorization Framework
|
|
30
|
+
- [ ] [RFC 7033](https://datatracker.ietf.org/doc/html/rfc7033): WebFinger
|
|
31
|
+
- [ ] [RFC 7591](https://datatracker.ietf.org/doc/html/rfc7591): OAuth 2.0 Dynamic Client Registration Protocol - **partically**
|
|
32
|
+
- [ ] [RFC 7636](https://datatracker.ietf.org/doc/html/rfc7636): Proof Key for Code Exchange by OAuth Public Clients
|
|
33
|
+
- [ ] [RFC 7662](https://datatracker.ietf.org/doc/html/rfc7662): OAuth 2.0 Token Introspection
|
|
34
|
+
- [ ] [RFC 8414](https://datatracker.ietf.org/doc/html/rfc8414): OAuth 2.0 Authorization Server Metadata
|
|
35
|
+
- [x] Metadata model
|
|
36
|
+
- [ ] `/.well-known/oauth-authorization-server` request
|
|
37
|
+
- [ ] [OpenID Connect Core](https://openid.net/specs/openid-connect-core-1_0-final.html)
|
|
38
|
+
- [ ] [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0-final.html)
|
|
39
|
+
- [ ] WebFinger discovery
|
|
40
|
+
- [x] Model
|
|
41
|
+
- [x] `.well-known/openid-configuration` request
|
|
42
|
+
|
|
43
|
+
## Implementation status / Roadmap
|
|
44
|
+
|
|
45
|
+
Core functional that I need from such library is simple client authentication via authorization code flow, so this will be implemented first.
|
|
46
|
+
|
|
47
|
+
1. [ ] OIDC Client for `CODE` flow
|
|
48
|
+
2. [ ] OIDC Client for `PKCE` flow
|
|
49
|
+
3. [ ] OIDC Client for token verification
|
|
50
|
+
4. [ ] OIDC Client for `client_credentials` flow
|
|
51
|
+
|
|
52
|
+
## Motivation
|
|
53
|
+
|
|
54
|
+
All the existing python OIDC RP libs are the big balls of mud:
|
|
55
|
+
|
|
56
|
+
- [pyoidc](https://github.com/CZ-NIC/pyoidc) - synchronous, a little obscure, but the best of all existing.
|
|
57
|
+
- [idpy-oidc](https://github.com/IdentityPython/idpy-oidc) - older lib from the same dev as `pyoidc`.
|
|
58
|
+
- [authlib](https://github.com/lepture/authlib) - synchronous, no typing, giant pain to use, dual licensing, bad kwargs architecture, bad docs. Worst library.
|
|
59
|
+
- [oauthlib](https://github.com/oauthlib/oauthlib) - synchronous, no OIDC client, only provider.
|
|
60
|
+
- [oidc-client](https://gitlab.com/yzr-oss/oidc-client) - not really a library.
|
|
61
|
+
|
|
62
|
+
There are few libraries which supports OAuth 2.0 & OIDC as provider (server), but they are out-of-scope.
|
aoidc-0.0.1/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# aOIDC
|
|
2
|
+
|
|
3
|
+
Suckless implementation of [OpenID Connect Core](https://openid.net/specs/openid-connect-core-1_0-final.html) for python with asyncio support in mind.
|
|
4
|
+
|
|
5
|
+
🚧 Currently under development 🚧
|
|
6
|
+
|
|
7
|
+
Also implemented:
|
|
8
|
+
|
|
9
|
+
- [ ] [RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749): The OAuth 2.0 Authorization Framework
|
|
10
|
+
- [ ] [RFC 7033](https://datatracker.ietf.org/doc/html/rfc7033): WebFinger
|
|
11
|
+
- [ ] [RFC 7591](https://datatracker.ietf.org/doc/html/rfc7591): OAuth 2.0 Dynamic Client Registration Protocol - **partically**
|
|
12
|
+
- [ ] [RFC 7636](https://datatracker.ietf.org/doc/html/rfc7636): Proof Key for Code Exchange by OAuth Public Clients
|
|
13
|
+
- [ ] [RFC 7662](https://datatracker.ietf.org/doc/html/rfc7662): OAuth 2.0 Token Introspection
|
|
14
|
+
- [ ] [RFC 8414](https://datatracker.ietf.org/doc/html/rfc8414): OAuth 2.0 Authorization Server Metadata
|
|
15
|
+
- [x] Metadata model
|
|
16
|
+
- [ ] `/.well-known/oauth-authorization-server` request
|
|
17
|
+
- [ ] [OpenID Connect Core](https://openid.net/specs/openid-connect-core-1_0-final.html)
|
|
18
|
+
- [ ] [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0-final.html)
|
|
19
|
+
- [ ] WebFinger discovery
|
|
20
|
+
- [x] Model
|
|
21
|
+
- [x] `.well-known/openid-configuration` request
|
|
22
|
+
|
|
23
|
+
## Implementation status / Roadmap
|
|
24
|
+
|
|
25
|
+
Core functional that I need from such library is simple client authentication via authorization code flow, so this will be implemented first.
|
|
26
|
+
|
|
27
|
+
1. [ ] OIDC Client for `CODE` flow
|
|
28
|
+
2. [ ] OIDC Client for `PKCE` flow
|
|
29
|
+
3. [ ] OIDC Client for token verification
|
|
30
|
+
4. [ ] OIDC Client for `client_credentials` flow
|
|
31
|
+
|
|
32
|
+
## Motivation
|
|
33
|
+
|
|
34
|
+
All the existing python OIDC RP libs are the big balls of mud:
|
|
35
|
+
|
|
36
|
+
- [pyoidc](https://github.com/CZ-NIC/pyoidc) - synchronous, a little obscure, but the best of all existing.
|
|
37
|
+
- [idpy-oidc](https://github.com/IdentityPython/idpy-oidc) - older lib from the same dev as `pyoidc`.
|
|
38
|
+
- [authlib](https://github.com/lepture/authlib) - synchronous, no typing, giant pain to use, dual licensing, bad kwargs architecture, bad docs. Worst library.
|
|
39
|
+
- [oauthlib](https://github.com/oauthlib/oauthlib) - synchronous, no OIDC client, only provider.
|
|
40
|
+
- [oidc-client](https://gitlab.com/yzr-oss/oidc-client) - not really a library.
|
|
41
|
+
|
|
42
|
+
There are few libraries which supports OAuth 2.0 & OIDC as provider (server), but they are out-of-scope.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .version import __version__ # noqa: F401
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from .oidc.oidc import OIDCClient
|
|
3
|
+
|
|
4
|
+
public_tests = [
|
|
5
|
+
# (
|
|
6
|
+
# "284523826908311692",
|
|
7
|
+
# "pflw13U3o1RDXBPOHfDQtPJPfYUeqFWNLQekt8fSXjRiXLo8icmFwdkM0pWBgiNc",
|
|
8
|
+
# "https://idp.cypol.dev",
|
|
9
|
+
# ),
|
|
10
|
+
# (
|
|
11
|
+
# None,
|
|
12
|
+
# None,
|
|
13
|
+
# "https://idphydra-uat.beeline.ru",
|
|
14
|
+
# ),
|
|
15
|
+
(
|
|
16
|
+
"1",
|
|
17
|
+
"A",
|
|
18
|
+
"https://www.certification.openid.net/test/a/test-1/.well-known/openid-configuration",
|
|
19
|
+
),
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
async def main():
|
|
24
|
+
for CLIENT_ID, CLIENT_SECRET, DISCOVERY in public_tests:
|
|
25
|
+
client = OIDCClient(discovery_endpoint=DISCOVERY, client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
|
|
26
|
+
await client.init()
|
|
27
|
+
auth_link = await client.authorization_code_flow_start(redirect_uri="http://127.0.0.1:9999")
|
|
28
|
+
print(auth_link)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if __name__ == "__main__":
|
|
32
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class _Settings(BaseSettings):
|
|
5
|
+
DEBUG: bool = False
|
|
6
|
+
|
|
7
|
+
ALLOW_HTTP: bool = False
|
|
8
|
+
"""This option violates the RFCs, but may be useful for debugging, and MUST NOT be enabled in production env"""
|
|
9
|
+
|
|
10
|
+
ALLOW_ALG_NONE: bool = False
|
|
11
|
+
"""This option violates the RFCs, but may be useful for debugging, and MUST NOT be enabled in production env"""
|
|
12
|
+
|
|
13
|
+
ALLOW_ALL_URLS: bool = False
|
|
14
|
+
"""This option is INSECURE, but may be useful for debugging, and MUST NOT be enabled in production env"""
|
|
15
|
+
|
|
16
|
+
model_config = SettingsConfigDict(
|
|
17
|
+
env_prefix="AOIDC_",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
settings = _Settings()
|
aoidc-0.0.1/aoidc/jwt.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# ruff: noqa: S105
|
|
2
|
+
from enum import StrEnum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class JsonWebAlgos(StrEnum):
|
|
6
|
+
"""
|
|
7
|
+
https://datatracker.ietf.org/doc/html/rfc7518#section-3.1
|
|
8
|
+
|
|
9
|
+
+ https://datatracker.ietf.org/doc/html/rfc9864#section-2.2
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
NONE = "none"
|
|
13
|
+
|
|
14
|
+
HS256 = "HS256"
|
|
15
|
+
HS384 = "HS384"
|
|
16
|
+
HS512 = "HS512"
|
|
17
|
+
|
|
18
|
+
RS256 = "RS256"
|
|
19
|
+
RS384 = "RS384"
|
|
20
|
+
RS512 = "RS512"
|
|
21
|
+
|
|
22
|
+
ES256 = "ES256"
|
|
23
|
+
ES256K = "ES256K"
|
|
24
|
+
|
|
25
|
+
ES384 = "ES384"
|
|
26
|
+
ES512 = "ES512"
|
|
27
|
+
|
|
28
|
+
PS256 = "PS256"
|
|
29
|
+
PS384 = "PS384"
|
|
30
|
+
PS512 = "PS512"
|
|
31
|
+
|
|
32
|
+
EDDSA = "EdDSA"
|
|
33
|
+
ED25519 = "Ed25519"
|
|
34
|
+
ED448 = "Ed448"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Helper module for passing validation context
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
|
|
7
|
+
from httpx import URL
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(init=True, frozen=True, slots=True)
|
|
11
|
+
class ValidationContext:
|
|
12
|
+
origin_url: URL
|
|
13
|
+
|
|
14
|
+
allowed_urls: list[URL] = field(default_factory=list)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# ruff: noqa: S105
|
|
2
|
+
from enum import StrEnum
|
|
3
|
+
from typing import Annotated, Any
|
|
4
|
+
|
|
5
|
+
from pydantic import BeforeValidator
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Taken from https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml as of 11.03.2025
|
|
9
|
+
|
|
10
|
+
Defined here, instead of RFCs, because of extending among many RFCs, and I don't want to define state for
|
|
11
|
+
each RFC
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ResponseType(StrEnum):
|
|
16
|
+
"""
|
|
17
|
+
https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#endpoint
|
|
18
|
+
|
|
19
|
+
Несмотря на то, что в стандарте написаны конкретные комбинации,
|
|
20
|
+
некоторые IdP (например, ory hydra) возвращает конструкции вида `token id_token` и `token id_token code`
|
|
21
|
+
Тогда как в стандарте написаны `token id_token code`
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
NONE = "none"
|
|
25
|
+
|
|
26
|
+
CODE = "code"
|
|
27
|
+
TOKEN = "token"
|
|
28
|
+
ID_TOKEN = "id_token"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def reconstruct_response_types(data: Any) -> set[tuple[ResponseType, ...]]:
|
|
32
|
+
if not isinstance(data, list) or any(not isinstance(i, str) for i in data):
|
|
33
|
+
raise ValueError("Invalid ResponseTypes input")
|
|
34
|
+
|
|
35
|
+
result: set[tuple[ResponseType, ...]] = set()
|
|
36
|
+
for entry in data:
|
|
37
|
+
responses: list[str] = entry.split(" ")
|
|
38
|
+
result_part = {ResponseType(i) for i in responses}
|
|
39
|
+
result.add(tuple(sorted(result_part)))
|
|
40
|
+
|
|
41
|
+
return result
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
ResponseTypes = Annotated[
|
|
45
|
+
set[tuple[ResponseType, ...]],
|
|
46
|
+
BeforeValidator(reconstruct_response_types, json_schema_input_type=list[str]),
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AccessTokenTypes(StrEnum):
|
|
51
|
+
"""
|
|
52
|
+
https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-types
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
BEARER = "Bearer"
|
|
56
|
+
|
|
57
|
+
DPoP = "DPoP"
|
|
58
|
+
N_A = "N_A"
|
|
59
|
+
PoP = "PoP"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class TokenEndpointAuthMetod(StrEnum):
|
|
63
|
+
"""
|
|
64
|
+
https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
NONE = "none"
|
|
68
|
+
CLIENT_SECRET_POST = "client_secret_post"
|
|
69
|
+
CLIENT_SECRET_BASIC = "client_secret_basic"
|
|
70
|
+
|
|
71
|
+
CLIENT_SECRET_JWT = "client_secret_jwt"
|
|
72
|
+
PRIVATE_KEY_JWT = "private_key_jwt"
|
|
73
|
+
|
|
74
|
+
TLS_CLIENT_AUTH = "tls_client_auth"
|
|
75
|
+
SELF_SIGNED_TLS_CLIENT_AUTH = "self_signed_tls_client_auth"
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class CodeChallendeMethods(StrEnum):
|
|
79
|
+
"""
|
|
80
|
+
https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#pkce-code-challenge-method
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
PLAIN = "plain"
|
|
84
|
+
S256 = "S256"
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# ruff: noqa: S105
|
|
2
|
+
from enum import StrEnum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class GrantTypes(StrEnum):
|
|
6
|
+
AUTHORIZATION_CODE = "authorization_code"
|
|
7
|
+
IMPLICIT = "implicit"
|
|
8
|
+
|
|
9
|
+
PASSWORD = "password"
|
|
10
|
+
CLIENT_CREDENTIALS = "client_credentials"
|
|
11
|
+
|
|
12
|
+
REFRESH_TOKEN = "refresh_token"
|
|
13
|
+
|
|
14
|
+
JWT_BEARER = "urn:ietf:params:oauth:grant-type:jwt-bearer"
|
|
15
|
+
SAML2_BEARER = "urn:ietf:params:oauth:grant-type:saml2-bearer"
|
|
16
|
+
DEVICE_CODE = "urn:ietf:params:oauth:grant-type:device_code"
|
|
File without changes
|
|
File without changes
|