Skip to content

Commit 2dbdd31

Browse files
author
IndominusByte
committed
use flit to package management
1 parent 8b5ce6a commit 2dbdd31

File tree

13 files changed

+172
-44
lines changed

13 files changed

+172
-44
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var/
3030

3131
# coverage
3232
.coverage
33+
htmlcov/
3334

3435
# testing py
3536
test.py

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## 0.3.0
2+
* **(Deprecated)** environment variable support
3+
* Change name function **load_end()** -> **load_config()**
4+
* Change name function **get_jwt_identity()** -> **get_jwt_subject()**
5+
* Change name identity claims to standard claims sub *(Thanks to @rassie for suggestion)*
6+
* Additional headers in claims
7+
* Get additional headers claims from request or parsing token directly
8+
* Leeway exp claim decode token
9+
* Dynamic token expires time
10+
* Change name **blacklist** -> **denylist**
11+
* Denylist custom check refresh and access tokens
12+
* Issuer claim
13+
* Audience claim
14+
* Jwt decode algorithms
15+
* Dynamic algorithm create token
16+
* Token multiple location
17+
* Support RSA encryption *(Thanks to @jet10000 for make issues)*
18+
* Custom header name and type
19+
* Custom error message key and status code
20+
* JWT in cookies *(Thanks to @m4nuC for make issues)*
21+
* Add Additional claims
22+
* Add Documentation *(#9 by @paulussimanjuntak)*
23+
24+
## 0.2.0
25+
26+
* Call create_token and get_jti function must be from dependency injection
27+
* Improve blacklist loader
28+
* Can load env from pydantic
29+
* Add docs on readme how to use without dependency injection and example on multiple files
30+
* Fix raise jwt exception PR #1 by @ironslob
31+
32+
## 0.1.0
33+
34+
* Initial release.

docs/configuration/general.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Defaults to `None`
1616

1717
`authjwt_algorithm`
18-
: Which algorithm to sign the JWT with. <a href="https://pyjwt.readthedocs.io/en/latest/algorithms.html">See here</a>
18+
: Which algorithm to sign the JWT with. <a href="https://pyjwt.readthedocs.io/en/latest/algorithms.html" class="external-link">See here</a>
1919
for the options. Defaults to `HS256`
2020

2121
`authjwt_decode_algorithms`

docs/contributing.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## Sharing feedback
2+
3+
This project is still quite new and therefore having your feedback will really help to
4+
prioritize relevant feature developments :rocket:. If you want to contribute thankss a lot :smile:, you can
5+
open an <a href="https://github.com/IndominusByte/fastapi-jwt-auth/issues/new">issue</a> on Github.
6+
7+
## Developing
8+
9+
If you already cloned the repository and you know that you need to deep dive in the code, here are some guidelines to set up your environment.
10+
11+
## Docs
12+
13+
The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.
14+
15+
All the documentation is in Markdown format in the directory `./docs`.
16+
17+
Many of the sections in the User Guide have blocks of code.
18+
19+
In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./examples/` directory.
20+
21+
And those Python files are included/injected in the documentation when generating the site.
22+
23+
### Docs for tests
24+
25+
Most of the tests actually run against the example source files in the documentation.
26+
27+
This helps making sure that:
28+
29+
* The documentation is up to date.
30+
* The documentation examples can be run as is.
31+
* Most of the features are covered by the documentation, ensured by test coverage.
32+
33+
During local development, there is a script that builds the site and checks for any changes, live-reloading:
34+
35+
```bash
36+
$ bash scripts/docs-live.sh
37+
```
38+
39+
It will serve the documentation on `http://0.0.0.0:5000`.
40+
41+
That way, you can edit the documentation/source files and see the changes live.
42+
43+
## Tests
44+
45+
There is a script that you can run locally to test all the code and generate coverage reports in HTML:
46+
47+
```bash
48+
bash scripts/tests.sh
49+
```
50+
51+
This command generates a directory `./htmlcov/`, if you open the file `./htmlcov/index.html` in your browser, you can explore interactively the regions of code that are covered by the tests, and notice if there is any region missing.

docs/css/custom.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
a.external-link::after {
2+
/* \00A0 is a non-breaking space
3+
to make the mark be on the same line as the link
4+
*/
5+
content: "\00A0[↪]";
6+
}
7+
8+
a.internal-link::after {
9+
/* \00A0 is a non-breaking space
10+
to make the mark be on the same line as the link
11+
*/
12+
content: "\00A0↪";
13+
}

docs/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{!../CHANGELOG.md!}

docs/usage/jwt_in_cookies.md renamed to docs/usage/jwt-in-cookies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Now in order to access a protected endpoint, you will need to add a custom heade
2323

2424
To break this down, if an attacker attempts to perform a CSRF attack they will send the JWT *(via cookie)* to protected endpoint, but without the random string in the request headers, they won't be able to access the endpoint. They cannot access the random string unless they can run javascript on your website *likely via an XSS attack*, and if they are able to perform an XSS attack, they will not be able to steal the actual access and refresh JWT, as javascript is still not able to access those httponly cookies.
2525

26-
No system is secure. If an attacker can perform an XSS attack they can still access protected endpoints from people who visit your site. However, it is better than if they were able to steal the access and refresh tokens from local/session storage, and use them whenever they wanted.
26+
No system is safe. If an attacker can perform an XSS attack they can still access protected endpoints from people who visit your site. However, it is better than if they were able to steal the access and refresh tokens from local/session storage, and use them whenever they wanted.
2727

2828
Here is an example of using cookies with CSRF protection:
2929

fastapi_jwt_auth/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
from .auth_jwt import AuthJWT
1+
"""FastAPI extension that provides JWT Auth support (secure, easy to use and lightweight)"""
22

33
__version__ = "0.3.0"
4+
5+
from .auth_jwt import AuthJWT

mkdocs.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ markdown_extensions:
1515
permalink: true
1616
- pymdownx.highlight:
1717
linenums_style: pymdownx.inline
18+
- pymdownx.magiclink:
19+
user: IndominusByte
20+
repo: fastapi-jwt-auth
21+
repo_url_shorthand: true
22+
- pymdownx.emoji:
23+
emoji_index: !!python/name:pymdownx.emoji.twemoji
1824
- attr_list
1925
- def_list
2026
- admonition
@@ -30,10 +36,15 @@ nav:
3036
- Refresh Tokens: usage/refresh.md
3137
- Freshness Tokens: usage/freshness.md
3238
- Revoking Tokens: usage/revoking.md
33-
- JWT in Cookies: usage/jwt_in_cookies.md
39+
- JWT in Cookies: usage/jwt-in-cookies.md
3440
- Configuration Options:
3541
- General Options: configuration/general.md
3642
- Headers Options: configuration/headers.md
3743
- Denylist Options: configuration/denylist.md
3844
- Cookies Options: configuration/cookies.md
3945
- CSRF Options: configuration/csrf.md
46+
- Development - Contributing: contributing.md
47+
- Release Notes: release-notes.md
48+
49+
extra_css:
50+
- 'css/custom.css'

pyproject.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[build-system]
2+
requires = ["flit_core >=2,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[tool.flit.metadata]
6+
module = "fastapi_jwt_auth"
7+
author = "Nyoman Pradipta Dewantara"
8+
author-email = "nyomanpradipta120@gmail.com"
9+
home-page = "https://github.com/IndominusByte/fastapi-jwt-auth"
10+
11+
classifiers = [
12+
"Environment :: Web Environment",
13+
"Intended Audience :: Developers",
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3.6",
16+
"Programming Language :: Python :: 3.7",
17+
"Programming Language :: Python :: 3.8",
18+
"License :: OSI Approved :: MIT License",
19+
"Operating System :: OS Independent",
20+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
21+
"Topic :: Software Development :: Libraries :: Python Modules"
22+
]
23+
24+
requires = [
25+
"fastapi>=0.61.0",
26+
"PyJWT>=1.7.1,<2.0.0"
27+
]
28+
29+
description-file = "README.md"
30+
requires-python = ">=3.6"
31+
32+
[tool.flit.metadata.requires-extra]
33+
test = [
34+
"pytest==6.0.1",
35+
"pytest-cov==2.10.0"
36+
]
37+
38+
doc = [
39+
"mkdocs >=1.1.2,<2.0.0",
40+
"mkdocs-material >=5.5.0,<6.0.0",
41+
"markdown-include >=0.5.1,<0.6.0"
42+
]
43+
44+
dev = [
45+
"cryptography>=2.6,<4.0.0",
46+
"uvicorn >=0.11.5,<0.12.0"
47+
]
48+
49+
asymmetric = ["cryptography>=2.6,<4.0.0"]

0 commit comments

Comments
 (0)