keycloak-sdk 0.1.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.
- keycloak_sdk-0.1.0/.gitignore +91 -0
- keycloak_sdk-0.1.0/LICENSE +201 -0
- keycloak_sdk-0.1.0/PKG-INFO +121 -0
- keycloak_sdk-0.1.0/README.md +92 -0
- keycloak_sdk-0.1.0/examples/async_quickstart.py +46 -0
- keycloak_sdk-0.1.0/examples/quickstart.py +39 -0
- keycloak_sdk-0.1.0/pyproject.toml +89 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/__init__.py +66 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/_internal/__init__.py +0 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/_internal/redirects.py +117 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/_internal/secrets.py +10 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/admin/__init__.py +88 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/admin/_translate.py +60 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/admin/clients.py +40 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/admin/groups.py +42 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/admin/realms.py +40 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/admin/roles.py +38 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/admin/users.py +39 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/__init__.py +7 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/admin/__init__.py +121 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/admin/_translate.py +28 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/admin/clients.py +40 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/admin/groups.py +39 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/admin/realms.py +36 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/admin/roles.py +36 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/admin/users.py +39 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/auth.py +260 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/aio/client.py +98 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/auth.py +290 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/client.py +94 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/config.py +47 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/exceptions.py +65 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/jwt.py +109 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/oidc.py +30 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/py.typed +0 -0
- keycloak_sdk-0.1.0/src/keycloak_sdk/tokens.py +68 -0
- keycloak_sdk-0.1.0/tests/__init__.py +0 -0
- keycloak_sdk-0.1.0/tests/integration/__init__.py +0 -0
- keycloak_sdk-0.1.0/tests/integration/conftest.py +27 -0
- keycloak_sdk-0.1.0/tests/integration/it-realm-realm.json +66 -0
- keycloak_sdk-0.1.0/tests/integration/test_admin_async_it.py +78 -0
- keycloak_sdk-0.1.0/tests/integration/test_admin_it.py +68 -0
- keycloak_sdk-0.1.0/tests/integration/test_auth_async_it.py +45 -0
- keycloak_sdk-0.1.0/tests/integration/test_auth_it.py +42 -0
- keycloak_sdk-0.1.0/tests/integration/test_smoke_it.py +12 -0
- keycloak_sdk-0.1.0/tests/unit/__init__.py +0 -0
- keycloak_sdk-0.1.0/tests/unit/aio/__init__.py +0 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_admin_client.py +181 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_admin_translate.py +91 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_auth.py +506 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_client.py +121 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_clients.py +107 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_groups.py +107 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_realms.py +98 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_redirects_async.py +62 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_roles.py +108 -0
- keycloak_sdk-0.1.0/tests/unit/aio/test_users.py +108 -0
- keycloak_sdk-0.1.0/tests/unit/conftest.py +118 -0
- keycloak_sdk-0.1.0/tests/unit/test_admin_client.py +89 -0
- keycloak_sdk-0.1.0/tests/unit/test_admin_translate.py +111 -0
- keycloak_sdk-0.1.0/tests/unit/test_auth.py +714 -0
- keycloak_sdk-0.1.0/tests/unit/test_client.py +167 -0
- keycloak_sdk-0.1.0/tests/unit/test_clients.py +105 -0
- keycloak_sdk-0.1.0/tests/unit/test_config.py +52 -0
- keycloak_sdk-0.1.0/tests/unit/test_exceptions.py +55 -0
- keycloak_sdk-0.1.0/tests/unit/test_groups.py +105 -0
- keycloak_sdk-0.1.0/tests/unit/test_jwt.py +326 -0
- keycloak_sdk-0.1.0/tests/unit/test_oidc.py +19 -0
- keycloak_sdk-0.1.0/tests/unit/test_realms.py +100 -0
- keycloak_sdk-0.1.0/tests/unit/test_redirects.py +270 -0
- keycloak_sdk-0.1.0/tests/unit/test_roles.py +104 -0
- keycloak_sdk-0.1.0/tests/unit/test_secrets.py +15 -0
- keycloak_sdk-0.1.0/tests/unit/test_smoke.py +20 -0
- keycloak_sdk-0.1.0/tests/unit/test_tokens.py +26 -0
- keycloak_sdk-0.1.0/tests/unit/test_users.py +105 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# ── Java / Maven ──────────────────────────────────────────────
|
|
2
|
+
target/
|
|
3
|
+
*.class
|
|
4
|
+
*.jar
|
|
5
|
+
*.war
|
|
6
|
+
*.ear
|
|
7
|
+
!.mvn/wrapper/maven-wrapper.jar
|
|
8
|
+
dependency-reduced-pom.xml
|
|
9
|
+
.mvn/timing.properties
|
|
10
|
+
.mvn/wrapper/maven-wrapper.properties
|
|
11
|
+
|
|
12
|
+
# ── IDE ───────────────────────────────────────────────────────
|
|
13
|
+
.idea/
|
|
14
|
+
*.iml
|
|
15
|
+
*.ipr
|
|
16
|
+
*.iws
|
|
17
|
+
.vscode/
|
|
18
|
+
.settings/
|
|
19
|
+
.project
|
|
20
|
+
.classpath
|
|
21
|
+
*.code-workspace
|
|
22
|
+
|
|
23
|
+
# ── OS ────────────────────────────────────────────────────────
|
|
24
|
+
.DS_Store
|
|
25
|
+
Thumbs.db
|
|
26
|
+
|
|
27
|
+
# ── Secrets / credentials (절대 커밋 금지) ────────────────────
|
|
28
|
+
*.gpg
|
|
29
|
+
*.asc
|
|
30
|
+
secring.*
|
|
31
|
+
.env
|
|
32
|
+
.env.*
|
|
33
|
+
settings-security.xml
|
|
34
|
+
.scamanager/token # SCAManager 인증 토큰 — 로컬 전용(mode 600), 환경변수 SCAMANAGER_TOKEN 대안
|
|
35
|
+
|
|
36
|
+
# ── SDD 진척 원장 (로컬 스크래치) ─────────────────────────────
|
|
37
|
+
.superpowers/
|
|
38
|
+
|
|
39
|
+
# ── Python (향후 SDK) ─────────────────────────────────────────
|
|
40
|
+
__pycache__/
|
|
41
|
+
*.py[cod]
|
|
42
|
+
.venv/
|
|
43
|
+
venv/
|
|
44
|
+
dist/
|
|
45
|
+
build/
|
|
46
|
+
*.egg-info/
|
|
47
|
+
.coverage
|
|
48
|
+
htmlcov/
|
|
49
|
+
.ruff_cache/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
|
|
52
|
+
# ── Node.js / TypeScript ──────────────────────────────────────
|
|
53
|
+
node_modules/
|
|
54
|
+
.vite/
|
|
55
|
+
coverage/
|
|
56
|
+
*.tsbuildinfo
|
|
57
|
+
cover.out
|
|
58
|
+
cover.logic.out
|
|
59
|
+
# rust — `cargo llvm-cov --lcov`가 SonarCloud에 먹일 리포트를 여기에 쓴다(CI가 매 실행마다 생성).
|
|
60
|
+
lcov.info
|
|
61
|
+
|
|
62
|
+
# ── Gradle / Kotlin (빌드 스크래치) ───────────────────────────
|
|
63
|
+
# kotlin/.gitignore가 SDK 모듈은 이미 덮지만, Gradle 스크래치는 build.gradle.kts가
|
|
64
|
+
# 있는 **아무 디렉터리에서나** 생긴다 — scripts/test/fixtures/doc-guard/src(가드
|
|
65
|
+
# 테스트용 가짜 빌드파일)에서 실제로 .gradle/이 생겨 커밋될 뻔했다. 루트에서 막는다.
|
|
66
|
+
.gradle/
|
|
67
|
+
.kotlin/
|
|
68
|
+
|
|
69
|
+
# SCAManager 개인 코드리뷰 도구 — 공개 저장소에 포함하지 않는다(개인 저장소/전역 git 템플릿으로 관리)
|
|
70
|
+
.scamanager/
|
|
71
|
+
|
|
72
|
+
# coverlet(.NET)이 테스트 실행 때마다 테스트 프로젝트 옆에 떨어뜨리는 커버리지 산출물.
|
|
73
|
+
# ⚠️ 절대경로가 박혀 있어 커밋되면 개인 머신 경로가 공개 이력에 남는다(실제로 한 번 유입됨 —
|
|
74
|
+
# 742a01b의 coverage.json에 `F:\DEVELOPMENT\...` 경로가 그대로 들어갔다).
|
|
75
|
+
# ⚠️ 출력 파일명은 `/p:CoverletOutputFormat`이 정한다. 오래 `coverage.json`(기본 json 형식)만
|
|
76
|
+
# 막아뒀는데 dotnet-ci와 harness가 실제로 쓰는 형식은 **cobertura**라, 로컬에서 CI와 같은 명령을
|
|
77
|
+
# 돌리면 무시되지 않는 `coverage.cobertura.xml`이 남았다(실제로 남는 것을 확인). 한 형식만 막으면
|
|
78
|
+
# 나머지가 새므로 coverlet이 내는 형식을 전부 막는다.
|
|
79
|
+
coverage.json
|
|
80
|
+
coverage.cobertura.xml
|
|
81
|
+
coverage.opencover.xml
|
|
82
|
+
coverage.info
|
|
83
|
+
# ⚠️ 단, 커버리지 가드의 테스트 픽스처는 산출물이 아니라 **소스**다. 위 규칙들은 파일명만 보므로
|
|
84
|
+
# `coverage.cobertura.xml` 픽스처를, 그리고 위쪽 `coverage/` 규칙은 디렉터리째 삼킨다 — 그러면
|
|
85
|
+
# 로컬에서는 테스트가 통과하는데 CI에서는 픽스처가 없어 깨진다(실제로 커밋 직전에 걸렸다).
|
|
86
|
+
# ⚠️ 예외는 이 디렉터리로만 좁힌다. `!scripts/test/fixtures/**`처럼 넓게 열면 doc-guard 픽스처
|
|
87
|
+
# 아래 실제 빌드 산출물(.gradle 잠금·바이너리 캐시)까지 추적된다(이것도 실제로 걸렸다).
|
|
88
|
+
!scripts/test/fixtures/coverage-gate/**
|
|
89
|
+
|
|
90
|
+
# Playwright MCP 브라우저 세션 산출물(스냅샷·콘솔 로그) — 진단용 임시 파일이다.
|
|
91
|
+
.playwright-mcp/
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 xzawed
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: keycloak-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Keycloak SDK for Python — auth (OIDC/OAuth2) + Admin REST API, wrapping python-keycloak
|
|
5
|
+
Project-URL: Homepage, https://github.com/xzawed/KeyCloakSDK/tree/main/python
|
|
6
|
+
Project-URL: Repository, https://github.com/xzawed/KeyCloakSDK
|
|
7
|
+
Project-URL: Issues, https://github.com/xzawed/KeyCloakSDK/issues
|
|
8
|
+
Author-email: xzawed <xzawed31@gmail.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: admin,keycloak,oauth2,oidc,sso
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: joserfc<2,>=1.7
|
|
20
|
+
Requires-Dist: python-keycloak<8,>=7.1
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: mypy>=2.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=9.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
27
|
+
Requires-Dist: testcontainers[keycloak]>=4.14; extra == 'dev'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# Keycloak SDK for Python
|
|
31
|
+
|
|
32
|
+
Authentication (OIDC / OAuth2) and the Admin REST API for [Keycloak](https://www.keycloak.org/) behind one consistent facade, with hardened JWT validation and a full async mirror.
|
|
33
|
+
|
|
34
|
+
Part of a **nine-language polyglot SDK** (Java · Python · Node · Go · C# · PHP · Rust · Ruby · Kotlin) — one API surface, isomorphic across all of them: [github.com/xzawed/KeyCloakSDK](https://github.com/xzawed/KeyCloakSDK).
|
|
35
|
+
|
|
36
|
+
> **Pre-release** — the first release candidate (`0.1.0rc1`) is on PyPI; there is no stable release yet. Note that a bare `pip install keycloak-sdk` currently resolves this RC, because pip falls back to pre-releases when only pre-releases exist.
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
- Python **3.10+**
|
|
41
|
+
- Ships the PEP 561 `py.typed` marker, so consumers can type-check with `mypy` too
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install keycloak-sdk
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The distribution name is `keycloak-sdk`; the import package is `keycloak_sdk`.
|
|
50
|
+
|
|
51
|
+
## Quickstart
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from keycloak_sdk import KeycloakClient, KeycloakConfig
|
|
55
|
+
|
|
56
|
+
config = KeycloakConfig(
|
|
57
|
+
server_url="https://kc.example.com",
|
|
58
|
+
realm="myrealm",
|
|
59
|
+
client_id="admin-cli",
|
|
60
|
+
client_secret="changeme", # load the real value from an env var / secrets manager
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# The `with` block cleans up the admin and auth sessions on exit.
|
|
64
|
+
with KeycloakClient.create(config) as kc:
|
|
65
|
+
# 1) Issue a client-credentials token. repr(TokenSet) masks every token value.
|
|
66
|
+
token = kc.auth.client_credentials_token()
|
|
67
|
+
|
|
68
|
+
# 2) Validate it — algorithm pinning, exact iss, aud containment, mandatory exp, clock skew.
|
|
69
|
+
validated = kc.auth.validate(token.access_token)
|
|
70
|
+
print(f"subject={validated.subject} aud={validated.audience}")
|
|
71
|
+
|
|
72
|
+
# 3) Admin API — admin is created lazily on first access. create() returns the new user id.
|
|
73
|
+
user_id = kc.admin.users.create({"username": "alice", "enabled": True})
|
|
74
|
+
users = kc.admin.users.search(first=0, max=20)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`validate()` expects the token's `aud` to contain `client_id` by default, but a stock realm does not put the client id into a client-credentials token. Either set `expected_audience="my-api"` on the config to check the audience your tokens actually carry, or add an audience mapper to the client in Keycloak (Client scopes → dedicated scope → Add mapper → Audience).
|
|
78
|
+
|
|
79
|
+
### Async
|
|
80
|
+
|
|
81
|
+
`keycloak_sdk.aio` is a complete async mirror — same method names, value types, and exceptions — so it never blocks the event loop (FastAPI and friends):
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from keycloak_sdk import KeycloakConfig
|
|
85
|
+
from keycloak_sdk.aio import AsyncKeycloakClient
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
async def handler(config: KeycloakConfig) -> None:
|
|
89
|
+
async with AsyncKeycloakClient.create(config) as kc:
|
|
90
|
+
token = await kc.auth.client_credentials_token()
|
|
91
|
+
validated = await kc.auth.validate(token.access_token)
|
|
92
|
+
users = await kc.admin.users.search(first=0, max=20)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Only `authorization_url` stays synchronous — it assembles a URL and needs no network.
|
|
96
|
+
|
|
97
|
+
## Security defaults
|
|
98
|
+
|
|
99
|
+
The SDK replaces the unsafe library defaults rather than inheriting them:
|
|
100
|
+
|
|
101
|
+
- **Algorithm pinning** — the header-supplied `alg` is never trusted, so `alg: none` and HS/RS confusion are rejected structurally: joserfc decodes against the configured allowlist, and an empty allowlist is refused at construction rather than falling back to joserfc's permissive default set.
|
|
102
|
+
- **Strict claim checks** — exact `iss` match, `aud` containment, mandatory `exp`, `nbf`, and a bounded clock skew.
|
|
103
|
+
- **DoS-safe JWKS** — a refetch is triggered only by an unresolved key ID and never by a bad signature, and is rate-limited to a minimum interval (`jwks_min_refetch_seconds`, 30s by default) — so no volume of forged tokens makes the SDK issue more than one JWKS request per interval.
|
|
104
|
+
- **Secret handling** — `repr()` of the config and token types masks secrets and tokens as `***` (no prefix leak), and TLS verification is on by default.
|
|
105
|
+
|
|
106
|
+
Masking covers this SDK's own `repr()`; it cannot cover what your logging framework or a traceback does with a value you hand it. Python has no erasable string type, so the client secret lives in an ordinary `str` for its lifetime — masking is defence in depth, not an erasure guarantee.
|
|
107
|
+
|
|
108
|
+
## Versioning and support
|
|
109
|
+
|
|
110
|
+
This SDK is **pre-1.0**. Under SemVer a `0.x` **minor** bump may carry breaking changes, so read the release notes before upgrading. Only the newest released version of each language SDK receives security fixes — there are no LTS lines, and older `0.x` releases are not backported to. Full policy: [SECURITY.md](https://github.com/xzawed/KeyCloakSDK/blob/main/SECURITY.md).
|
|
111
|
+
|
|
112
|
+
## Documentation
|
|
113
|
+
|
|
114
|
+
- [Getting started](https://github.com/xzawed/KeyCloakSDK/blob/main/docs/guides/getting-started.md#python) — install, quickstart, async, and the compatibility matrix
|
|
115
|
+
- [Deploying a Keycloak server](https://github.com/xzawed/KeyCloakSDK/blob/main/docs/guides/deploying-keycloak-server.md) — the server this SDK talks to
|
|
116
|
+
- [Security policy](https://github.com/xzawed/KeyCloakSDK/blob/main/SECURITY.md)
|
|
117
|
+
- Full examples: [`quickstart.py`](https://github.com/xzawed/KeyCloakSDK/blob/main/python/examples/quickstart.py) · [`async_quickstart.py`](https://github.com/xzawed/KeyCloakSDK/blob/main/python/examples/async_quickstart.py)
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
[Apache-2.0](https://github.com/xzawed/KeyCloakSDK/blob/main/python/LICENSE)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Keycloak SDK for Python
|
|
2
|
+
|
|
3
|
+
Authentication (OIDC / OAuth2) and the Admin REST API for [Keycloak](https://www.keycloak.org/) behind one consistent facade, with hardened JWT validation and a full async mirror.
|
|
4
|
+
|
|
5
|
+
Part of a **nine-language polyglot SDK** (Java · Python · Node · Go · C# · PHP · Rust · Ruby · Kotlin) — one API surface, isomorphic across all of them: [github.com/xzawed/KeyCloakSDK](https://github.com/xzawed/KeyCloakSDK).
|
|
6
|
+
|
|
7
|
+
> **Pre-release** — the first release candidate (`0.1.0rc1`) is on PyPI; there is no stable release yet. Note that a bare `pip install keycloak-sdk` currently resolves this RC, because pip falls back to pre-releases when only pre-releases exist.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Python **3.10+**
|
|
12
|
+
- Ships the PEP 561 `py.typed` marker, so consumers can type-check with `mypy` too
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install keycloak-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The distribution name is `keycloak-sdk`; the import package is `keycloak_sdk`.
|
|
21
|
+
|
|
22
|
+
## Quickstart
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from keycloak_sdk import KeycloakClient, KeycloakConfig
|
|
26
|
+
|
|
27
|
+
config = KeycloakConfig(
|
|
28
|
+
server_url="https://kc.example.com",
|
|
29
|
+
realm="myrealm",
|
|
30
|
+
client_id="admin-cli",
|
|
31
|
+
client_secret="changeme", # load the real value from an env var / secrets manager
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# The `with` block cleans up the admin and auth sessions on exit.
|
|
35
|
+
with KeycloakClient.create(config) as kc:
|
|
36
|
+
# 1) Issue a client-credentials token. repr(TokenSet) masks every token value.
|
|
37
|
+
token = kc.auth.client_credentials_token()
|
|
38
|
+
|
|
39
|
+
# 2) Validate it — algorithm pinning, exact iss, aud containment, mandatory exp, clock skew.
|
|
40
|
+
validated = kc.auth.validate(token.access_token)
|
|
41
|
+
print(f"subject={validated.subject} aud={validated.audience}")
|
|
42
|
+
|
|
43
|
+
# 3) Admin API — admin is created lazily on first access. create() returns the new user id.
|
|
44
|
+
user_id = kc.admin.users.create({"username": "alice", "enabled": True})
|
|
45
|
+
users = kc.admin.users.search(first=0, max=20)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`validate()` expects the token's `aud` to contain `client_id` by default, but a stock realm does not put the client id into a client-credentials token. Either set `expected_audience="my-api"` on the config to check the audience your tokens actually carry, or add an audience mapper to the client in Keycloak (Client scopes → dedicated scope → Add mapper → Audience).
|
|
49
|
+
|
|
50
|
+
### Async
|
|
51
|
+
|
|
52
|
+
`keycloak_sdk.aio` is a complete async mirror — same method names, value types, and exceptions — so it never blocks the event loop (FastAPI and friends):
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from keycloak_sdk import KeycloakConfig
|
|
56
|
+
from keycloak_sdk.aio import AsyncKeycloakClient
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
async def handler(config: KeycloakConfig) -> None:
|
|
60
|
+
async with AsyncKeycloakClient.create(config) as kc:
|
|
61
|
+
token = await kc.auth.client_credentials_token()
|
|
62
|
+
validated = await kc.auth.validate(token.access_token)
|
|
63
|
+
users = await kc.admin.users.search(first=0, max=20)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Only `authorization_url` stays synchronous — it assembles a URL and needs no network.
|
|
67
|
+
|
|
68
|
+
## Security defaults
|
|
69
|
+
|
|
70
|
+
The SDK replaces the unsafe library defaults rather than inheriting them:
|
|
71
|
+
|
|
72
|
+
- **Algorithm pinning** — the header-supplied `alg` is never trusted, so `alg: none` and HS/RS confusion are rejected structurally: joserfc decodes against the configured allowlist, and an empty allowlist is refused at construction rather than falling back to joserfc's permissive default set.
|
|
73
|
+
- **Strict claim checks** — exact `iss` match, `aud` containment, mandatory `exp`, `nbf`, and a bounded clock skew.
|
|
74
|
+
- **DoS-safe JWKS** — a refetch is triggered only by an unresolved key ID and never by a bad signature, and is rate-limited to a minimum interval (`jwks_min_refetch_seconds`, 30s by default) — so no volume of forged tokens makes the SDK issue more than one JWKS request per interval.
|
|
75
|
+
- **Secret handling** — `repr()` of the config and token types masks secrets and tokens as `***` (no prefix leak), and TLS verification is on by default.
|
|
76
|
+
|
|
77
|
+
Masking covers this SDK's own `repr()`; it cannot cover what your logging framework or a traceback does with a value you hand it. Python has no erasable string type, so the client secret lives in an ordinary `str` for its lifetime — masking is defence in depth, not an erasure guarantee.
|
|
78
|
+
|
|
79
|
+
## Versioning and support
|
|
80
|
+
|
|
81
|
+
This SDK is **pre-1.0**. Under SemVer a `0.x` **minor** bump may carry breaking changes, so read the release notes before upgrading. Only the newest released version of each language SDK receives security fixes — there are no LTS lines, and older `0.x` releases are not backported to. Full policy: [SECURITY.md](https://github.com/xzawed/KeyCloakSDK/blob/main/SECURITY.md).
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
- [Getting started](https://github.com/xzawed/KeyCloakSDK/blob/main/docs/guides/getting-started.md#python) — install, quickstart, async, and the compatibility matrix
|
|
86
|
+
- [Deploying a Keycloak server](https://github.com/xzawed/KeyCloakSDK/blob/main/docs/guides/deploying-keycloak-server.md) — the server this SDK talks to
|
|
87
|
+
- [Security policy](https://github.com/xzawed/KeyCloakSDK/blob/main/SECURITY.md)
|
|
88
|
+
- Full examples: [`quickstart.py`](https://github.com/xzawed/KeyCloakSDK/blob/main/python/examples/quickstart.py) · [`async_quickstart.py`](https://github.com/xzawed/KeyCloakSDK/blob/main/python/examples/async_quickstart.py)
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
[Apache-2.0](https://github.com/xzawed/KeyCloakSDK/blob/main/python/LICENSE)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Async QuickStart — `keycloak-sdk`의 `keycloak_sdk.aio` 최소 사용 예제.
|
|
2
|
+
|
|
3
|
+
sync `examples/quickstart.py`의 async 미러다. FastAPI 같은 async 프레임워크
|
|
4
|
+
안에서 이벤트 루프를 블로킹하지 않고 Keycloak을 호출하고 싶을 때 이 경로를 쓴다.
|
|
5
|
+
|
|
6
|
+
이 파일은 정적으로 임포트/타입체크만 되는 것을 목표로 한다(실제 Keycloak 서버 없이도
|
|
7
|
+
`python -c "import ast; ast.parse(...)"`와 `mypy`가 통과해야 한다). 네트워크 호출이
|
|
8
|
+
필요한 로직은 `main()`에 있고 `if __name__ == "__main__":` 가드 뒤에서만 실행되므로,
|
|
9
|
+
모듈을 임포트하는 것만으로는 아무 요청도 나가지 않는다.
|
|
10
|
+
|
|
11
|
+
실행하려면 실제 Keycloak 서버 정보로 아래 `KeycloakConfig` 값을 채우고
|
|
12
|
+
`python examples/async_quickstart.py`를 실행한다(서비스 계정에 필요한 권한 role 필요).
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import asyncio
|
|
18
|
+
|
|
19
|
+
from keycloak_sdk import mask
|
|
20
|
+
from keycloak_sdk.aio import AsyncKeycloakClient
|
|
21
|
+
from keycloak_sdk.config import KeycloakConfig
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def main() -> None:
|
|
25
|
+
config = KeycloakConfig(
|
|
26
|
+
server_url="https://keycloak.example.com",
|
|
27
|
+
realm="my-realm",
|
|
28
|
+
client_id="my-client",
|
|
29
|
+
client_secret="my-client-secret", # 실제 값은 환경변수/시크릿 매니저에서 로드할 것
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# AsyncKeycloakClient.create()는 auth(AsyncAuthClient)를 즉시 조립한다. admin은
|
|
33
|
+
# 최초 `.admin` 접근 시 지연 생성된다(client_secret 필요 — client-credentials grant).
|
|
34
|
+
async with AsyncKeycloakClient.create(config) as kc:
|
|
35
|
+
# 1) client-credentials 토큰 발급 — 토큰 원문은 절대 로그에 남기지 않는다.
|
|
36
|
+
# `mask()`는 접두 노출 없이 "***"(값이 있을 때)만 돌려준다 — 존재 여부만 드러낸다.
|
|
37
|
+
token = await kc.auth.client_credentials_token()
|
|
38
|
+
print(f"access_token={mask(token.access_token)} token_type={token.token_type}")
|
|
39
|
+
|
|
40
|
+
# 2) 관리 API로 사용자 목록 조회(admin이 이 시점에 지연 생성된다).
|
|
41
|
+
users = await kc.admin.users.search(first=0, max=10)
|
|
42
|
+
print(f"users={[u.get('username') for u in users]}")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""QuickStart — `keycloak-sdk` 최소 사용 예제.
|
|
2
|
+
|
|
3
|
+
이 파일은 정적으로 임포트/타입체크만 되는 것을 목표로 한다(실제 Keycloak 서버 없이도
|
|
4
|
+
`python -c "import ast; ast.parse(...)"`와 `mypy`가 통과해야 한다). 네트워크 호출이
|
|
5
|
+
필요한 로직은 `main()`에 있고 `if __name__ == "__main__":` 가드 뒤에서만 실행되므로,
|
|
6
|
+
모듈을 임포트하는 것만으로는 아무 요청도 나가지 않는다.
|
|
7
|
+
|
|
8
|
+
실행하려면 실제 Keycloak 서버 정보로 아래 `KeycloakConfig` 값을 채우고
|
|
9
|
+
`python examples/quickstart.py`를 실행한다(서비스 계정에 필요한 권한 role 필요).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from keycloak_sdk import KeycloakClient, KeycloakConfig, mask
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main() -> None:
|
|
18
|
+
config = KeycloakConfig(
|
|
19
|
+
server_url="https://keycloak.example.com",
|
|
20
|
+
realm="my-realm",
|
|
21
|
+
client_id="my-client",
|
|
22
|
+
client_secret="my-client-secret", # 실제 값은 환경변수/시크릿 매니저에서 로드할 것
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# KeycloakClient.create()는 auth(AuthClient)를 즉시 조립한다. admin은 최초
|
|
26
|
+
# `.admin` 접근 시 지연 생성된다(client_secret 필요 — client-credentials grant).
|
|
27
|
+
with KeycloakClient.create(config) as kc:
|
|
28
|
+
# 1) client-credentials 토큰 발급 — 토큰 원문은 절대 로그에 남기지 않는다.
|
|
29
|
+
# `mask()`는 접두 노출 없이 "***"(값이 있을 때)만 돌려준다 — 존재 여부만 드러낸다.
|
|
30
|
+
token = kc.auth.client_credentials_token()
|
|
31
|
+
print(f"access_token={mask(token.access_token)} token_type={token.token_type}")
|
|
32
|
+
|
|
33
|
+
# 2) 관리 API로 사용자 목록 조회(admin이 이 시점에 지연 생성된다).
|
|
34
|
+
users = kc.admin.users.search(first=0, max=10)
|
|
35
|
+
print(f"users={[u.get('username') for u in users]}")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
main()
|