jwt-toolkit 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.
- jwt_toolkit-0.1.0/.editorconfig +18 -0
- jwt_toolkit-0.1.0/.github/dependabot.yml +25 -0
- jwt_toolkit-0.1.0/.github/workflows/ci.yml +75 -0
- jwt_toolkit-0.1.0/.github/workflows/publish.yml +47 -0
- jwt_toolkit-0.1.0/.gitignore +224 -0
- jwt_toolkit-0.1.0/.pre-commit-config.yaml +40 -0
- jwt_toolkit-0.1.0/.python-version +1 -0
- jwt_toolkit-0.1.0/LICENSE +21 -0
- jwt_toolkit-0.1.0/Makefile +48 -0
- jwt_toolkit-0.1.0/PKG-INFO +116 -0
- jwt_toolkit-0.1.0/README.md +85 -0
- jwt_toolkit-0.1.0/jwt_toolkit/__init__.py +0 -0
- jwt_toolkit-0.1.0/jwt_toolkit/cli/__init__.py +110 -0
- jwt_toolkit-0.1.0/jwt_toolkit/cli/algorithms.py +66 -0
- jwt_toolkit-0.1.0/jwt_toolkit/cli/banner.py +277 -0
- jwt_toolkit-0.1.0/jwt_toolkit/cli/console.py +35 -0
- jwt_toolkit-0.1.0/jwt_toolkit/cli/decoding.py +83 -0
- jwt_toolkit-0.1.0/jwt_toolkit/cli/panels.py +28 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/__init__.py +0 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/audit.py +269 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/crack.py +322 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/decode.py +54 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/download_wordlists.py +216 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/forge.py +133 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/generate_secret.py +72 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/sign.py +146 -0
- jwt_toolkit-0.1.0/jwt_toolkit/commands/verify.py +290 -0
- jwt_toolkit-0.1.0/jwt_toolkit/core/__init__.py +0 -0
- jwt_toolkit-0.1.0/jwt_toolkit/core/auditor.py +602 -0
- jwt_toolkit-0.1.0/jwt_toolkit/core/crypto.py +229 -0
- jwt_toolkit-0.1.0/jwt_toolkit/core/decoder.py +70 -0
- jwt_toolkit-0.1.0/jwt_toolkit/core/encoding.py +22 -0
- jwt_toolkit-0.1.0/jwt_toolkit/core/errors.py +25 -0
- jwt_toolkit-0.1.0/jwt_toolkit/core/forge.py +260 -0
- jwt_toolkit-0.1.0/jwt_toolkit/core/jwks.py +197 -0
- jwt_toolkit-0.1.0/pyproject.toml +173 -0
- jwt_toolkit-0.1.0/tests/__init__.py +0 -0
- jwt_toolkit-0.1.0/tests/conftest.py +137 -0
- jwt_toolkit-0.1.0/tests/helpers.py +46 -0
- jwt_toolkit-0.1.0/tests/test_auditor.py +397 -0
- jwt_toolkit-0.1.0/tests/test_cmd_audit.py +153 -0
- jwt_toolkit-0.1.0/tests/test_cmd_crack.py +146 -0
- jwt_toolkit-0.1.0/tests/test_cmd_decode.py +69 -0
- jwt_toolkit-0.1.0/tests/test_cmd_download_wordlists.py +89 -0
- jwt_toolkit-0.1.0/tests/test_cmd_forge.py +112 -0
- jwt_toolkit-0.1.0/tests/test_cmd_generate_secret.py +84 -0
- jwt_toolkit-0.1.0/tests/test_cmd_sign.py +180 -0
- jwt_toolkit-0.1.0/tests/test_cmd_verify.py +337 -0
- jwt_toolkit-0.1.0/tests/test_crypto.py +51 -0
- jwt_toolkit-0.1.0/tests/test_crypto_asymmetric.py +131 -0
- jwt_toolkit-0.1.0/tests/test_decoder.py +65 -0
- jwt_toolkit-0.1.0/tests/test_forge.py +199 -0
- jwt_toolkit-0.1.0/tests/test_jwks.py +223 -0
- jwt_toolkit-0.1.0/uv.lock +1062 -0
- jwt_toolkit-0.1.0/wordlists/common-secrets.txt +313 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
insert_final_newline = true
|
|
7
|
+
trim_trailing_whitespace = true
|
|
8
|
+
indent_style = space
|
|
9
|
+
indent_size = 4
|
|
10
|
+
|
|
11
|
+
[*.{yml,yaml,toml,json}]
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
[*.md]
|
|
15
|
+
trim_trailing_whitespace = false
|
|
16
|
+
|
|
17
|
+
[Makefile]
|
|
18
|
+
indent_style = tab
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# All Python dependencies (runtime + dev) bundled into a single weekly PR.
|
|
4
|
+
# Major versions are split out so they get a deliberate review instead of silently riding along with patch bumps.
|
|
5
|
+
- package-ecosystem: "uv"
|
|
6
|
+
directory: "/"
|
|
7
|
+
schedule:
|
|
8
|
+
interval: "weekly"
|
|
9
|
+
day: "monday"
|
|
10
|
+
open-pull-requests-limit: 1
|
|
11
|
+
groups:
|
|
12
|
+
python:
|
|
13
|
+
patterns: ["*"]
|
|
14
|
+
update-types: ["minor", "patch"]
|
|
15
|
+
|
|
16
|
+
# GitHub Actions pin updates bundled into a single weekly PR.
|
|
17
|
+
- package-ecosystem: "github-actions"
|
|
18
|
+
directory: "/"
|
|
19
|
+
schedule:
|
|
20
|
+
interval: "weekly"
|
|
21
|
+
day: "monday"
|
|
22
|
+
open-pull-requests-limit: 1
|
|
23
|
+
groups:
|
|
24
|
+
github-actions:
|
|
25
|
+
patterns: ["*"]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint:
|
|
14
|
+
name: Lint & format
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
- uses: astral-sh/setup-uv@v7
|
|
19
|
+
with:
|
|
20
|
+
enable-cache: true
|
|
21
|
+
- name: Install dev dependencies
|
|
22
|
+
run: uv sync --group dev
|
|
23
|
+
- name: Ruff format (check only)
|
|
24
|
+
run: uv run ruff format --check .
|
|
25
|
+
- name: Ruff lint
|
|
26
|
+
run: uv run ruff check .
|
|
27
|
+
|
|
28
|
+
typecheck:
|
|
29
|
+
name: Type check
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v6
|
|
33
|
+
- uses: astral-sh/setup-uv@v7
|
|
34
|
+
with:
|
|
35
|
+
enable-cache: true
|
|
36
|
+
- run: uv sync --group dev
|
|
37
|
+
- run: uv run mypy
|
|
38
|
+
|
|
39
|
+
security:
|
|
40
|
+
name: Security scan
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v6
|
|
44
|
+
- uses: astral-sh/setup-uv@v7
|
|
45
|
+
with:
|
|
46
|
+
enable-cache: true
|
|
47
|
+
- run: uv sync --group dev
|
|
48
|
+
- name: Bandit static analysis
|
|
49
|
+
run: uv run bandit -c pyproject.toml -r jwt_toolkit --severity-level medium
|
|
50
|
+
- name: pip-audit dependency CVEs
|
|
51
|
+
run: uv run pip-audit
|
|
52
|
+
|
|
53
|
+
test:
|
|
54
|
+
name: Tests (Python ${{ matrix.python-version }})
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
strategy:
|
|
57
|
+
fail-fast: false
|
|
58
|
+
matrix:
|
|
59
|
+
python-version: ["3.13"]
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v6
|
|
62
|
+
- uses: astral-sh/setup-uv@v7
|
|
63
|
+
with:
|
|
64
|
+
enable-cache: true
|
|
65
|
+
python-version: ${{ matrix.python-version }}
|
|
66
|
+
- run: uv sync --group dev
|
|
67
|
+
- name: Run tests with coverage
|
|
68
|
+
run: uv run pytest --cov --cov-report=term-missing --cov-report=xml -n auto
|
|
69
|
+
- name: Upload coverage artifact
|
|
70
|
+
if: always()
|
|
71
|
+
uses: actions/upload-artifact@v7
|
|
72
|
+
with:
|
|
73
|
+
name: coverage-${{ matrix.python-version }}
|
|
74
|
+
path: coverage.xml
|
|
75
|
+
if-no-files-found: ignore
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: publish-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: false
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
name: Build distribution
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
- uses: astral-sh/setup-uv@v7
|
|
19
|
+
with:
|
|
20
|
+
enable-cache: true
|
|
21
|
+
- name: Build sdist + wheel
|
|
22
|
+
run: uv build
|
|
23
|
+
- name: Check package metadata
|
|
24
|
+
run: uvx twine check --strict dist/*
|
|
25
|
+
- name: Upload build artifacts
|
|
26
|
+
uses: actions/upload-artifact@v7
|
|
27
|
+
with:
|
|
28
|
+
name: dist
|
|
29
|
+
path: dist/
|
|
30
|
+
|
|
31
|
+
publish:
|
|
32
|
+
name: Publish to PyPI
|
|
33
|
+
needs: build
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
environment:
|
|
36
|
+
name: pypi
|
|
37
|
+
url: https://pypi.org/p/jwt-toolkit
|
|
38
|
+
permissions:
|
|
39
|
+
id-token: write
|
|
40
|
+
steps:
|
|
41
|
+
- name: Download build artifacts
|
|
42
|
+
uses: actions/download-artifact@v7
|
|
43
|
+
with:
|
|
44
|
+
name: dist
|
|
45
|
+
path: dist/
|
|
46
|
+
- name: Publish to PyPI (Trusted Publishing)
|
|
47
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
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
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
|
|
220
|
+
# MacOS
|
|
221
|
+
.DS_Store
|
|
222
|
+
|
|
223
|
+
# Code editor
|
|
224
|
+
.vscode/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Pre-commit hooks — run automatically on `git commit`.
|
|
2
|
+
# Install once per clone: uv run pre-commit install
|
|
3
|
+
# Run manually on all files: uv run pre-commit run --all-files
|
|
4
|
+
#
|
|
5
|
+
# Hooks are pinned by rev for reproducibility. Bump with:
|
|
6
|
+
# uv run pre-commit autoupdate
|
|
7
|
+
|
|
8
|
+
repos:
|
|
9
|
+
# General hygiene
|
|
10
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
11
|
+
rev: v5.0.0
|
|
12
|
+
hooks:
|
|
13
|
+
- id: trailing-whitespace
|
|
14
|
+
- id: end-of-file-fixer
|
|
15
|
+
- id: check-yaml
|
|
16
|
+
- id: check-toml
|
|
17
|
+
- id: check-merge-conflict
|
|
18
|
+
- id: check-added-large-files
|
|
19
|
+
args: ["--maxkb=500"]
|
|
20
|
+
|
|
21
|
+
# Ruff — formatter + linter (replaces black, flake8, isort).
|
|
22
|
+
# Order matters: format first, then lint so the linter sees formatted code.
|
|
23
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
24
|
+
rev: v0.15.14
|
|
25
|
+
hooks:
|
|
26
|
+
- id: ruff-format
|
|
27
|
+
- id: ruff
|
|
28
|
+
args: ["--fix"]
|
|
29
|
+
|
|
30
|
+
# Bandit static security scan. Source-only, no network — safe to run on commit.
|
|
31
|
+
- repo: https://github.com/PyCQA/bandit
|
|
32
|
+
rev: 1.8.6
|
|
33
|
+
hooks:
|
|
34
|
+
- id: bandit
|
|
35
|
+
args: ["-c", "pyproject.toml", "--severity-level", "medium"]
|
|
36
|
+
additional_dependencies: ["bandit[toml]"]
|
|
37
|
+
files: ^jwt_toolkit/
|
|
38
|
+
|
|
39
|
+
# Mypy and pip-audit run in CI rather than pre-commit:
|
|
40
|
+
# mypy is slow on cold cache, pip-audit needs network.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Khaled Saeed
|
|
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.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# jwt-toolkit dev commands. Run `make` or `make help` for the list.
|
|
2
|
+
|
|
3
|
+
.DEFAULT_GOAL := help
|
|
4
|
+
.PHONY: help install fmt lint typecheck test test-fast cov security audit check pre-commit clean
|
|
5
|
+
|
|
6
|
+
UV ?= uv
|
|
7
|
+
|
|
8
|
+
help: ## Show this help.
|
|
9
|
+
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*##/ {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
10
|
+
|
|
11
|
+
install: ## Sync dev dependencies and install pre-commit hook.
|
|
12
|
+
$(UV) sync --group dev
|
|
13
|
+
$(UV) run pre-commit install
|
|
14
|
+
|
|
15
|
+
fmt: ## Auto-format code with ruff.
|
|
16
|
+
$(UV) run ruff format .
|
|
17
|
+
$(UV) run ruff check . --fix
|
|
18
|
+
|
|
19
|
+
lint: ## Lint without modifying files.
|
|
20
|
+
$(UV) run ruff format --check .
|
|
21
|
+
$(UV) run ruff check .
|
|
22
|
+
|
|
23
|
+
typecheck: ## Run mypy.
|
|
24
|
+
$(UV) run mypy
|
|
25
|
+
|
|
26
|
+
test: ## Run the full test suite with coverage in parallel.
|
|
27
|
+
$(UV) run pytest --cov -n auto
|
|
28
|
+
|
|
29
|
+
test-fast: ## Run tests without coverage, parallel.
|
|
30
|
+
$(UV) run pytest -n auto
|
|
31
|
+
|
|
32
|
+
cov: ## Test suite with coverage report on stdout.
|
|
33
|
+
$(UV) run pytest --cov --cov-report=term-missing
|
|
34
|
+
|
|
35
|
+
security: ## Static security scan of the source.
|
|
36
|
+
$(UV) run bandit -c pyproject.toml -r jwt_toolkit --severity-level medium
|
|
37
|
+
|
|
38
|
+
audit: ## Check dependencies for known CVEs.
|
|
39
|
+
$(UV) run pip-audit
|
|
40
|
+
|
|
41
|
+
check: lint typecheck test security audit ## Full local CI gate.
|
|
42
|
+
|
|
43
|
+
pre-commit: ## Run all pre-commit hooks on every file.
|
|
44
|
+
$(UV) run pre-commit run --all-files
|
|
45
|
+
|
|
46
|
+
clean: ## Remove caches and build artifacts.
|
|
47
|
+
rm -rf .pytest_cache .ruff_cache .mypy_cache .coverage coverage.xml htmlcov dist build
|
|
48
|
+
find . -type d -name __pycache__ -prune -exec rm -rf {} +
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jwt-toolkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A command-line toolkit for inspecting, verifying, cracking, and securing JSON Web Tokens. built to expose how JWT signing works and where it breaks.
|
|
5
|
+
Project-URL: Homepage, https://github.com/KhaledSaeed18/jwt-toolkit
|
|
6
|
+
Project-URL: Repository, https://github.com/KhaledSaeed18/jwt-toolkit
|
|
7
|
+
Project-URL: Issues, https://github.com/KhaledSaeed18/jwt-toolkit/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/KhaledSaeed18/jwt-toolkit/releases
|
|
9
|
+
Author-email: Khaled Saeed <khaled18saeed@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: appsec,audit,cli,cryptography,json-web-token,jwt,pentesting,security
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Information Technology
|
|
17
|
+
Classifier: Intended Audience :: System Administrators
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Topic :: Security :: Cryptography
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.13
|
|
26
|
+
Requires-Dist: click>=8.4.1
|
|
27
|
+
Requires-Dist: cryptography>=48.0.0
|
|
28
|
+
Requires-Dist: pyfiglet>=1.0.2
|
|
29
|
+
Requires-Dist: rich>=15.0.0
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# JWT Toolkit
|
|
33
|
+
|
|
34
|
+
A command-line toolkit for inspecting, verifying, cracking, and securing JSON Web Tokens — built to expose how JWT signing works and where it breaks.
|
|
35
|
+
|
|
36
|
+
Use it to audit tokens for misconfigurations, verify signatures and standard claims (including JWKS), brute-force weak HMAC secrets against a wordlist, forge defensive attack-shaped variants for self-audit, and generate cryptographically strong secrets.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
`jwt-toolkit` is a command-line tool, so the recommended way to install it is with [pipx](https://pipx.pypa.io), which installs CLI tools into isolated environments:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pipx install jwt-toolkit
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or with pip / uv:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install jwt-toolkit
|
|
50
|
+
# or
|
|
51
|
+
uv tool install jwt-toolkit
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Requires Python 3.13+.
|
|
55
|
+
|
|
56
|
+
## Quick start
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Decode and pretty-print a token
|
|
60
|
+
jwt-toolkit decode <token>
|
|
61
|
+
|
|
62
|
+
# Static security audit (no key needed) — flags alg=none, weak HMAC, jwk-in-header, etc.
|
|
63
|
+
jwt-toolkit audit <token>
|
|
64
|
+
jwt-toolkit audit <token> --strict --json
|
|
65
|
+
|
|
66
|
+
# Verify signature + standard claims (exp, nbf, iat, iss, aud)
|
|
67
|
+
jwt-toolkit verify <token> --secret <secret> --issuer auth.example.com
|
|
68
|
+
jwt-toolkit verify <token> --jwks-url https://auth.example.com/.well-known/jwks.json
|
|
69
|
+
|
|
70
|
+
# Mint a JWT (HMAC or asymmetric)
|
|
71
|
+
jwt-toolkit sign --payload '{"sub":"1"}' --secret mysecret
|
|
72
|
+
|
|
73
|
+
# Generate defensive attack-shaped variants of a token (alg=none, alg confusion, etc.)
|
|
74
|
+
jwt-toolkit forge <token> --public-key key.pub.pem
|
|
75
|
+
|
|
76
|
+
# Brute-force a weak HMAC secret against a wordlist
|
|
77
|
+
jwt-toolkit crack <token> wordlists/common-secrets.txt --threads 8
|
|
78
|
+
|
|
79
|
+
# Generate a strong random secret
|
|
80
|
+
jwt-toolkit generate-secret --bits 256 --encoding base64
|
|
81
|
+
|
|
82
|
+
# Fetch the bundled common-secrets wordlist
|
|
83
|
+
jwt-toolkit download-wordlists --output-dir wordlists
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Run `jwt-toolkit COMMAND --help` for command-specific options.
|
|
87
|
+
|
|
88
|
+
## Commands
|
|
89
|
+
|
|
90
|
+
| Command | Purpose |
|
|
91
|
+
| -------------------- | ------------------------------------------------------------------------------- |
|
|
92
|
+
| `decode` | Decode a JWT and pretty-print its header and payload. |
|
|
93
|
+
| `sign` | Mint a new JWT signed with an HMAC secret or an asymmetric key. |
|
|
94
|
+
| `audit` | Static security analysis of a JWT — no key required. CVE-referenced findings. |
|
|
95
|
+
| `verify` | Verify the signature and standard claims of a JWT (supports JWKS). |
|
|
96
|
+
| `forge` | Emit defensive attack-shaped variants of a JWT for self-audit. |
|
|
97
|
+
| `crack` | Brute-force a weak HMAC secret using a wordlist. |
|
|
98
|
+
| `generate-secret` | Emit a cryptographically strong random secret. |
|
|
99
|
+
| `download-wordlists` | Fetch the latest common-secrets wordlist. |
|
|
100
|
+
|
|
101
|
+
## Scripting
|
|
102
|
+
|
|
103
|
+
Suppress the banner and color output for clean machine-readable runs:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
jwt-toolkit --quiet audit <token> --json
|
|
107
|
+
JWT_TOOLKIT_QUIET=1 NO_COLOR=1 jwt-toolkit audit <token> --json
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Use responsibly
|
|
111
|
+
|
|
112
|
+
`jwt-toolkit` is built for defensive work — auditing your own tokens, hardening your own systems, and learning how JWTs break. Only use it against tokens and systems you are authorized to test.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
[MIT](./LICENSE) © Khaled Saeed
|