From c329e790cfbfb90e0effc1bc1a4868d1d0c559f5 Mon Sep 17 00:00:00 2001 From: Polyedre Date: Mon, 22 Feb 2021 22:32:48 +0100 Subject: fix(ci): Add rustc to the system dependencies --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9397c4ac..265566e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ aliases: command: | sudo apt-get update sudo apt-get install -y sox libtag1v5 libmagic1 libffi6 ffmpeg postgresql-client-11 rsync - sudo apt-get install -y cmake build-essential git wget make libboost-all-dev + sudo apt-get install -y cmake build-essential git wget make libboost-all-dev rustc sudo apt-get install -y libsox-dev libsox-fmt-all libtag1-dev libmagic-dev libffi-dev libgd-dev libmad0-dev libsndfile1-dev libid3tag0-dev libmediainfo-dev - &install_audiowaveform -- cgit v1.2.3 From 1bfb81502371f752dc06e43eb225de080705b8e2 Mon Sep 17 00:00:00 2001 From: Polyedre Date: Mon, 22 Feb 2021 22:48:24 +0100 Subject: fix(ci): Use black to reformat utils.py --- api/activitypub/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/activitypub/utils.py b/api/activitypub/utils.py index a44cbae8..3eb6030e 100644 --- a/api/activitypub/utils.py +++ b/api/activitypub/utils.py @@ -38,7 +38,7 @@ def full_url(path): def embed_collection(total_items, first_page_id): """Helper creating a root OrderedCollection - with a link to the first page.""" + with a link to the first page.""" return { "type": ap.ActivityType.ORDERED_COLLECTION.value, "totalItems": total_items, @@ -78,7 +78,7 @@ def activity_from_doc(item: Dict[str, Any], embed: bool = False) -> Dict[str, An def clean_activity(activity: ObjectType) -> Dict[str, Any]: """Clean the activity before rendering it. - - Remove the hidden bco and bcc field + - Remove the hidden bco and bcc field """ for field in ["bto", "bcc", "source"]: if field in activity: -- cgit v1.2.3 From cf5dd6eba205e8599a1d72f67157d66fec7c3002 Mon Sep 17 00:00:00 2001 From: Polyedre Date: Mon, 22 Feb 2021 23:08:52 +0100 Subject: fix(ci): Remove error displayed by flake8 --- api/activitypub/backend.py | 6 +++--- api/commands/system.py | 2 +- api/controllers/api/v1/accounts.py | 2 ++ api/tasks.py | 4 ++-- api/transcoding_utils.py | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/api/activitypub/backend.py b/api/activitypub/backend.py index 599273ce..78a623cc 100644 --- a/api/activitypub/backend.py +++ b/api/activitypub/backend.py @@ -90,7 +90,7 @@ class Reel2BitsBackend(ap.Backend): # Parse the activity ap_activity = ap.parse_activity(activity.payload) if not ap_activity: - current_app.logger.error(f"cannot parse undo follower activity") + current_app.logger.error("cannot parse undo follower activity") return actor = ap_activity.get_actor() @@ -159,7 +159,7 @@ class Reel2BitsBackend(ap.Backend): # FIXME TODO: check if it still works with unknown remote actor if not actor: - current_app.logger.debug(f"cannot find actor") + current_app.logger.debug("cannot find actor") actor = Actor.query.filter(Actor.url == ap_actor.id).first() if not actor: current_app.logger.debug(f"actor {ap_actor.id} not found") @@ -240,7 +240,7 @@ class Reel2BitsBackend(ap.Backend): current_app.logger.debug(f"fetch_iri: local activity {activity!r}") return activity.payload - current_app.logger.debug(f"fetch_iri: cannot find locally, fetching remote") + current_app.logger.debug("fetch_iri: cannot find locally, fetching remote") return super().fetch_iri(iri) def fetch_iri(self, iri: str) -> ap.ObjectType: diff --git a/api/commands/system.py b/api/commands/system.py index 36bf24ed..9b55cdb1 100644 --- a/api/commands/system.py +++ b/api/commands/system.py @@ -40,7 +40,7 @@ def test_email(email): msg.html = render_template("email/test_email.html", instance=instance) try: mail.send(msg) - except: # noqa: E772 + except: # noqa: E722 print(f"Error sending mail: {sys.exc_info()[0]}") diff --git a/api/controllers/api/v1/accounts.py b/api/controllers/api/v1/accounts.py index eff33449..897dda54 100644 --- a/api/controllers/api/v1/accounts.py +++ b/api/controllers/api/v1/accounts.py @@ -42,6 +42,8 @@ avatars = UploadSet("avatars", Reel2bitsDefaults.avatar_extensions_allowed) # nickname(==username), email, fullname, password, confirm, agreement, locale(dropped here for now) # Optionals: # bio + + @bp_api_v1_accounts.route("/api/v1/accounts", methods=["POST"]) def accounts(): """ diff --git a/api/tasks.py b/api/tasks.py index f07bdb86..7d67b16c 100644 --- a/api/tasks.py +++ b/api/tasks.py @@ -466,7 +466,7 @@ def finish_inbox_processing(self, iri: str) -> None: elif obj.has_type(ap.ActivityType.FOLLOW): backend.undo_new_follower(actor, obj) except (ActivityGoneError, ActivityNotFoundError, NotAnActivityError): - current_app.logger.exception(f"no retry") + current_app.logger.exception("no retry") except Exception as err: # noqa: F841 current_app.logger.exception(f"failed to cache attachments for" f" {iri}") @@ -511,7 +511,7 @@ def finish_post_to_outbox(self, iri: str) -> None: current_app.logger.debug(f"posting to {recp}") post_to_remote_inbox.delay(payload, recp) except (ActivityGoneError, ActivityNotFoundError): - current_app.logger.exception(f"no retry") + current_app.logger.exception("no retry") except Exception as err: # noqa: F841 current_app.logger.exception(f"failed to post " f"to remote inbox for {iri}") diff --git a/api/transcoding_utils.py b/api/transcoding_utils.py index 71bfbe2a..7b9eaaf0 100644 --- a/api/transcoding_utils.py +++ b/api/transcoding_utils.py @@ -174,7 +174,7 @@ def work_metadatas(sound_id, force=False): # force is unused for now sound = Sound.query.get(sound_id) if not sound: - print("- Cant find sound ID %(id)s in database".format(id=sound_id)) + print("- Cant find sound ID {id}s in database".format(id=sound_id)) return add_user_log( -- cgit v1.2.3 From 23535804d3268763eb2d22019da67127d006003b Mon Sep 17 00:00:00 2001 From: Polyedre Date: Mon, 22 Feb 2021 23:49:33 +0100 Subject: fix(ci): Update python packages versions - Flask_Babelex was updated to fix an error with an old Werkzeug version - Flask_Upload was replaced by Flask_Reuploaded for the same reason. See https://pypi.org/project/Flask-Reuploaded/ - Flask-Security was added --- api/requirements.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/requirements.txt b/api/requirements.txt index d5248b4a..b654603e 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,4 +1,4 @@ -Flask_Babelex==0.9.3 +Flask_Babelex==0.9.4 psycopg2-binary==2.8.4 texttable==1.6.2 Unidecode==1.1.1 @@ -13,7 +13,7 @@ bcrypt==3.1.7 celery==4.4.0 flask_mail==0.9.1 flask_migrate==2.5.2 -flask_uploads==0.2.1 +Flask-Reuploaded==0.5.0 wtforms_alchemy==0.16.9 sqlalchemy_searchable==1.1.0 redis==3.3.11 @@ -28,5 +28,6 @@ pymediainfo==4.1 feedgen==0.9.0 waitress==1.4.3 Flask-SQLAlchemy==2.4.1 +Flask-Security==3.0.0 git+https://github.com/jwag956/flask-security#egg=Flask-Security-too git+https://github.com/tsileo/little-boxes@master#egg=little-boxes -- cgit v1.2.3 From 991ebb490f7feac49eb0bc6d6bff654dcb40d512 Mon Sep 17 00:00:00 2001 From: Polyedre Date: Mon, 22 Feb 2021 23:52:29 +0100 Subject: fix(ci): Adapt to change in authlib imports See the warning about the change in version 0.13 in https://docs.authlib.org/en/stable/client/flask.html --- api/app_oauth.py | 4 ++-- api/controllers/api/account.py | 2 +- api/controllers/api/albums.py | 2 +- api/controllers/api/pleroma_admin.py | 2 +- api/controllers/api/reel2bits.py | 2 +- api/controllers/api/tracks.py | 2 +- api/controllers/api/v1/accounts.py | 2 +- api/controllers/api/v1/timelines.py | 2 +- api/forms.py | 2 +- api/models.py | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/api/app_oauth.py b/api/app_oauth.py index 171f833b..98616f47 100644 --- a/api/app_oauth.py +++ b/api/app_oauth.py @@ -1,5 +1,5 @@ -from authlib.flask.oauth2 import AuthorizationServer, ResourceProtector -from authlib.flask.oauth2.sqla import ( +from authlib.integrations.flask_oauth2 import AuthorizationServer, ResourceProtector +from authlib.integrations.sqla_oauth2 import ( create_query_client_func, create_save_token_func, create_revocation_endpoint, diff --git a/api/controllers/api/account.py b/api/controllers/api/account.py index 3230beef..b98af64a 100644 --- a/api/controllers/api/account.py +++ b/api/controllers/api/account.py @@ -1,6 +1,6 @@ from flask import Blueprint, jsonify, request, abort from app_oauth import require_oauth -from authlib.flask.oauth2 import current_token +from authlib.integrations.flask_oauth2 import current_token from models import UserLogging bp_api_account = Blueprint("bp_api_account", __name__) diff --git a/api/controllers/api/albums.py b/api/controllers/api/albums.py index 699baf4e..513581cd 100644 --- a/api/controllers/api/albums.py +++ b/api/controllers/api/albums.py @@ -1,6 +1,6 @@ from flask import Blueprint, jsonify, request, current_app from app_oauth import require_oauth -from authlib.flask.oauth2 import current_token +from authlib.integrations.flask_oauth2 import current_token from forms import AlbumForm from models import db, Album, User, Sound, SoundTag import json diff --git a/api/controllers/api/pleroma_admin.py b/api/controllers/api/pleroma_admin.py index 9fabdf1c..3f408d64 100644 --- a/api/controllers/api/pleroma_admin.py +++ b/api/controllers/api/pleroma_admin.py @@ -1,7 +1,7 @@ from flask import Blueprint, request, jsonify, abort from models import db, User from app_oauth import require_oauth -from authlib.flask.oauth2 import current_token +from authlib.integrations.flask_oauth2 import current_token bp_api_pleroma_admin = Blueprint("bp_api_pleroma_admin", __name__) diff --git a/api/controllers/api/reel2bits.py b/api/controllers/api/reel2bits.py index 77ab5f95..fddbd9b8 100644 --- a/api/controllers/api/reel2bits.py +++ b/api/controllers/api/reel2bits.py @@ -3,7 +3,7 @@ from models import db, User, PasswordResetToken, Sound, SoundTag, Actor, Followe from utils.various import add_user_log, generate_random_token, add_log from datas_helpers import to_json_account, to_json_relationship, default_genres, to_json_track from app_oauth import require_oauth -from authlib.flask.oauth2 import current_token +from authlib.integrations.flask_oauth2 import current_token from flask_security.utils import hash_password, verify_password from flask_mail import Message import smtplib diff --git a/api/controllers/api/tracks.py b/api/controllers/api/tracks.py index affeb990..492edb5e 100644 --- a/api/controllers/api/tracks.py +++ b/api/controllers/api/tracks.py @@ -1,6 +1,6 @@ from flask import Blueprint, request, jsonify, current_app from app_oauth import require_oauth -from authlib.flask.oauth2 import current_token +from authlib.integrations.flask_oauth2 import current_token from forms import SoundUploadForm from models import db, Sound, User, Album, UserLogging, SoundTag import json diff --git a/api/controllers/api/v1/accounts.py b/api/controllers/api/v1/accounts.py index 897dda54..0ee3ad47 100644 --- a/api/controllers/api/v1/accounts.py +++ b/api/controllers/api/v1/accounts.py @@ -17,7 +17,7 @@ from models import ( from flask_security.utils import hash_password from flask_security import confirmable as FSConfirmable from app_oauth import authorization, require_oauth -from authlib.flask.oauth2 import current_token +from authlib.integrations.flask_oauth2 import current_token from datas_helpers import to_json_track, to_json_account, to_json_relationship from utils.various import forbidden_username, add_user_log, add_log, get_hashed_filename from tasks import send_update_profile, federate_delete_actor, post_to_outbox diff --git a/api/controllers/api/v1/timelines.py b/api/controllers/api/v1/timelines.py index 3925bd15..f1b1a040 100644 --- a/api/controllers/api/v1/timelines.py +++ b/api/controllers/api/v1/timelines.py @@ -2,7 +2,7 @@ from flask import Blueprint, jsonify, request, abort from models import db, Sound, Activity, Album, User from app_oauth import require_oauth from datas_helpers import to_json_track, to_json_account, to_json_album, to_json_relationship -from authlib.flask.oauth2 import current_token +from authlib.integrations.flask_oauth2 import current_token bp_api_v1_timelines = Blueprint("bp_api_v1_timelines", __name__) diff --git a/api/forms.py b/api/forms.py index e49465a8..bace39c8 100644 --- a/api/forms.py +++ b/api/forms.py @@ -1,4 +1,4 @@ -from authlib.flask.oauth2 import current_token +from authlib.integrations.flask_oauth2 import current_token from flask_uploads import UploadSet, AUDIO from flask_wtf import FlaskForm as Form from flask_wtf.file import FileField, FileAllowed, FileRequired diff --git a/api/models.py b/api/models.py index d057d6b1..c1365702 100644 --- a/api/models.py +++ b/api/models.py @@ -19,7 +19,7 @@ from sqlalchemy.dialects.postgresql import UUID, JSONB from sqlalchemy import text as sa_text from little_boxes import activitypub as ap from urllib.parse import urlparse -from authlib.flask.oauth2.sqla import OAuth2ClientMixin, OAuth2AuthorizationCodeMixin, OAuth2TokenMixin +from authlib.integrations.sqla_oauth2 import OAuth2ClientMixin, OAuth2AuthorizationCodeMixin, OAuth2TokenMixin import time import uuid from utils.defaults import Reel2bitsDefaults -- cgit v1.2.3 From ad678e855ac15f00f3dd789637f11e16f6a6c949 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 08:28:58 +0100 Subject: Switch to the right Flask-Security --- api/requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/requirements.txt b/api/requirements.txt index b654603e..77ad8c89 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -28,6 +28,5 @@ pymediainfo==4.1 feedgen==0.9.0 waitress==1.4.3 Flask-SQLAlchemy==2.4.1 -Flask-Security==3.0.0 -git+https://github.com/jwag956/flask-security#egg=Flask-Security-too +Flask-Security-Too==4.0.0 git+https://github.com/tsileo/little-boxes@master#egg=little-boxes -- cgit v1.2.3 From d70356ec96f2df68c804b33cc0edebaa639485fb Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 08:41:02 +0100 Subject: s/Babelex/Babel/ --- api/app.py | 2 +- api/controllers/admin.py | 2 +- api/controllers/main.py | 2 +- api/controllers/users.py | 2 +- api/forms.py | 2 +- api/requirements.txt | 2 +- api/setup.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/app.py b/api/app.py index 8dfae508..6b58cfb4 100644 --- a/api/app.py +++ b/api/app.py @@ -3,7 +3,7 @@ import logging import os import subprocess from logging.handlers import RotatingFileHandler -from flask_babelex import gettext, Babel +from flask_babel import gettext, Babel from flask import Flask, render_template, g, send_from_directory, jsonify, safe_join, request, flash, Response from flask_bootstrap import Bootstrap from flask_mail import Mail diff --git a/api/controllers/admin.py b/api/controllers/admin.py index 409a2f8c..239d4497 100644 --- a/api/controllers/admin.py +++ b/api/controllers/admin.py @@ -1,5 +1,5 @@ from flask import Blueprint, render_template, request, redirect, url_for, flash, Response, json -from flask_babelex import gettext +from flask_babel import gettext from flask_security import login_required from forms import ConfigForm diff --git a/api/controllers/main.py b/api/controllers/main.py index cc231808..8892aea9 100644 --- a/api/controllers/main.py +++ b/api/controllers/main.py @@ -1,5 +1,5 @@ from flask import Blueprint, render_template -from flask_babelex import gettext +from flask_babel import gettext from models import User diff --git a/api/controllers/users.py b/api/controllers/users.py index cd924491..a0399e4b 100644 --- a/api/controllers/users.py +++ b/api/controllers/users.py @@ -1,7 +1,7 @@ import pytz import requests from flask import Blueprint, render_template, request, redirect, url_for, flash, Response, jsonify, current_app -from flask_babelex import gettext +from flask_babel import gettext from flask_security import login_required, current_user from forms import UserProfileForm diff --git a/api/forms.py b/api/forms.py index bace39c8..b227baab 100644 --- a/api/forms.py +++ b/api/forms.py @@ -7,7 +7,7 @@ from wtforms import widgets from wtforms.fields.core import StringField from wtforms.validators import DataRequired, ValidationError, Length from wtforms_alchemy import model_form_factory -from flask_babelex import lazy_gettext +from flask_babel import lazy_gettext from wtforms_alchemy.fields import QuerySelectField from models import db, Album diff --git a/api/requirements.txt b/api/requirements.txt index 77ad8c89..69292809 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,4 +1,4 @@ -Flask_Babelex==0.9.4 +Flask_Babel==2.0.0 psycopg2-binary==2.8.4 texttable==1.6.2 Unidecode==1.1.1 diff --git a/api/setup.py b/api/setup.py index 13017233..cb24ae1f 100644 --- a/api/setup.py +++ b/api/setup.py @@ -25,7 +25,7 @@ setup( "psycopg2-binary==2.8.4", "mutagen==1.43.0", "unidecode==1.1.1", - "Flask_Babelex==0.9.3", + "Flask_Babel==2.0.0", "texttable==1.6.1", "python-slugify==4.0.0", "python-magic==0.4.15", -- cgit v1.2.3 From ee08cc4c12be88101d060f262799e5bceb2207c8 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 09:00:04 +0100 Subject: Add python 3.9 --- .circleci/config.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 265566e1..dec247c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -222,10 +222,10 @@ jobs: - image: circleci/python:3.7-buster-node <<: *install_python_dependencies - install-python3.8: + install-python3.9: <<: *defaults docker: - - image: circleci/python:3.8-rc-buster-node + - image: circleci/python:3.9-rc-buster-node <<: *install_python_dependencies test-python3.6: @@ -248,10 +248,10 @@ jobs: POSTGRES_DB: reel2bits_test <<: *test_steps - test-python3.8: + test-python3.9: <<: *defaults docker: - - image: circleci/python:3.8-rc-buster-node + - image: circleci/python:3.9-rc-buster-node - image: circleci/postgres:11-alpine environment: POSTGRES_USER: postgres @@ -313,13 +313,18 @@ workflows: - install-python3.7: requires: - install - - install-python3.6 + - install-python3.9: + requires: + - install - test-python3.6: requires: - install-python3.6 - test-python3.7: requires: - install-python3.7 + - test-python3.9: + requires: + - install-python3.9 - front-lint-lts: requires: - install -- cgit v1.2.3 From 4b63a87c3c316fde26b05de9a60849cd7dee9312 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 09:03:19 +0100 Subject: Front in // --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dec247c2..d402a7b8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -335,11 +335,9 @@ workflows: - front-lint: requires: - install - - front-lint-lts - front-build: requires: - install - - front-lint-lts - front-lint - front-sync: requires: -- cgit v1.2.3 From 9cd002024634a61173fe5f39992788edc3b1988f Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 09:04:07 +0100 Subject: useless requirement --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d402a7b8..377ba51a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -330,18 +330,15 @@ workflows: - install - front-test-lts: requires: - - install - front-lint-lts - front-lint: requires: - install - front-build: requires: - - install - front-lint - front-sync: requires: - - install - front-lint-lts - front-build filters: -- cgit v1.2.3 From 9ca4aed41518c4fe8ce0adc3b91d6ac777423d48 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 19:15:30 +0100 Subject: Some fixes for Flask-Security and Oauth thingy --- .vscode/settings.json | 2 +- api/migrations/versions/67_7df5c87e5fef_.py | 85 +++++++++++++++++++++++++++++ api/models.py | 1 + api/requirements.txt | 1 + api/setup.py | 2 +- 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 api/migrations/versions/67_7df5c87e5fef_.py diff --git a/.vscode/settings.json b/.vscode/settings.json index e8f3a966..d2308c6f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" } \ No newline at end of file diff --git a/api/migrations/versions/67_7df5c87e5fef_.py b/api/migrations/versions/67_7df5c87e5fef_.py new file mode 100644 index 00000000..ab1d91e8 --- /dev/null +++ b/api/migrations/versions/67_7df5c87e5fef_.py @@ -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 ### diff --git a/api/models.py b/api/models.py index c1365702..862dad73 100644 --- a/api/models.py +++ b/api/models.py @@ -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) diff --git a/api/requirements.txt b/api/requirements.txt index 69292809..ceadb2d1 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -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 diff --git a/api/setup.py b/api/setup.py index cb24ae1f..1f43f6f5 100644 --- a/api/setup.py +++ b/api/setup.py @@ -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", -- cgit v1.2.3 From 50aac7a39c37f6569bcadf50702112ea5c2d7d94 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 19:20:08 +0100 Subject: forgot the linter --- .gitignore | 1 + api/migrations/versions/67_7df5c87e5fef_.py | 122 +++++++++++++++------------- 2 files changed, 66 insertions(+), 57 deletions(-) diff --git a/.gitignore b/.gitignore index 114d4611..469a2c64 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ front/locales/en_US/LC_MESSAGES/app.po .env /data /api/celerybeat-schedule +/venv diff --git a/api/migrations/versions/67_7df5c87e5fef_.py b/api/migrations/versions/67_7df5c87e5fef_.py index ab1d91e8..b1b7151e 100644 --- a/api/migrations/versions/67_7df5c87e5fef_.py +++ b/api/migrations/versions/67_7df5c87e5fef_.py @@ -7,79 +7,87 @@ Create Date: 2021-02-23 19:07:51.420492 """ # revision identifiers, used by Alembic. -revision = '7df5c87e5fef' -down_revision = 'f537ac7a67d6' +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)) + 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)) + 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) + 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']) + 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') + 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 ### -- cgit v1.2.3 From f9c3de5fc858acf7f1f96ae087f0e6103cf31310 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 19:34:19 +0100 Subject: Fix requirement --- api/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/requirements.txt b/api/requirements.txt index ceadb2d1..9113a7c7 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -21,7 +21,7 @@ redis==3.3.11 flask-accept==0.0.6 Bootstrap-Flask==1.2.0 PyQRCode==1.2.1 -Authlib>=0.11 +Authlib==0.15.3 flask-cors>=3.0.8 cachetools==4.0.0 flasgger==0.9.3 -- cgit v1.2.3 From d128a9efadc40e10188e89485cd0b526c40e45b6 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 19:36:29 +0100 Subject: bump some versions --- api/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/requirements.txt b/api/requirements.txt index 9113a7c7..c25b0342 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -9,11 +9,11 @@ python-magic==0.4.15 flask==1.1.1 python-slugify==4.0.0 wtforms==2.2.1 -sqlalchemy==1.3.12 +sqlalchemy==1.3.23 bcrypt==3.1.7 celery==4.4.0 flask_mail==0.9.1 -flask_migrate==2.5.2 +flask_migrate==2.7.0 Flask-Reuploaded==0.5.0 wtforms_alchemy==0.16.9 sqlalchemy_searchable==1.1.0 @@ -28,6 +28,6 @@ flasgger==0.9.3 pymediainfo==4.1 feedgen==0.9.0 waitress==1.4.3 -Flask-SQLAlchemy==2.4.1 +Flask-SQLAlchemy==2.4.4 Flask-Security-Too==4.0.0 git+https://github.com/tsileo/little-boxes@master#egg=little-boxes -- cgit v1.2.3 From e66a42e91e838cdb678406c4d799b96682101ae7 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 20:26:22 +0100 Subject: Fix Authlib breakage --- api/migrations/versions/67_7df5c87e5fef_.py | 39 ++++++++++++++++------------- api/models.py | 8 ++++++ 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/api/migrations/versions/67_7df5c87e5fef_.py b/api/migrations/versions/67_7df5c87e5fef_.py index b1b7151e..23e99f37 100644 --- a/api/migrations/versions/67_7df5c87e5fef_.py +++ b/api/migrations/versions/67_7df5c87e5fef_.py @@ -14,6 +14,11 @@ from alembic import op # noqa: E402 import sqlalchemy as sa # noqa: E402 import uuid # noqa: E402 +""" +Note: Authlib introduced major breaking change by removing thoses fields that I wasn't able to find in the changelogs +Theses will stay commented, they have been added into the models. +""" + def upgrade(): # ### commands auto generated by Alembic - please adjust! ### @@ -22,22 +27,22 @@ def upgrade(): 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", "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", "redirect_uri") op.drop_column("oauth2_client", "software_version") - op.drop_column("oauth2_client", "client_uri") + # 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", "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", "scope") op.drop_column("oauth2_client", "jwks_text") - op.drop_column("oauth2_client", "token_endpoint_auth_method") + # 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)) @@ -64,27 +69,27 @@ def downgrade(): 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("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("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("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("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("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("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") diff --git a/api/models.py b/api/models.py index 862dad73..ddb4b86c 100644 --- a/api/models.py +++ b/api/models.py @@ -219,6 +219,14 @@ class OAuth2Client(db.Model, OAuth2ClientMixin): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="CASCADE")) + client_name = db.Column(db.String(255)) + client_uri = db.Column(db.Text()) + redirect_uri = db.Column(db.Text()) + scope = db.Column(db.Text(), nullable=False) + token_endpoint_auth_method = db.Column(db.String(50)) + response_type = db.Column(db.Text(), nullable=False) + grant_type = db.Column(db.Text(), nullable=False) + user = db.relationship("User") -- cgit v1.2.3 From 5a43c811dde4cec5127476b3f23b7412d5dc27ec Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 20:55:55 +0100 Subject: Bump lof of libs versions --- api/requirements.txt | 40 ++++++++++++++++++++-------------------- api/setup.py | 36 ++++++++++++++++++------------------ api/tests/conftest.py | 6 +++--- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/api/requirements.txt b/api/requirements.txt index c25b0342..6abc0333 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,33 +1,33 @@ # don't forget to edit setup.py Flask_Babel==2.0.0 -psycopg2-binary==2.8.4 -texttable==1.6.2 -Unidecode==1.1.1 -pydub==0.23.1 -mutagen==1.43.0 -python-magic==0.4.15 -flask==1.1.1 -python-slugify==4.0.0 -wtforms==2.2.1 +psycopg2-binary==2.8.6 +texttable==1.6.3 +Unidecode==1.2.0 +pydub==0.24.1 +mutagen==1.45.1 +python-magic==0.4.22 +flask==1.1.2 +python-slugify==4.0.1 +wtforms==2.3.3 sqlalchemy==1.3.23 -bcrypt==3.1.7 -celery==4.4.0 +bcrypt==3.2.0 +celery==5.0.5 flask_mail==0.9.1 flask_migrate==2.7.0 Flask-Reuploaded==0.5.0 -wtforms_alchemy==0.16.9 -sqlalchemy_searchable==1.1.0 -redis==3.3.11 +wtforms_alchemy==0.17.0 +sqlalchemy_searchable==1.2.0 +redis==3.5.3 flask-accept==0.0.6 -Bootstrap-Flask==1.2.0 +Bootstrap-Flask==1.5.1 PyQRCode==1.2.1 Authlib==0.15.3 -flask-cors>=3.0.8 -cachetools==4.0.0 -flasgger==0.9.3 -pymediainfo==4.1 +flask-cors>=3.0.10 +cachetools==4.2.1 +flasgger==0.9.5 +pymediainfo==5.0.3 feedgen==0.9.0 -waitress==1.4.3 +waitress==1.4.4 Flask-SQLAlchemy==2.4.4 Flask-Security-Too==4.0.0 git+https://github.com/tsileo/little-boxes@master#egg=little-boxes diff --git a/api/setup.py b/api/setup.py index 1f43f6f5..464f76dc 100644 --- a/api/setup.py +++ b/api/setup.py @@ -10,29 +10,29 @@ setup( author="Dashie", author_email="dashie@sigpipe.me", install_requires=[ - "Flask==1.1.1", - "SQLAlchemy==1.3.12", - "WTForms==2.2.1", - "WTForms-Alchemy==0.16.9", - "SQLAlchemy-Searchable==1.1.0", + "Flask==1.1.2", + "SQLAlchemy==1.3.23", + "WTForms==2.3.3", + "WTForms-Alchemy==0.17.0", + "SQLAlchemy-Searchable==1.2.0", "SQLAlchemy-Utils==0.36.1", - "Bootstrap-Flask==1.2.0", + "Bootstrap-Flask==1.5.1", "Flask-Mail==0.9.1", - "Flask-Migrate==2.4.0", + "Flask-Migrate==2.7.0", "Flask-Reuploaded==0.5.0", - "bcrypt==3.1.7", - "pydub==0.23.1", - "psycopg2-binary==2.8.4", - "mutagen==1.43.0", - "unidecode==1.1.1", + "bcrypt==3.2.0", + "pydub==0.24.1", + "psycopg2-binary==2.8.6", + "mutagen==1.45.1", + "unidecode==1.2.0", "Flask_Babel==2.0.0", - "texttable==1.6.1", - "python-slugify==4.0.0", - "python-magic==0.4.15", - "redis==3.3.11", - "celery==4.4.0", + "texttable==1.6.3", + "python-slugify==4.0.1", + "python-magic==0.4.22", + "redis==3.5.3", + "celery==5.0.5", "flask-accept==0.0.6", ], setup_requires=["pytest-runner"], - tests_require=["pytest==5.3.2", "pytest-cov==2.8.1", "jsonschema==3.2.0"], + tests_require=["pytest==6.2.2", "pytest-cov==2.11.1", "jsonschema==3.2.0"], ) diff --git a/api/tests/conftest.py b/api/tests/conftest.py index 4fa21e0d..f1a244be 100644 --- a/api/tests/conftest.py +++ b/api/tests/conftest.py @@ -14,7 +14,7 @@ from commands.db_datas import make_db_seed # noqa: E402 from models import user_datastore # noqa: E402 -@pytest.yield_fixture(scope="session") +@pytest.fixture(scope="session") def app(): app = create_app(config_filename="config.testing.Config") ctx = app.app_context() @@ -25,7 +25,7 @@ def app(): ctx.pop() -@pytest.yield_fixture(scope="session") +@pytest.fixture(scope="session") def db(app): _db.drop_all() _db.engine.connect().execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";') @@ -43,7 +43,7 @@ def client(app): return app.test_client() -@pytest.yield_fixture(scope="function") +@pytest.fixture(scope="function") def session(db): connection = db.engine.connect() transaction = connection.begin() -- cgit v1.2.3 From 81fce46bff43598af0c976a160a21a66169141d5 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 21:14:56 +0100 Subject: add pytest-sugar plugin --- api/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/setup.py b/api/setup.py index 464f76dc..2555db4d 100644 --- a/api/setup.py +++ b/api/setup.py @@ -34,5 +34,5 @@ setup( "flask-accept==0.0.6", ], setup_requires=["pytest-runner"], - tests_require=["pytest==6.2.2", "pytest-cov==2.11.1", "jsonschema==3.2.0"], + tests_require=["pytest==6.2.2", "pytest-cov==2.11.1", "jsonschema==3.2.0", "pytest-sugar==0.9.4"], ) -- cgit v1.2.3 From 9ae5186bca6386c255eccfb20afe3c7f0cd8a726 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 23:15:36 +0100 Subject: This uses the client_metadata from authlib, /oauth/authorize seems ok, /oauth/token still not working --- api/controllers/api/v1/auth.py | 24 +++++++++++-------- api/migrations/versions/dff4edfb26b6_.py | 41 ++++++++++++++++++++++++++++++++ api/models.py | 7 ------ 3 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 api/migrations/versions/dff4edfb26b6_.py diff --git a/api/controllers/api/v1/auth.py b/api/controllers/api/v1/auth.py index 4cb7aefa..4261b7b8 100644 --- a/api/controllers/api/v1/auth.py +++ b/api/controllers/api/v1/auth.py @@ -41,19 +41,23 @@ def create_client(): return response client = OAuth2Client() - client.client_name = req.get("client_name") - client.client_uri = req.get("website", None) - client.redirect_uri = req.get("redirect_uris") - client.scope = req.get("scopes") client.client_id = gen_salt(24) + metadatas = { + "client_name": req.get("client_name"), + "client_uri": req.get("website", None), + "redirect_uris": req.get("redirect_uris"), + "scope": req.get("scopes"), + # this needs to be hardcoded for whatever reason + "response_type": "code", + "grant_type": "authorization_code\r\nclient_credentials\r\npassword", + "token_endpoint_auth_method": "client_secret_post", + } if client.token_endpoint_auth_method == "none": client.client_secret = "" else: client.client_secret = gen_salt(48) - # this needs to be hardcoded for whatever reason - client.response_type = "code" - client.grant_type = "authorization_code\r\nclient_credentials\r\npassword" - client.token_endpoint_auth_method = "client_secret_post" + + client.set_client_metadata(metadatas) db.session.add(client) db.session.commit() @@ -63,7 +67,7 @@ def create_client(): "client_secret": client.client_secret, "id": client.id, "name": client.client_name, - "redirect_uri": client.redirect_uri, + "redirect_uris": client.redirect_uris[0] if len(client.redirect_uris) else "", "website": client.client_uri, "vapid_key": None, # FIXME to implement this } @@ -136,7 +140,7 @@ def oauth_token(): d["redirect_uri"] = request.json["redirect_uri"] request.form = ImmutableMultiDict(d) - return authorization.create_token_response() + return authorization.create_token_response(request) @bp_api_v1_auth.route("/oauth/revoke", methods=["POST"]) diff --git a/api/migrations/versions/dff4edfb26b6_.py b/api/migrations/versions/dff4edfb26b6_.py new file mode 100644 index 00000000..e8b80b2a --- /dev/null +++ b/api/migrations/versions/dff4edfb26b6_.py @@ -0,0 +1,41 @@ +"""empty message + +Revision ID: dff4edfb26b6 +Revises: 7df5c87e5fef +Create Date: 2021-02-23 22:59:23.112766 + +""" + +# revision identifiers, used by Alembic. +revision = "dff4edfb26b6" +down_revision = "7df5c87e5fef" + +from alembic import op # noqa: E402 +import sqlalchemy as sa # noqa: E402 + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("oauth2_client", "redirect_uri") + op.drop_column("oauth2_client", "client_uri") + op.drop_column("oauth2_client", "response_type") + op.drop_column("oauth2_client", "client_name") + op.drop_column("oauth2_client", "grant_type") + op.drop_column("oauth2_client", "token_endpoint_auth_method") + op.drop_column("oauth2_client", "scope") + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column("oauth2_client", sa.Column("scope", sa.TEXT(), autoincrement=False, nullable=False)) + 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("grant_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("response_type", sa.TEXT(), autoincrement=False, nullable=False)) + op.add_column("oauth2_client", sa.Column("client_uri", sa.TEXT(), autoincrement=False, nullable=True)) + op.add_column("oauth2_client", sa.Column("redirect_uri", sa.TEXT(), autoincrement=False, nullable=True)) + # ### end Alembic commands ### diff --git a/api/models.py b/api/models.py index ddb4b86c..294956df 100644 --- a/api/models.py +++ b/api/models.py @@ -219,13 +219,6 @@ class OAuth2Client(db.Model, OAuth2ClientMixin): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="CASCADE")) - client_name = db.Column(db.String(255)) - client_uri = db.Column(db.Text()) - redirect_uri = db.Column(db.Text()) - scope = db.Column(db.Text(), nullable=False) - token_endpoint_auth_method = db.Column(db.String(50)) - response_type = db.Column(db.Text(), nullable=False) - grant_type = db.Column(db.Text(), nullable=False) user = db.relationship("User") -- cgit v1.2.3 From 565f0eb58392b6cfb25c34b0dc1d1f98f205dc9c Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 23 Feb 2021 23:41:16 +0100 Subject: Is that THE fix --- api/controllers/api/v1/auth.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/controllers/api/v1/auth.py b/api/controllers/api/v1/auth.py index 4261b7b8..10261675 100644 --- a/api/controllers/api/v1/auth.py +++ b/api/controllers/api/v1/auth.py @@ -45,11 +45,11 @@ def create_client(): metadatas = { "client_name": req.get("client_name"), "client_uri": req.get("website", None), - "redirect_uris": req.get("redirect_uris"), + "redirect_uris": [req.get("redirect_uris")], # TODO, should make a check or something "scope": req.get("scopes"), # this needs to be hardcoded for whatever reason "response_type": "code", - "grant_type": "authorization_code\r\nclient_credentials\r\npassword", + "grant_types": ["authorization_code", "client_credentials", "password"], "token_endpoint_auth_method": "client_secret_post", } if client.token_endpoint_auth_method == "none": -- cgit v1.2.3 From 7dc45b7a85b7a5c1db419e9a24596ee506f06730 Mon Sep 17 00:00:00 2001 From: Dashie Date: Wed, 24 Feb 2021 00:16:52 +0100 Subject: Add python 3.8 to CI --- .circleci/config.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 377ba51a..d0ddcbc5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -222,6 +222,12 @@ jobs: - image: circleci/python:3.7-buster-node <<: *install_python_dependencies + install-python3.8: + <<: *defaults + docker: + - image: circleci/python:3.8-buster-node + <<: *install_python_dependencies + install-python3.9: <<: *defaults docker: @@ -248,6 +254,16 @@ jobs: POSTGRES_DB: reel2bits_test <<: *test_steps + test-python3.8: + <<: *defaults + docker: + - image: circleci/python:3.8-buster-node + - image: circleci/postgres:11-alpine + environment: + POSTGRES_USER: postgres + POSTGRES_DB: reel2bits_test + <<: *test_steps + test-python3.9: <<: *defaults docker: @@ -313,6 +329,9 @@ workflows: - install-python3.7: requires: - install + - install-python3.8: + requires: + - install - install-python3.9: requires: - install @@ -322,6 +341,9 @@ workflows: - test-python3.7: requires: - install-python3.7 + - test-python3.8: + requires: + - install-python3.8 - test-python3.9: requires: - install-python3.9 -- cgit v1.2.3 From 71fd48c5056c0a874be2149c28a3047799cbd952 Mon Sep 17 00:00:00 2001 From: Dashie Date: Wed, 24 Feb 2021 00:37:15 +0100 Subject: Set fs_uniquifier here too --- api/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/models.py b/api/models.py index 294956df..7dd2699c 100644 --- a/api/models.py +++ b/api/models.py @@ -774,6 +774,7 @@ def create_remote_actor(activity_actor: ap.BaseActivity): user.confirmed_at = None user.display_name = activity_actor.name user.local = False + user.fs_uniquifier = uuid.uuid4().hex actor.user = user -- cgit v1.2.3 From 5f113a49c69fd4af0754b37746731f8dcacf620b Mon Sep 17 00:00:00 2001 From: Dashie Date: Wed, 24 Feb 2021 07:33:47 +0100 Subject: Rename migration; Rename some CI targets; Switch to cimg images --- .circleci/config.yml | 53 +++++++++++++++++------------ api/migrations/versions/68_dff4edfb26b6_.py | 41 ++++++++++++++++++++++ api/migrations/versions/dff4edfb26b6_.py | 41 ---------------------- 3 files changed, 72 insertions(+), 63 deletions(-) create mode 100644 api/migrations/versions/68_dff4edfb26b6_.py delete mode 100644 api/migrations/versions/dff4edfb26b6_.py diff --git a/.circleci/config.yml b/.circleci/config.yml index d0ddcbc5..c3e4457f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ version: 2 aliases: - &defaults docker: - - image: circleci/python:3.6-buster-node + - image: cimg/python:3.6-node working_directory: ~/projects/reel2bits - &attach_workspace @@ -219,25 +219,25 @@ jobs: install-python3.7: <<: *defaults docker: - - image: circleci/python:3.7-buster-node + - image: cimg/python:3.7-node <<: *install_python_dependencies install-python3.8: <<: *defaults docker: - - image: circleci/python:3.8-buster-node + - image: cimg/python:3.8-node <<: *install_python_dependencies install-python3.9: <<: *defaults docker: - - image: circleci/python:3.9-rc-buster-node + - image: cimg/python:3.9-node <<: *install_python_dependencies test-python3.6: <<: *defaults docker: - - image: circleci/python:3.6-buster-node + - image: cimg/python:3.6-node - image: circleci/postgres:11-alpine environment: POSTGRES_USER: postgres @@ -247,7 +247,7 @@ jobs: test-python3.7: <<: *defaults docker: - - image: circleci/python:3.7-buster-node + - image: cimg/python:3.7-node - image: circleci/postgres:11-alpine environment: POSTGRES_USER: postgres @@ -257,7 +257,7 @@ jobs: test-python3.8: <<: *defaults docker: - - image: circleci/python:3.8-buster-node + - image: cimg/python:3.8-node - image: circleci/postgres:11-alpine environment: POSTGRES_USER: postgres @@ -267,47 +267,53 @@ jobs: test-python3.9: <<: *defaults docker: - - image: circleci/python:3.9-rc-buster-node + - image: cimg/python:3.9-node - image: circleci/postgres:11-alpine environment: POSTGRES_USER: postgres POSTGRES_DB: reel2bits_test <<: *test_steps - front-lint: + front-lint-current: <<: *defaults docker: - - image: circleci/node:12.9.0-buster-browsers + - image: cimg/node:current-browsers <<: *lint_steps_front front-lint-lts: <<: *defaults docker: - - image: circleci/node:10.16.3-buster-browsers + - image: cimg/node:lts-browsers <<: *lint_steps_front front-test-lts: <<: *defaults docker: - - image: circleci/node:10.16.3-buster-browsers + - image: cimg/node:lts-browsers <<: *test_steps_front - front-build: + front-build-lts: <<: *defaults docker: - - image: circleci/node:10.16.3-buster-browsers + - image: cimg/node:lts-browsers <<: *build_front - front-sync: + front-build-current: <<: *defaults docker: - - image: circleci/node:10.16.3-buster-browsers + - image: cim