0.6.0
0.6.0 Summary
🚀Features
- Token blacklist (possibility to log out users)
📝Docs
0. New Token Blacklist Model

To log users out, a token blacklist was created. Now you can invalidate a token at any moment. To do so, verify_token function (also schemas and CRUD) created.
🚚Migration
0. Update user table definition in create_first_superuser.py
If you change the user model, you must also update the table definition in src/scripts/create_first_superuser.py in order for it to keep working.
Here is the table definition:
# src/scripts/create_first_superuser.py
...
if user is None:
metadata = MetaData()
user_table = Table(
"user", metadata,
Column("id", Integer, primary_key=True, autoincrement=True, nullable=False),
Column("name", String(30), nullable=False),
Column("username", String(20), nullable=False, unique=True, index=True),
Column("email", String(50), nullable=False, unique=True, index=True),
Column("hashed_password", String, nullable=False),
Column("profile_image_url", String, default="https://profileimageurl.com"),
Column("uuid", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, unique=True),
Column("created_at", DateTime, default=datetime.utcnow, nullable=False),
Column("updated_at", DateTime),
Column("deleted_at", DateTime),
Column("is_deleted", Boolean, default=False, index=True),
Column("is_superuser", Boolean, default=False),
Column("tier_id", Integer, ForeignKey("tier.id"), index=True)
)Let's say you added a column in your user model, age.
...
class User(Base):
__tablename__ = "user"
...
# --------- here the new `age` column was added ---------
age: Mapped[Optional[int]] = mapped_column(default=None)
# -------------------------------------------------------
...I'll now update the table definition in create_first_superuser.py accordingly:
# src/scripts/create_first_superuser.py
...
if user is None:
metadata = MetaData()
user_table = Table(
"user", metadata,
...
Column("age", Integer, nullable=True, default=None),
...
)1. Token Blacklist
This should work out of the box, all you need to do is run the alembic migration.
While in the src folder:
poetry run alembic revision --autogenerateAnd to apply the migration
poetry run alembic upgrade head3. Middleware folder
Now you can create your middleware in the app/middleware folder. Client-side cache was moved there.
🔎Bug fixes
- docs content fixed
- fixed some type hints
- some unused imports removed
- logger being declared twice in
rate_limit.py#45 create_first_superusernow working again.
Warning
If you change the user model, now you'll also have to change the definition in create_first_superuser script. That happens because the script wasn't working without the relationship definitions, also getting the user model isn't trivial for async. May be fixed eventually.
What's Changed
- Update README.md by @igorbenav in #39
- Update README.md by @igorbenav in #40
- logger being declared twice in rate_limit.py fixed by @igorbenav in #45
- Update README.md by @igorbenav in #48
- 43 enhance folder structure by @igorbenav in #49
- Update README.md by @igorbenav in #50
- Update README.md by @igorbenav in #51
- Token blacklist by @igorbenav in #52
Full Changelog: v0.5.0...v0.6.0