Added OIDC draft für wordpress

This commit is contained in:
2025-04-17 11:51:37 +02:00
parent 7d5d69c380
commit 7e24d9b1c3
18 changed files with 91 additions and 33 deletions

View File

@@ -1,12 +1,15 @@
FROM wordpress
# Update and installation of msmtp
# Install msmtp and update system
RUN apt-get update && \
apt-get install -y msmtp msmtp-mta && \
rm -rf /var/lib/apt/lists/*
# Copy the msmtp configuration into the container
COPY config/msmtprc.conf /etc/msmtprc
# Install WP CLI
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
chmod +x wp-cli.phar && \
mv wp-cli.phar /usr/local/bin/wp
# Copy the PHP configuration for uploads (and mail settings)
# Copy msmtp configuration and PHP upload settings
COPY config/msmtprc.conf /etc/msmtprc
COPY upload.ini $PHP_INI_DIR/conf.d/

View File

@@ -0,0 +1,12 @@
- name: "{{ role_name }} | Run WordPress core install via WP CLI"
command: >
docker-compose exec -T -u www-data application
wp core install
--url="https://{{ domains[application_id][0] }}"
--title="{{ applications[application_id].title }}"
--admin_user="{{ applications[application_id].credentials.administrator.username }}"
--admin_password="{{ applications[application_id].credentials.administrator.password }}"
--admin_email="{{ applications[application_id].credentials.administrator.email }}"
--path="{{ wordpress_docker_html_path }}"
args:
chdir: "{{ docker_compose.directories.instance }}"

View File

@@ -1,9 +1,9 @@
---
- name: "include docker-central-database"
- name: "{{ role_name }} | Include docker-central-database"
include_role:
name: docker-central-database
- name: "include role nginx-domain-setup for {{ application_id }}"
- name: "{{ role_name }} | Include role nginx-domain-setup for {{ application_id }}"
include_role:
name: nginx-domain-setup
loop: "{{ domains.wordpress }}"
@@ -13,23 +13,30 @@
nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size {{ wordpress_max_upload_size }};"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "Transfering upload.ini to {{ docker_compose.directories.instance }}"
- name: "{{ role_name }} | Transfering upload.ini to {{ docker_compose.directories.instance }}"
template:
src: upload.ini.j2
dest: "{{ docker_compose.directories.instance }}upload.ini"
notify: docker compose project build and setup
- name: "Transfering msmtprc to {{ host_msmtp_conf }}"
- name: "{{ role_name }} | Transfering msmtprc to {{ host_msmtp_conf }}"
template:
src: "{{ playbook_dir }}/roles/msmtp/templates/msmtprc.conf.j2"
dest: "{{ host_msmtp_conf }}"
notify: docker compose project build and setup
- name: "Transfering Dockerfile to {{ docker_compose.directories.instance }}"
- name: "{{ role_name }} | Transfering Dockerfile to {{ docker_compose.directories.instance }}"
copy:
src: Dockerfile
dest: "{{ docker_compose.directories.instance }}Dockerfile"
notify: docker compose project build and setup
- name: "copy docker-compose.yml and env file"
- name: "{{ role_name }} | copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- name: "{{ role_name }} | Install wordpress"
include_tasks: install.yml
- name: "{{ role_name }} | Activating OIDC when enabled."
include_tasks: oidc.yml
when: applications[application_id].oidc.enabled | bool

View File

@@ -0,0 +1,16 @@
---
- name: "{{ role_name }} | Install OpenID Connect Generic Plugin via WP CLI"
command: >
docker-compose exec -u www-data -T application
wp plugin install daggerhart-openid-connect-generic
--path={{ wordpress_docker_html_path }}
args:
chdir: "{{ docker_compose.directories.instance }}"
- name: "{{ role_name }} | Activate OpenID Connect Generic Plugin"
command: >
docker-compose exec -u www-data -T application
wp plugin activate daggerhart-openid-connect-generic
--path={{ wordpress_docker_html_path }}
args:
chdir: "{{ docker_compose.directories.instance }}"

View File

@@ -4,14 +4,14 @@ services:
application:
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
image: {{custom_wordpress_image}}
image: {{wordpress_custom_image}}
container_name: wordpress-application
build:
context: .
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
volumes:
- data:/var/www/html
- data:{{ wordpress_docker_html_path }}
{% include 'roles/docker-compose/templates/services/msmtp_curl_test.yml.j2' %}

View File

@@ -1,4 +1,15 @@
WORDPRESS_DB_HOST= "{{database_host}}:{{database_port}}"
WORDPRESS_DB_USER= "{{database_username}}"
WORDPRESS_DB_PASSWORD= "{{database_password}}"
WORDPRESS_DB_NAME= "{{database_name}}"
WORDPRESS_DB_NAME= "{{database_name}}"
{% if applications[application_id].oidc.enabled | bool %}
# OIDC Configuration (loaded if OIDC is enabled)
# @see https://github.com/oidc-wp/openid-connect-generic/blob/develop/includes/openid-connect-generic-option-settings.php
OIDC_CLIENT_ID={{ oidc.client.id }}
OIDC_CLIENT_SECRET={{ oidc.client.secret }}
OIDC_ENDPOINT_LOGOUT_URL={{ oidc.client.logout_url }}
OIDC_ENDPOINT_LOGIN_URL={{ oidc.client.authorize_url }}
OIDC_ENDPOINT_TOKEN_URL={{ oidc.client.token_url }}
OIDC_ENDPOINT_USERINFO_URL={{ oidc.client.user_info_url }}
{% endif %}

View File

@@ -1,6 +1,7 @@
application_id: "wordpress"
wordpress_max_upload_size: "64M"
database_type: "mariadb"
database_password: "{{wordpress_database_password}}"
custom_wordpress_image: "custom_wordpress"
database_password: "{{applications[application_id].credentials.database.password}}"
wordpress_custom_image: "wordpress_custom"
wordpress_docker_html_path: "/var/www/html"
host_msmtp_conf: "{{docker_compose.directories.config}}msmtprc.conf"