From c61489adfc2c1d7cc8aab384b17846ded6347edc Mon Sep 17 00:00:00 2001 From: Stefan Ubbink Date: Sun, 12 Mar 2023 13:11:20 +0100 Subject: [PATCH 1/7] Improve things for using PostgreSQL --- configs/development.py | 10 ++++++++++ docker-test/Dockerfile | 1 + docker/Dockerfile | 1 + docs/wiki/database-setup/Setup-PostgreSQL.md | 13 ++++--------- ...ning-PowerDNS-Admin-on-Ubuntu-or-Debian.md | 19 +++++++++++++++---- requirements.txt | 1 + 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/configs/development.py b/configs/development.py index 6d1dd0d..e92ac72 100644 --- a/configs/development.py +++ b/configs/development.py @@ -27,6 +27,7 @@ CAPTCHA_SESSION_KEY = 'captcha_image' SESSION_TYPE = 'sqlalchemy' ### DATABASE - MySQL +## Don't forget to uncomment the import in the top #SQLALCHEMY_DATABASE_URI = 'mysql://{}:{}@{}/{}'.format( # urllib.parse.quote_plus(SQLA_DB_USER), # urllib.parse.quote_plus(SQLA_DB_PASSWORD), @@ -34,6 +35,15 @@ SESSION_TYPE = 'sqlalchemy' # SQLA_DB_NAME #) +### DATABASE - PostgreSQL +## Don't forget to uncomment the import in the top +#SQLALCHEMY_DATABASE_URI = 'postgres://{}:{}@{}/{}'.format( +# urllib.parse.quote_plus(SQLA_DB_USER), +# urllib.parse.quote_plus(SQLA_DB_PASSWORD), +# SQLA_DB_HOST, +# SQLA_DB_NAME +#) + ### DATABASE - SQLite SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'pdns.db') diff --git a/docker-test/Dockerfile b/docker-test/Dockerfile index 17f934f..7191825 100644 --- a/docker-test/Dockerfile +++ b/docker-test/Dockerfile @@ -11,6 +11,7 @@ RUN apt-get update -y \ libffi-dev \ libldap2-dev \ libmariadb-dev-compat \ + libpq-dev \ libsasl2-dev \ libssl-dev \ libxml2-dev \ diff --git a/docker/Dockerfile b/docker/Dockerfile index b553998..55ccdfd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,6 +2,7 @@ FROM alpine:3.17 AS builder ARG BUILD_DEPENDENCIES="build-base \ libffi-dev \ + libpq-dev \ libxml2-dev \ mariadb-connector-c-dev \ openldap-dev \ diff --git a/docs/wiki/database-setup/Setup-PostgreSQL.md b/docs/wiki/database-setup/Setup-PostgreSQL.md index a6e3364..197aae5 100644 --- a/docs/wiki/database-setup/Setup-PostgreSQL.md +++ b/docs/wiki/database-setup/Setup-PostgreSQL.md @@ -15,10 +15,9 @@ The below will create a database called powerdnsadmindb and a user of powerdnsad ``` $ sudo su - postgres $ createuser powerdnsadmin -$ createdb powerdnsadmindb +$ createdb -E UTF8 -l en_US.UTF-8 -O powerdnsadmin -T template0 powerdnsadmindb 'The database for PowerDNS-Admin' $ psql -postgres=# alter user powerdnsadmin with encrypted password 'powerdnsadmin'; -postgres=# grant all privileges on database powerdnsadmindb to powerdnsadmin; +postgres=# ALTER ROLE powerdnsadmin WITH PASSWORD 'powerdnsadmin_password'; ``` Note: @@ -51,18 +50,14 @@ On debian based systems these files are located in: ## Install required packages: ### Red-hat based systems: +TODO: confirm this is correct ``` sudo yum install postgresql-libs ``` ### Debian based systems: ``` -apt install libpq-dev python-dev -``` - -### Install python packages: -``` -pip3 install psycopg2 +apt install python3-psycopg2 ``` ## Known Issues: diff --git a/docs/wiki/install/Running-PowerDNS-Admin-on-Ubuntu-or-Debian.md b/docs/wiki/install/Running-PowerDNS-Admin-on-Ubuntu-or-Debian.md index d3bc834..ad51c2b 100644 --- a/docs/wiki/install/Running-PowerDNS-Admin-on-Ubuntu-or-Debian.md +++ b/docs/wiki/install/Running-PowerDNS-Admin-on-Ubuntu-or-Debian.md @@ -7,19 +7,30 @@ First setup your database accordingly: ### Install required packages for building python libraries from requirements.txt file +For Debian 11 (bullseye) and above: ```bash -sudo apt install -y python3-dev git libsasl2-dev libldap2-dev libssl-dev libxml2-dev libxslt1-dev libxmlsec1-dev libffi-dev pkg-config apt-transport-https virtualenv build-essential curl +sudo apt install -y python3-dev git libsasl2-dev libldap2-dev python3-venv libmariadb-dev pkg-config build-essential curl libpq-dev +``` +Older systems might also need the following: +```bash +sudo apt install -y libssl-dev libxml2-dev libxslt1-dev libxmlsec1-dev libffi-dev apt-transport-https virtualenv ``` ### Install NodeJs ```bash -curl -sL https://deb.nodesource.com/setup_14.x | bash - -apt install -y nodejs +curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - +sudo apt install -y nodejs ``` ### Install yarn to build asset files - +For Debian 11 (bullseye) and above: +```bash +curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null +echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +sudo apt update && sudo apt install -y yarn +``` +For older Debian systems: ```bash sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list diff --git a/requirements.txt b/requirements.txt index 9753bf0..839c004 100644 --- a/requirements.txt +++ b/requirements.txt @@ -43,3 +43,4 @@ webcolors==1.12 werkzeug==2.1.2 zipp==3.11.0 rcssmin==1.1.1 +psycopg2==2.9.5 From 3e9e73fb3a50bf9fbf149924b8b03d9abeb80836 Mon Sep 17 00:00:00 2001 From: Stefan Ubbink Date: Sun, 12 Mar 2023 20:40:19 +0100 Subject: [PATCH 2/7] Change domain(s) to zone(s) in the templates --- .../templates/admin_edit_account.html | 14 +++++++------- powerdnsadmin/templates/admin_edit_key.html | 18 +++++++++--------- powerdnsadmin/templates/admin_edit_user.html | 4 ++-- .../templates/admin_global_search.html | 2 +- powerdnsadmin/templates/admin_history.html | 8 ++++---- .../templates/admin_manage_account.html | 2 +- powerdnsadmin/templates/admin_manage_keys.html | 2 +- powerdnsadmin/templates/admin_manage_user.html | 2 +- .../admin_setting_authentication.html | 4 ++-- powerdnsadmin/templates/dashboard.html | 2 +- powerdnsadmin/templates/domain_add.html | 6 +++--- powerdnsadmin/templates/domain_changelog.html | 6 +++--- powerdnsadmin/templates/domain_remove.html | 4 ++-- powerdnsadmin/templates/domain_setting.html | 18 +++++++++--------- 14 files changed, 46 insertions(+), 46 deletions(-) diff --git a/powerdnsadmin/templates/admin_edit_account.html b/powerdnsadmin/templates/admin_edit_account.html index 4894df8..ca08ab7 100644 --- a/powerdnsadmin/templates/admin_edit_account.html +++ b/powerdnsadmin/templates/admin_edit_account.html @@ -96,7 +96,7 @@
-

Users on the right have access to manage records in all domains +

Users on the right have access to manage records in all zones associated with the account.

Click on users to move between columns.

@@ -113,12 +113,12 @@
-

Domains on the right are associated with the account. Red marked domain names are +

Zones on the right are associated with the account. Red marked zone names are already associated with other accounts. - Moving already associated domains to this account will overwrite the previous + Moving already associated zones to this account will overwrite the previous associated account.

-

Hover over the red domain names to show the associated account. Click on domains to +

Hover over the red zone names to show the associated account. Click on zones to move between columns.