# FastJWS
Using this module you can quickly and easily perform JWT authentication.
The main advantage is the use of the RSA-256 algorithm for signing tokens.
The library is also great for small microservices.
## Install
#### pip:
![Typing SVG](https://readme-typing-svg.herokuapp.com?color=%2336BCF7&lines=pip+install+fastjws)
#### poetry:
![Typing SVG](https://readme-typing-svg.herokuapp.com?color=%2336BCF7&lines=poetry+add+fastjws)
## Speed tests
|Action | Time |
|:-----------:|:--------:|
| Create token| 0.11 sec |
| Verify | 0.10 sec |
## Examples of using
```python
from fastapi import FastAPI, Depends
from fastjws import SingJWT, AuthJWT
from pydantic import BaseModel
import datetime
# Open keys !!!not necessarily like here)
private_key = open('rs256.rsa', "r").read()
public_key = open('rs256.rsa.pub', "r").read()
# Creating an instance of a class.
jwt_sing = SingJWT(private_key)
jwt_auth = AuthJWT(public_key)
# Pydantic model for example, this is optional)
class AuthScheme(BaseModel):
fake_login: str
fake_password: str
app = FastAPI()
@app.post("/token")
def token(fake_data: AuthScheme):
# Retrieving data from a database.
fake_user: dict = fake_database
# Selecting the token lifetime.
expire = datetime.timedelta(minutes=15)
# Receiving a token!)
token: str = jwt_sing(fake_user, expire)
@app.get("/data")
async def get_data(token_data = Depends(jwt_auth)):
return token_data
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Eugenekochetov02/fastjws",
"name": "fastjws",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "example python",
"author": "EugeneKo",
"author_email": "eugene.kochetov02@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/51/e5/3236e3b109d2c721b2ff21e64bb39131b18cae12a265d9828f4eb848685a/fastjws-1.1.0.tar.gz",
"platform": null,
"description": "# FastJWS\n\nUsing this module you can quickly and easily perform JWT authentication.\nThe main advantage is the use of the RSA-256 algorithm for signing tokens.\nThe library is also great for small microservices.\n\n## Install\n#### pip:\n\n![Typing SVG](https://readme-typing-svg.herokuapp.com?color=%2336BCF7&lines=pip+install+fastjws)\n#### poetry:\n\n![Typing SVG](https://readme-typing-svg.herokuapp.com?color=%2336BCF7&lines=poetry+add+fastjws)\n\n## Speed tests\n|Action | Time |\n|:-----------:|:--------:|\n| Create token| 0.11 sec |\n| Verify | 0.10 sec |\n\n## Examples of using\n\n```python\nfrom fastapi import FastAPI, Depends\nfrom fastjws import SingJWT, AuthJWT\nfrom pydantic import BaseModel\nimport datetime\n\n# Open keys !!!not necessarily like here)\nprivate_key = open('rs256.rsa', \"r\").read()\npublic_key = open('rs256.rsa.pub', \"r\").read()\n\n# Creating an instance of a class.\njwt_sing = SingJWT(private_key)\njwt_auth = AuthJWT(public_key)\n\n# Pydantic model for example, this is optional)\nclass AuthScheme(BaseModel):\n fake_login: str\n fake_password: str\n\napp = FastAPI()\n\n@app.post(\"/token\")\ndef token(fake_data: AuthScheme):\n # Retrieving data from a database.\n fake_user: dict = fake_database\n # Selecting the token lifetime.\n expire = datetime.timedelta(minutes=15)\n # Receiving a token!)\n token: str = jwt_sing(fake_user, expire)\n\n@app.get(\"/data\")\nasync def get_data(token_data = Depends(jwt_auth)):\n return token_data\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "This library will help you use JWT authentication in FastAPI!",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/Eugenekochetov02/fastjws"
},
"split_keywords": [
"example",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4eedbd17f1691add2d1683a12d59f996fc0ca419d3f1f40df12c1a11aeedfdc5",
"md5": "43c1bc9965b53ea734c69f1d77c819e0",
"sha256": "e0986297b79955a74485f05120c9ffdfdaa5c6b47c0838e513b63a8230e11dd7"
},
"downloads": -1,
"filename": "fastjws-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "43c1bc9965b53ea734c69f1d77c819e0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 3275,
"upload_time": "2023-09-25T23:54:51",
"upload_time_iso_8601": "2023-09-25T23:54:51.918531Z",
"url": "https://files.pythonhosted.org/packages/4e/ed/bd17f1691add2d1683a12d59f996fc0ca419d3f1f40df12c1a11aeedfdc5/fastjws-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "51e53236e3b109d2c721b2ff21e64bb39131b18cae12a265d9828f4eb848685a",
"md5": "5fadfc72059e6f1007e65e974fb1f2da",
"sha256": "9ce5db201de665f1c3fc75f9e1f131e93e2bf8b55cc101cb5fe0f25f0326f4c3"
},
"downloads": -1,
"filename": "fastjws-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "5fadfc72059e6f1007e65e974fb1f2da",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 2917,
"upload_time": "2023-09-25T23:54:53",
"upload_time_iso_8601": "2023-09-25T23:54:53.603043Z",
"url": "https://files.pythonhosted.org/packages/51/e5/3236e3b109d2c721b2ff21e64bb39131b18cae12a265d9828f4eb848685a/fastjws-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-25 23:54:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Eugenekochetov02",
"github_project": "fastjws",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fastjws"
}