From 8532ab5134209cd0b8842631155639a74578284c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 20 Dec 2021 22:50:14 +0100 Subject: [PATCH] JWT token size --- app/auth/models.py | 2 +- .../91be8a06d423_user_token_size_limit.py | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/91be8a06d423_user_token_size_limit.py diff --git a/app/auth/models.py b/app/auth/models.py index 86ebdb83c..d29cde908 100644 --- a/app/auth/models.py +++ b/app/auth/models.py @@ -65,7 +65,7 @@ class User(UserMixin, db.Model): date_created = db.Column(db.DateTime, default=datetime.utcnow) date_expiration = db.Column(db.DateTime, default=None) passwd_temp = db.Column(db.Boolean, default=False) - token = db.Column(db.String(32), index=True, unique=True) + token = db.Column(db.Text(), index=True, unique=True) token_expiration = db.Column(db.DateTime) roles = db.relationship("Role", secondary="user_role", viewonly=True) diff --git a/migrations/versions/91be8a06d423_user_token_size_limit.py b/migrations/versions/91be8a06d423_user_token_size_limit.py new file mode 100644 index 000000000..a9caa0d51 --- /dev/null +++ b/migrations/versions/91be8a06d423_user_token_size_limit.py @@ -0,0 +1,40 @@ +"""user token size limit + +Revision ID: 91be8a06d423 +Revises: 4f98a8b02c89 +Create Date: 2021-12-20 22:48:42.390743 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "91be8a06d423" +down_revision = "4f98a8b02c89" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column( + "user", + "token", + existing_type=sa.VARCHAR(length=32), + type_=sa.Text(), + existing_nullable=True, + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column( + "user", + "token", + existing_type=sa.Text(), + type_=sa.VARCHAR(length=32), + existing_nullable=True, + ) + # ### end Alembic commands ###