diff --git a/alembic/versions/fa17ebbe2192_user_entity.py b/alembic/versions/fa17ebbe2192_user_entity.py new file mode 100644 index 0000000..9046adc --- /dev/null +++ b/alembic/versions/fa17ebbe2192_user_entity.py @@ -0,0 +1,28 @@ +"""user-entity + +Revision ID: fa17ebbe2192 +Revises: 15770e820938 +Create Date: 2022-08-26 20:18:50.700242 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'fa17ebbe2192' +down_revision = '15770e820938' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/readMe.md b/readMe.md index b480aca..493a2d3 100644 --- a/readMe.md +++ b/readMe.md @@ -1,5 +1,43 @@ -# RESTful API with Python, FastAPI, Pydantic, SQLAlchemy and Docker +# RESTful API with Python,SQLAlchemy, & FastAPI: Access and Refresh Tokens -### 1. RESTful API with Python & FastAPI: Access and Refresh Tokens +In this article, you'll learn how to secure a FastAPI app by implementing access and refresh token functionalities using JSON Web Tokens (JWTs). We'll use the FastAPI JWT Auth package to sign, encode and decode the access and refresh JWT tokens. -[RESTful API with Python & FastAPI: Access and Refresh Tokens](https://codevoweb.com/restful-api-with-python-fastapi-access-and-refresh-tokens) +![RESTful API with Python,SQLAlchemy, & FastAPI: Access and Refresh Tokens](https://codevoweb.com/wp-content/uploads/2022/07/RESTful-API-with-Python-FastAPI-Access-and-Refresh-Tokens.webp) + +## Topics Covered + +- Python FastAPI JWT Authentication Overview +- How to Setup FastAPI with PostgreSQL + - Setup FastAPI + - Initialize a Simple FastAPI Server +- Setting up Environment Variables in FastAPI +- Connect to the PostgreSQL Docker Container +- Installing the UUID OSSP PostgreSQL Extension +- Create Database Models with SQLAlchemy in FastAPI +- Creating Schemas with Pydantic in FastAPI +- Password Management with Bcrypt +- Configure the FastAPI JWT Auth Extension +- Creating the Authentication Controllers + - User Registration Controller + - User Sign-in Controller + - Refresh Access Token Controller + - Logout User Controller +- How to add Protected Routes +- Create a User Controller +- Adding the Routes to FastAPI Middleware Pipeline +- Database Migration with Alembic +- Testing the FastAPI JSON Web Token API + +Read the entire article here: [https://codevoweb.com/restful-api-with-python-fastapi-access-and-refresh-tokens](https://codevoweb.com/restful-api-with-python-fastapi-access-and-refresh-tokens) + +### 1. RESTful API with Python,SQLAlchemy, & FastAPI: Access and Refresh Tokens + +[RESTful API with Python, SQLAlchemy, & FastAPI: Access and Refresh Tokens](https://codevoweb.com/restful-api-with-python-fastapi-access-and-refresh-tokens) + +### 2. RESTful API with Python, SQLAlchemy, & FastAPI: Send HTML Emails + +[RESTful API with Python, SQLAlchemy & FastAPI: Send HTML Emails](https://codevoweb.com/restful-api-with-python-fastapi-send-html-emails) + +### 3. CRUD RESTful API Server with Python, FastAPI, SQLAlchemy, and PostgreSQL + +[CRUD RESTful API Server with Python, FastAPI, SQLAlchemy, and PostgreSQL](https://codevoweb.com/crud-restful-api-server-with-python-fastapi-and-postgresql) diff --git a/requirements.txt b/requirements.txt index 2c14003..095a868 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,46 +1,44 @@ -alembic==1.8.0 -anyio==3.6.1 -asgiref==3.5.2 -autopep8==1.6.0 -bcrypt==3.2.2 -certifi==2022.6.15 +aiosmtplib==1.1.7 +alembic==1.9.0 +anyio==3.6.2 +bcrypt==4.0.1 +blinker==1.5 +certifi==2022.12.7 cffi==1.15.1 -charset-normalizer==2.1.0 click==8.1.3 -colorama==0.4.5 +colorama==0.4.6 cryptography==3.4.8 dnspython==2.2.1 -email-validator==1.2.1 -fastapi==0.78.0 +email-validator==1.3.0 +fastapi==0.87.0 fastapi-jwt-auth==0.5.0 -greenlet==1.1.2 -h11==0.13.0 -httptools==0.4.0 -idna==3.3 +fastapi-mail==1.2.2 +greenlet==2.0.1 +h11==0.14.0 +httpcore==0.16.3 +httptools==0.5.0 +httpx==0.23.1 +idna==3.4 itsdangerous==2.1.2 Jinja2==3.1.2 -Mako==1.2.1 +Mako==1.2.4 MarkupSafe==2.1.1 -orjson==3.7.6 +orjson==3.8.3 passlib==1.7.4 -psycopg2==2.9.3 -pycodestyle==2.8.0 +psycopg2==2.9.5 pycparser==2.21 -pydantic==1.9.1 +pydantic==1.10.2 PyJWT==1.7.1 -python-dotenv==0.20.0 +python-dotenv==0.21.0 python-multipart==0.0.5 PyYAML==6.0 -requests==2.28.1 +rfc3986==1.5.0 six==1.16.0 -sniffio==1.2.0 -SQLAlchemy==1.4.39 -starlette==0.19.1 -toml==0.10.2 -typing_extensions==4.3.0 -tzdata==2022.1 -ujson==5.4.0 -urllib3==1.26.9 -uvicorn==0.17.6 -watchgod==0.8.2 -websockets==10.3 +sniffio==1.3.0 +SQLAlchemy==1.4.45 +starlette==0.21.0 +typing_extensions==4.4.0 +ujson==5.6.0 +uvicorn==0.20.0 +watchfiles==0.18.1 +websockets==10.4