diff --git a/trunk/065a3aa2f5a22024746419596de7de8dff34440c.patch b/trunk/065a3aa2f5a22024746419596de7de8dff34440c.patch new file mode 100644 index 0000000..f6be5e7 --- /dev/null +++ b/trunk/065a3aa2f5a22024746419596de7de8dff34440c.patch @@ -0,0 +1,175 @@ +From 065a3aa2f5a22024746419596de7de8dff34440c Mon Sep 17 00:00:00 2001 +From: Aditya Toshniwal +Date: Sun, 6 Jun 2021 13:58:06 +0530 +Subject: [PATCH] Updated Flask-Security-Too to the latest v4. Fixes #6225 + +--- + docs/en_US/release_notes_5_4.rst | 1 + + requirements.txt | 2 +- + web/migrations/versions/c465fee44968_.py | 57 ++++++++++++++++++++++++ + web/pgadmin/__init__.py | 4 +- + web/pgadmin/browser/__init__.py | 6 +-- + web/pgadmin/model/__init__.py | 6 ++- + 6 files changed, 69 insertions(+), 7 deletions(-) + create mode 100644 web/migrations/versions/c465fee44968_.py + +diff --git a/requirements.txt b/requirements.txt +index ebdb1b21e..3ed3f7800 100644 +--- a/requirements.txt ++++ b/requirements.txt +@@ -29,7 +29,7 @@ psycopg2==2.8.* + python-dateutil==2.* + SQLAlchemy==1.3.* + itsdangerous<=1.1.0 +-Flask-Security-Too==3.* ++Flask-Security-Too==4.* + bcrypt==3.* + cryptography==3.* + sshtunnel==0.* +diff --git a/web/migrations/versions/c465fee44968_.py b/web/migrations/versions/c465fee44968_.py +new file mode 100644 +index 000000000..07459675d +--- /dev/null ++++ b/web/migrations/versions/c465fee44968_.py +@@ -0,0 +1,57 @@ ++ ++"""empty message ++ ++Revision ID: c465fee44968 ++Revises: d0bc9f32b2b9 ++Create Date: 2021-06-04 14:42:12.843116 ++ ++""" ++from pgadmin.model import db, User ++import uuid ++ ++ ++# revision identifiers, used by Alembic. ++revision = 'c465fee44968' ++down_revision = 'd0bc9f32b2b9' ++branch_labels = None ++depends_on = None ++ ++ ++def upgrade(): ++ db.engine.execute("ALTER TABLE user RENAME TO user_old") ++ ++ db.engine.execute(""" ++ CREATE TABLE user ( ++ id INTEGER NOT NULL, ++ username VARCHAR(256) NOT NULL, ++ email VARCHAR(256), ++ password VARCHAR(256), ++ active BOOLEAN NOT NULL, ++ confirmed_at DATETIME, ++ masterpass_check VARCHAR(256), ++ auth_source VARCHAR(256) NOT NULL DEFAULT 'internal', ++ fs_uniquifier NOT NULL UNIQUE, ++ PRIMARY KEY (id), ++ UNIQUE (username, auth_source, fs_uniquifier), ++ CHECK (active IN (0, 1)) ++ ); ++ """) ++ ++ user_old = db.engine.execute( ++ 'select id, username, email, password, active, ' ++ 'confirmed_at, masterpass_check, auth_source ' ++ 'from user_old') ++ ++ db.engine.execute(User.__table__.insert(), [ ++ { ++ **row, ++ 'fs_uniquifier': uuid.uuid4().hex ++ } for row in user_old ++ ]) ++ ++ db.engine.execute("DROP TABLE user_old") ++ ++ ++def downgrade(): ++ # pgAdmin only upgrades, downgrade not implemented. ++ pass +diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py +index 6e395f42f..dfc034c93 100644 +--- a/web/pgadmin/__init__.py ++++ b/web/pgadmin/__init__.py +@@ -305,7 +305,7 @@ def get_locale(): + if current_user.is_authenticated: + user_id = current_user.id + else: +- user = user_datastore.get_user(config.DESKTOP_USER) ++ user = user_datastore.find_user(email=config.DESKTOP_USER) + if user is not None: + user_id = user.id + user_language = Preferences.raw_value( +@@ -697,7 +697,7 @@ def before_request(): + abort(401) + + if not config.SERVER_MODE and not current_user.is_authenticated: +- user = user_datastore.get_user(config.DESKTOP_USER) ++ user = user_datastore.find_user(email=config.DESKTOP_USER) + # Throw an error if we failed to find the desktop user, to give + # the sysadmin a hint. We'll continue to try to login anyway as + # that'll through a nice 500 error for us. +diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py +index edbd491e7..d6cf78cac 100644 +--- a/web/pgadmin/browser/__init__.py ++++ b/web/pgadmin/browser/__init__.py +@@ -32,7 +32,7 @@ + from flask_security.signals import reset_password_instructions_sent + from flask_security.utils import config_value, do_flash, get_url, \ + get_message, slash_url_suffix, login_user, send_mail, logout_user +-from flask_security.views import _security, _commit, _ctx ++from flask_security.views import _security, view_commit, _ctx + from werkzeug.datastructures import MultiDict + + import config +@@ -1144,7 +1144,7 @@ def change_password(): + has_error = True + + if request.json is None and not has_error: +- after_this_request(_commit) ++ after_this_request(view_commit) + do_flash(*get_message('PASSWORD_CHANGE')) + + old_key = get_crypt_key()[1] +@@ -1310,7 +1310,7 @@ def reset_password(token): + has_error = True + + if not has_error: +- after_this_request(_commit) ++ after_this_request(view_commit) + do_flash(*get_message('PASSWORD_RESET')) + login_user(user) + return redirect(get_url(_security.post_reset_view) or +diff --git a/web/pgadmin/model/__init__.py b/web/pgadmin/model/__init__.py +index bd90077b7..3afef96eb 100644 +--- a/web/pgadmin/model/__init__.py ++++ b/web/pgadmin/model/__init__.py +@@ -20,6 +20,7 @@ + + from flask_security import UserMixin, RoleMixin + from flask_sqlalchemy import SQLAlchemy ++import uuid + + ########################################################################## + # +@@ -29,7 +30,7 @@ + # + ########################################################################## + +-SCHEMA_VERSION = 29 ++SCHEMA_VERSION = 30 + + ########################################################################## + # +@@ -76,6 +77,9 @@ class User(db.Model, UserMixin): + roles = db.relationship('Role', secondary=roles_users, + backref=db.backref('users', lazy='dynamic')) + auth_source = db.Column(db.String(16), unique=True, nullable=False) ++ # fs_uniquifier is required by flask-security-too >= 4. ++ fs_uniquifier = db.Column(db.String(255), unique=True, nullable=False, ++ default=(lambda _: uuid.uuid4().hex)) + + + class Setting(db.Model): diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD index f0d5c40..29c3af7 100644 --- a/trunk/PKGBUILD +++ b/trunk/PKGBUILD @@ -2,14 +2,13 @@ # Maintainer: Jerome Leclanche pkgname=pgadmin4 -pkgver=4.30 +pkgver=5.3 pkgrel=1 pkgdesc='Comprehensive design and management interface for PostgreSQL' url='https://www.pgadmin.org/' -arch=('x86_64') +arch=('any') license=('custom') -depends=('qt5-base' 'postgresql-libs' 'hicolor-icon-theme' 'python' - 'libxcrypt' 'libcrypt.so' 'glibc' 'gcc-libs' +depends=('postgresql-libs' 'hicolor-icon-theme' 'python' 'python-blinker' 'python-flask' 'python-flask-login' 'python-flask-migrate' 'python-flask-sqlalchemy' 'python-flask-wtf' 'python-passlib' 'python-pytz' 'python-simplejson' 'python-six' @@ -20,67 +19,60 @@ depends=('qt5-base' 'postgresql-libs' 'hicolor-icon-theme' 'python' 'python-flask-gravatar' 'python-flask-mail' 'python-flask-principal' 'python-flask-paranoid' 'python-sshtunnel' 'python-flask-security-too' 'python-werkzeug' 'python-flask-compress' 'python-ldap3' 'python-cryptography' - 'python-flask-babelex' 'python-gssapi') + 'python-flask-babelex' 'python-gssapi' 'python-email-validator') makedepends=('python-setuptools' 'python-sphinx' 'python-extras' 'python-fixtures' 'python-html5lib' 'python-pbr' 'python-mimeparse' 'python-pyrsistent' 'imagemagick') source=(https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${pkgver}/source/${pkgname}-${pkgver}.tar.gz{,.asc} + 065a3aa2f5a22024746419596de7de8dff34440c.patch pgAdmin4.desktop config_distro.py config_local.py - pgadmin4-python-de-vendor-venv-paths.patch) + test.patch) validpgpkeys=('E8697E2EEF76C02D3A6332778881B2A8210976F2') # Package Manager (Package Signing Key) -sha512sums=('7ce12f65ce9dbfe4af9e92dd7f9327a05be8b8436ef495a0634043158417f3af5f457b88ee5422ede59f517c197668094454c6d7b7c33e255068479ce6ec13d9' +sha512sums=('229a42c709c59e57408b2226c76301ddcde9b8ed045d6bb2faefdcfee9a3c9eee0e3a33e4a4be02004a3bdad35429f705d529ffd8969e81d98c1dec86e970f51' 'SKIP' + '74545f52cd59d4f3a34576701b2625c5bef2f5c0d1361675f9a2cb10f54c2b360282ad675ef9690d6965c6bc0515b522c6acc7af06e8422c0420eef9d23664f3' 'b19dda3331585010c759099eb09f4db288ce4cd3d36882b56748e1e3756dc7bee2899d7438d496280498ec6a60f6e1ba90309d49fc599403f1fdc7e8817b6645' '16d00dc2095904a6b12da7039458f632873829ad98d4d7653eac5804032ba92097ccae4488d56467d0ea9bd64e2654a3dead73eb7924c947ff1737ff6e3b4745' 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e' - 'a8c1a3762469b02b745da4e3b30f7534ad6bb94e91d43f7e63604fef24f638e09575e2c9336e753e5b6dbe167c55bb49fb6247a16431415318479eb3a3712adc') + 'a8c1a3762469b02b745da4e3b30f7534ad6bb94e91d43f7e63604fef24f638e09575e2c9336e753e5b6dbe167c55bb49fb6247a16431415318479eb3a3712adc' + 'b9a5382146f014576ae5aba880c552bcb1f9f6487005e112d60f3218cc421cfb076562cfa3d12cabecb0112723cbd7da637c9908c7fd4ec535d693e069550de5') prepare() { cd ${pkgname}-${pkgver} - patch -Np1 < ../pgadmin4-python-de-vendor-venv-paths.patch - - local PYTHONVERSION="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')" - sed -E "s|/usr/pgadmin4/web|/usr/lib/pgadmin4/web|g; - s|/usr/pgadmin4/lib/python[0-9\\.]+|/usr/lib/python${PYTHONVERSION}|g" \ - -i runtime/ConfigWindow.ui - sed "s|##PYTHONVERSION##|${PYTHONVERSION}|g" -i runtime/Server.cpp + patch -Np1 < ../065a3aa2f5a22024746419596de7de8dff34440c.patch + patch -Np1 < ../test.patch sed -E -i requirements.txt \ - -e '/blinker>?=/d' \ - -e '/extras>?=/d' \ + -e '/cheroot>?=/d' \ -e '/Flask>?=/d' \ + -e '/Flask-Gravatar>?=/d' \ -e '/Flask-Login>?=/d' \ + -e '/Flask-Mail>?=/d' \ -e '/Flask-Migrate>?=/d' \ -e '/Flask-SQLAlchemy>?=/d' \ -e '/Flask-WTF>?=/d' \ - -e '/pycrypto>?=/d' \ + -e '/Flask-Compress>?=/d' \ -e '/passlib>?=/d' \ -e '/pytz>?=/d' \ -e '/simplejson>?=/d' \ -e '/six>?=/d' \ - -e '/speaklater>?=/d' \ + -e '/speaklater3>?=/d' \ -e '/sqlparse>?=/d' \ -e '/WTForms>?=/d' \ + -e '/Flask-Paranoid>?=/d' \ -e '/psutil>?=/d' \ -e '/psycopg2>?=/d' \ -e '/python-dateutil>?=/d' \ -e '/SQLAlchemy>?=/d' \ - -e '/Flask-Gravatar>?=/d' \ - -e '/Flask-Mail>?=/d' \ - -e '/Flask-Principal>?=/d' \ - -e '/Flask-Paranoid>?=/d' \ - -e '/htmlmin>?=/d' \ + -e '/itsdangerous>??=/d' \ - -e '/Flask-HTMLmin>?=/d' \ - -e '/Flask-Compress>?=/d' \ - -e '/sshtunnel>?=/d' \ - -e '/Werkzeug>?=/d' \ - -e '/ldap3>?=/d' \ -e '/bcrypt>?????? -Date: Wed, 19 Dec 2018 01:10:25 +0100 -Subject: [PATCH] python: de-vendor venv paths - ---- - runtime/Server.cpp | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/runtime/Server.cpp b/runtime/Server.cpp -index f053cbb00..fd120f36a 100644 ---- a/runtime/Server.cpp -+++ b/runtime/Server.cpp -@@ -131,11 +131,11 @@ Server::Server(quint16 port, QString key, QString logFileName) - add_to_path(pythonHome, venvPath.canonicalFilePath()); - #else - // Build (and canonicalise) the virtual environment path -- QFileInfo venvBinPath(app_dir + "/../venv/bin"); -- QFileInfo venvLibPath(app_dir + "/../venv/lib/python"); -- QFileInfo venvDynLibPath(app_dir + "/../venv/lib/python/lib-dynload"); -- QFileInfo venvSitePackagesPath(app_dir + "/../venv/lib/python/site-packages"); -- QFileInfo venvPath(app_dir + "/../venv"); -+ QFileInfo venvBinPath("/usr/bin"); -+ QFileInfo venvLibPath("/usr/lib/python##PYTHONVERSION##"); -+ QFileInfo venvDynLibPath("/usr/lib/python##PYTHONVERSION##/lib-dynload"); -+ QFileInfo venvSitePackagesPath("/usr/lib/python##PYTHONVERSION##/site-packages"); -+ QFileInfo venvPath("/usr/lib/python##PYTHONVERSION##"); - - // Prepend the bin directory to the path - add_to_path(path_env, venvBinPath.canonicalFilePath(), true); --- -2.27.0 - diff --git a/trunk/test.patch b/trunk/test.patch new file mode 100644 index 0000000..539f47c --- /dev/null +++ b/trunk/test.patch @@ -0,0 +1,22 @@ +diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py +index 312b0ee..948663c 100644 +--- a/web/pgadmin/browser/utils.py ++++ b/web/pgadmin/browser/utils.py +@@ -13,7 +13,7 @@ from abc import abstractmethod + + import flask + from flask import render_template, current_app +-from flask.views import View, MethodViewType, with_metaclass ++from flask.views import View, MethodViewType + from flask_babelex import gettext + + from config import PG_DEFAULT_DRIVER +@@ -142,7 +142,7 @@ class PGChildModule(object): + pass + + +-class NodeView(with_metaclass(MethodViewType, View)): ++class NodeView(View,metaclass=MethodViewType): + """ + A PostgreSQL Object has so many operaions/functions apart from CRUD + (Create, Read, Update, Delete):