aboutsummaryrefslogtreecommitdiff
path: root/server/szurubooru/migrations
diff options
context:
space:
mode:
authorReAnzu2018-02-25 04:44:02 -0600
committerrr-2018-03-25 22:23:29 +0200
commit2a69f0193f9e5aa451e0dbcb8c89070f3e49ffa5 (patch)
treebda640614ae711e8fef0e0463f118f85ef83ac0e /server/szurubooru/migrations
parente35e70992736340bff3995ca6f425baf2f431e2f (diff)
server/auth: add token authentication
* Users are only authenticated against their password on login, and to retrieve a token * Passwords are wiped from the GUI frontend and cookies after login and token retrieval * Tokens are revoked at the end of the session/logout * If the user chooses the "remember me" option, the token is stored in the cookie * Tokens correctly delete themselves on logout * Tokens can expire at user-specified date * Tokens have their last usage time * Tokens can have user defined descriptions * Users can manage login tokens in their account settings
Diffstat (limited to 'server/szurubooru/migrations')
-rw-r--r--server/szurubooru/migrations/versions/a39c7f98a7fa_add_user_token_table.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/server/szurubooru/migrations/versions/a39c7f98a7fa_add_user_token_table.py b/server/szurubooru/migrations/versions/a39c7f98a7fa_add_user_token_table.py
new file mode 100644
index 0000000..899eaa7
--- /dev/null
+++ b/server/szurubooru/migrations/versions/a39c7f98a7fa_add_user_token_table.py
@@ -0,0 +1,39 @@
+'''
+Added a user_token table for API authorization
+
+Revision ID: a39c7f98a7fa
+Created at: 2018-02-25 01:31:27.345595
+'''
+
+import sqlalchemy as sa
+from alembic import op
+
+
+revision = 'a39c7f98a7fa'
+down_revision = '9ef1a1643c2a'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ op.create_table(
+ 'user_token',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('user_id', sa.Integer(), nullable=False),
+ sa.Column('token', sa.Unicode(length=36), nullable=False),
+ sa.Column('note', sa.Unicode(length=128), nullable=True),
+ sa.Column('enabled', sa.Boolean(), nullable=False),
+ sa.Column('expiration_time', sa.DateTime(), nullable=True),
+ sa.Column('creation_time', sa.DateTime(), nullable=False),
+ sa.Column('last_edit_time', sa.DateTime(), nullable=True),
+ sa.Column('last_usage_time', sa.DateTime(), nullable=True),
+ sa.Column('version', sa.Integer(), nullable=False),
+ sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
+ sa.PrimaryKeyConstraint('id'))
+ op.create_index(
+ op.f('ix_user_token_user_id'), 'user_token', ['user_id'], unique=False)
+
+
+def downgrade():
+ op.drop_index(op.f('ix_user_token_user_id'), table_name='user_token')
+ op.drop_table('user_token')

© 2015 - 2026 Jakob L. Kreuze