Use GitHub user ids instead of usernames for authentication

Otherwise, renaming a GitHub account could allow someone else
to gain access to a CDB account.
This commit is contained in:
rubenwardy
2024-03-30 16:52:17 +00:00
parent a8d2cc0383
commit f5dd77fcb3
8 changed files with 118 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
"""empty message
Revision ID: 1fe2e44cf565
Revises: d73078c5d619
Create Date: 2024-03-30 16:19:47.384716
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '1fe2e44cf565'
down_revision = 'd73078c5d619'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.add_column(sa.Column('github_user_id', sa.Integer(), nullable=True))
batch_op.create_unique_constraint("_user_github_user_id", ['github_user_id'])
def downgrade():
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.drop_constraint("_user_github_user_id", type_='unique')
batch_op.drop_column('github_user_id')