Browse Source

Some fixes for Flask-Security and Oauth thingy

pull/378/head
squeaky otter 4 months ago
parent
commit
9ca4aed415
Signed by: dashie GPG Key ID: C2D57B325840B755
5 changed files with 89 additions and 2 deletions
  1. +1
    -1
      .vscode/settings.json
  2. +85
    -0
      api/migrations/versions/67_7df5c87e5fef_.py
  3. +1
    -0
      api/models.py
  4. +1
    -0
      api/requirements.txt
  5. +1
    -1
      api/setup.py

+ 1
- 1
.vscode/settings.json View File

@ -37,6 +37,6 @@
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatter.html": "js-beautify-html",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"python.pythonPath": "/usr/bin/python3.6",
"python.pythonPath": "venv/bin/python",
"restructuredtext.confPath": "${workspaceFolder}/docs"
}

+ 85
- 0
api/migrations/versions/67_7df5c87e5fef_.py View File

@ -0,0 +1,85 @@
"""oauth2_client + fs_uniquifier
Revision ID: 7df5c87e5fef
Revises: f537ac7a67d6
Create Date: 2021-02-23 19:07:51.420492
"""
# revision identifiers, used by Alembic.
revision = '7df5c87e5fef'
down_revision = 'f537ac7a67d6'
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
import uuid # noqa: E402
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('oauth2_client', sa.Column('client_id_issued_at', sa.Integer(), nullable=False))
op.add_column('oauth2_client', sa.Column('client_metadata', sa.Text(), nullable=True))
op.add_column('oauth2_client', sa.Column('client_secret_expires_at', sa.Integer(), nullable=False))
op.drop_column('oauth2_client', 'policy_uri')
op.drop_column('oauth2_client', 'tos_uri')
op.drop_column('oauth2_client', 'client_name')
op.drop_column('oauth2_client', 'response_type')
op.drop_column('oauth2_client', 'expires_at')
op.drop_column('oauth2_client', 'software_id')
op.drop_column('oauth2_client', 'redirect_uri')
op.drop_column('oauth2_client', 'software_version')
op.drop_column('oauth2_client', 'client_uri')
op.drop_column('oauth2_client', 'contact')
op.drop_column('oauth2_client', 'i18n_metadata')
op.drop_column('oauth2_client', 'logo_uri')
op.drop_column('oauth2_client', 'grant_type')
op.drop_column('oauth2_client', 'jwks_uri')
op.drop_column('oauth2_client', 'issued_at')
op.drop_column('oauth2_client', 'scope')
op.drop_column('oauth2_client', 'jwks_text')
op.drop_column('oauth2_client', 'token_endpoint_auth_method')
op.add_column('oauth2_code', sa.Column('code_challenge', sa.Text(), nullable=True))
op.add_column('oauth2_code', sa.Column('code_challenge_method', sa.String(length=48), nullable=True))
op.add_column('oauth2_code', sa.Column('nonce', sa.Text(), nullable=True))
# fs_uniquifier
op.add_column('user', sa.Column('fs_uniquifier', sa.String(length=255), nullable=True))
user_table = sa.Table('user', sa.MetaData(), sa.Column('id', sa.Integer, primary_key=True), sa.Column('fs_uniquifier', sa.String))
conn = op.get_bind()
for row in conn.execute(sa.select([user_table.c.id])):
conn.execute(user_table.update().values(fs_uniquifier=uuid.uuid4().hex).where(user_table.c.id == row['id']))
op.alter_column('user', 'fs_uniquifier', nullable=False)
op.create_unique_constraint(None, 'user', ['fs_uniquifier'])
# end fs_uniquifier
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'user', type_='unique')
op.drop_column('user', 'fs_uniquifier')
op.drop_column('oauth2_code', 'nonce')
op.drop_column('oauth2_code', 'code_challenge_method')
op.drop_column('oauth2_code', 'code_challenge')
op.add_column('oauth2_client', sa.Column('token_endpoint_auth_method', sa.VARCHAR(length=48), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('jwks_text', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('scope', sa.TEXT(), autoincrement=False, nullable=False))
op.add_column('oauth2_client', sa.Column('issued_at', sa.INTEGER(), autoincrement=False, nullable=False))
op.add_column('oauth2_client', sa.Column('jwks_uri', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('grant_type', sa.TEXT(), autoincrement=False, nullable=False))
op.add_column('oauth2_client', sa.Column('logo_uri', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('i18n_metadata', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('contact', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('client_uri', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('software_version', sa.VARCHAR(length=48), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('redirect_uri', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('software_id', sa.VARCHAR(length=36), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('expires_at', sa.INTEGER(), autoincrement=False, nullable=False))
op.add_column('oauth2_client', sa.Column('response_type', sa.TEXT(), autoincrement=False, nullable=False))
op.add_column('oauth2_client', sa.Column('client_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('tos_uri', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('oauth2_client', sa.Column('policy_uri', sa.TEXT(), autoincrement=False, nullable=True))
op.drop_column('oauth2_client', 'client_secret_expires_at')
op.drop_column('oauth2_client', 'client_metadata')
op.drop_column('oauth2_client', 'client_id_issued_at')
# ### end Alembic commands ###

+ 1
- 0
api/models.py View File

@ -83,6 +83,7 @@ class User(db.Model, UserMixin):
name = db.Column(db.String(255), nullable=False, info={"label": "Username"})
password = db.Column(db.String(255), nullable=True, info={"label": "Password"})
active = db.Column(db.Boolean())
fs_uniquifier = db.Column(db.String(255), unique=True, nullable=False)
confirmed_at = db.Column(db.DateTime())
created_at = db.Column(db.DateTime(timezone=False), default=datetime.datetime.utcnow)


+ 1
- 0
api/requirements.txt View File

@ -1,3 +1,4 @@
# don't forget to edit setup.py
Flask_Babel==2.0.0
psycopg2-binary==2.8.4
texttable==1.6.2


+ 1
- 1
api/setup.py View File

@ -19,7 +19,7 @@ setup(
"Bootstrap-Flask==1.2.0",
"Flask-Mail==0.9.1",
"Flask-Migrate==2.4.0",
"Flask-Uploads==0.2.1",
"Flask-Reuploaded==0.5.0",
"bcrypt==3.1.7",
"pydub==0.23.1",
"psycopg2-binary==2.8.4",


Loading…
Cancel
Save