Skip to content

Update - support pydantic 2.* #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var/
.installed.cfg
*.egg
.pytest_cache
setup.py

# coverage
.coverage
Expand Down
41 changes: 0 additions & 41 deletions CHANGELOG.md

This file was deleted.

15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@

**Documentation**: <a href="https://indominusbyte.github.io/fastapi-jwt-auth" target="_blank">https://indominusbyte.github.io/fastapi-jwt-auth</a>

**Source Code**: <a href="https://github.com/IndominusByte/fastapi-jwt-auth" target="_blank">https://github.com/IndominusByte/fastapi-jwt-auth</a>
**Source Code**: <a href="https://github.com/jean-ek/fastapi-jwt-authV2" target="_blank">https://github.com/jean-ek/fastapi-jwt-authV2</a>

**Original Legacy Library**: <a href="https://github.com/IndominusByte/fastapi-jwt-auth" target="_blank">https://github.com/IndominusByte/fastapi-jwt-auth</a>

---

## Notes:
<b> This is a modified version of the original fastapi-jwt-auth library to add compatibility with pydantic versions 2.* </b>

## Features
FastAPI extension that provides JWT Auth support (secure, easy to use and lightweight), if you were familiar with flask-jwt-extended this extension suitable for you, cause this extension inspired by flask-jwt-extended 😀

- Compatible with pydantic 2.* versions
- Access tokens and refresh tokens
- Freshness Tokens
- Revoking Tokens
Expand All @@ -29,12 +35,7 @@ FastAPI extension that provides JWT Auth support (secure, easy to use and lightw
The easiest way to start working with this extension with pip

```bash
pip install fastapi-jwt-auth
```

If you want to use asymmetric (public/private) key signing algorithms, include the <b>asymmetric</b> extra requirements.
```bash
pip install 'fastapi-jwt-auth[asymmetric]'
pip install fastapi-jwt-auth-compat
```

## License
Expand Down
14 changes: 7 additions & 7 deletions fastapi_jwt_auth/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import timedelta
from typing import Optional, Union, Sequence, List
from typing import Optional, Union, List
from pydantic import (
BaseModel,
validator,
Expand All @@ -9,7 +9,7 @@
)

class LoadConfig(BaseModel):
authjwt_token_location: Optional[Sequence[StrictStr]] = {'headers'}
authjwt_token_location: Optional[List[StrictStr]] = {'headers'}
authjwt_secret_key: Optional[StrictStr] = None
authjwt_public_key: Optional[StrictStr] = None
authjwt_private_key: Optional[StrictStr] = None
Expand All @@ -18,9 +18,9 @@ class LoadConfig(BaseModel):
authjwt_decode_leeway: Optional[Union[StrictInt,timedelta]] = 0
authjwt_encode_issuer: Optional[StrictStr] = None
authjwt_decode_issuer: Optional[StrictStr] = None
authjwt_decode_audience: Optional[Union[StrictStr,Sequence[StrictStr]]] = None
authjwt_decode_audience: Optional[Union[StrictStr,List[StrictStr]]] = None
authjwt_denylist_enabled: Optional[StrictBool] = False
authjwt_denylist_token_checks: Optional[Sequence[StrictStr]] = {'access','refresh'}
authjwt_denylist_token_checks: Optional[List[StrictStr]] = {'access','refresh'}
authjwt_header_name: Optional[StrictStr] = "Authorization"
authjwt_header_type: Optional[StrictStr] = "Bearer"
authjwt_access_token_expires: Optional[Union[StrictBool,StrictInt,timedelta]] = timedelta(minutes=15)
Expand All @@ -42,7 +42,7 @@ class LoadConfig(BaseModel):
authjwt_refresh_csrf_cookie_path: Optional[StrictStr] = "/"
authjwt_access_csrf_header_name: Optional[StrictStr] = "X-CSRF-Token"
authjwt_refresh_csrf_header_name: Optional[StrictStr] = "X-CSRF-Token"
authjwt_csrf_methods: Optional[Sequence[StrictStr]] = {'POST','PUT','PATCH','DELETE'}
authjwt_csrf_methods: Optional[List[StrictStr]] = {'POST','PUT','PATCH','DELETE'}

@validator('authjwt_access_token_expires')
def validate_access_token_expires(cls, v):
Expand Down Expand Up @@ -81,5 +81,5 @@ def validate_csrf_methods(cls, v):
return v.upper()

class Config:
min_anystr_length = 1
anystr_strip_whitespace = True
str_min_length = 1
str_strip_whitespace = True
60 changes: 0 additions & 60 deletions mkdocs.yml

This file was deleted.

54 changes: 0 additions & 54 deletions pyproject.toml

This file was deleted.