Skip to content
Snippets Groups Projects
Commit a988e30c authored by Arie Peterson's avatar Arie Peterson
Browse files

Merge branch '94-add-smtp-configuration-options' into 'master'

Resolve "Add SMTP configuration options"

Closes #94

See merge request openappstack/wordpress-helm!58
parents 811bddcd b82fd552
No related branches found
No related tags found
1 merge request!58Resolve "Add SMTP configuration options"
Pipeline #9199 passed with stage
in 32 seconds
...@@ -117,6 +117,28 @@ openid_connect_settings: ...@@ -117,6 +117,28 @@ openid_connect_settings:
role_mapping_enabled: false role_mapping_enabled: false
role_key: roles role_key: roles
smtp_settings:
# Enable using these SMTP settings
enabled: false
# Username for SMTP authentication
smtp_user: admin@example.com
# Password for STMP authentication
smtp_pass: password
# Hostname of the mailserver
smtp_host: smtp.example.som
# SMTP from email address
smtp_from: admin@example.com
# SMTP from name
smtp_name: WordPress Admin
# SMTP port number - likely to be 25, 465 or 587
smtp_port: 587
# Encryption system to use - ssl or tls
smtp_secure: 'tls'
# Use SMTP authentication (true|false)
smtp_auth: true
# Can be set to 1 or 2 for debug logs
smtp_debug: 0
database: database:
auth: auth:
username: wordpress username: wordpress
......
...@@ -121,10 +121,6 @@ wordpress: ...@@ -121,10 +121,6 @@ wordpress:
theme_active: twentynineteen theme_active: twentynineteen
# Fallback theme from wordpress repo which is fetched + activated if helm reports an error # Fallback theme from wordpress repo which is fetched + activated if helm reports an error
theme_fallback: twentytwenty theme_fallback: twentytwenty
wp_content: wp_content:
## The directory to mount the files placed in wp-content. You shouldn't have to ## The directory to mount the files placed in wp-content. You shouldn't have to
## change this. ## change this.
...@@ -193,6 +189,18 @@ service: ...@@ -193,6 +189,18 @@ service:
type: ClusterIP type: ClusterIP
port: 8080 port: 8080
# See values-local.yaml.example for an explanation of these variables
smtp_settings:
enabled: false
smtp_user: admin@example.com
smtp_pass: password
smtp_host: smtp.example.com
smtp_from: admin@example.com
smtp_name: WordPress Admin
smtp_port: 587
smtp_secure: 'tls'
smtp_auth: true
smtp_debug: 0
## Dictionary with variables that are inserted into the wordpress-init default ## Dictionary with variables that are inserted into the wordpress-init default
## task. Feel free to override these if necessary ## task. Feel free to override these if necessary
...@@ -395,7 +403,6 @@ ansibleSecrets: | ...@@ -395,7 +403,6 @@ ansibleSecrets: |
scope: {{ .Values.openid_connect_settings.scope }} scope: {{ .Values.openid_connect_settings.scope }}
state_time_limit: {{ .Values.openid_connect_settings.state_time_limit }} state_time_limit: {{ .Values.openid_connect_settings.state_time_limit }}
role_key: {{ .Values.openid_connect_settings.role_key }} role_key: {{ .Values.openid_connect_settings.role_key }}
WP_SALTS: WP_SALTS:
AUTH_KEY: {{ .Values.wpSalts.AUTH_KEY | default ( randAlphaNum 32) }} AUTH_KEY: {{ .Values.wpSalts.AUTH_KEY | default ( randAlphaNum 32) }}
AUTH_SALT: {{ .Values.wpSalts.AUTH_SALT | default ( randAlphaNum 32) }} AUTH_SALT: {{ .Values.wpSalts.AUTH_SALT | default ( randAlphaNum 32) }}
...@@ -406,6 +413,18 @@ ansibleSecrets: | ...@@ -406,6 +413,18 @@ ansibleSecrets: |
SECURE_AUTH_KEY: {{ .Values.wpSalts.SECURE_AUTH_KEY | default ( randAlphaNum 32) }} SECURE_AUTH_KEY: {{ .Values.wpSalts.SECURE_AUTH_KEY | default ( randAlphaNum 32) }}
SECURE_AUTH_SALT: {{ .Values.wpSalts.SECURE_AUTH_SALT | default ( randAlphaNum 32) }} SECURE_AUTH_SALT: {{ .Values.wpSalts.SECURE_AUTH_SALT | default ( randAlphaNum 32) }}
WP_CACHE_KEY_SALT: {{ .Values.wpSalts.WP_CACHE_KEY_SALT | default ( randAlphaNum 32) }} WP_CACHE_KEY_SALT: {{ .Values.wpSalts.WP_CACHE_KEY_SALT | default ( randAlphaNum 32) }}
WP_SMTP_ENABLED: {{ .Values.smtp_settings.enabled }}
WP_SMTP_SETTINGS:
SMTP_USER: {{ .Values.smtp_settings.smtp_user }}
SMTP_PASS: {{ .Values.smtp_settings.smtp_pass }}
SMTP_HOST: {{ .Values.smtp_settings.smtp_host }}
SMTP_FROM: {{ .Values.smtp_settings.smtp_from }}
SMTP_NAME: {{ .Values.smtp_settings.smtp_name }}
SMTP_PORT: {{ .Values.smtp_settings.smtp_port }}
SMTP_SECURE: {{ .Values.smtp_settings.smtp_secure }}
WP_SMTP_RAW_SETTINGS:
SMTP_AUTH: {{ .Values.smtp_settings.smtp_auth }}
SMTP_DEBUG: {{ .Values.smtp_settings.smtp_debug }}
## Liveness and readiness probe values ## Liveness and readiness probe values
## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes
......
...@@ -179,8 +179,22 @@ ...@@ -179,8 +179,22 @@
- import_tasks: redis.yml - import_tasks: redis.yml
when: WP_REDIS_ENABLED when: WP_REDIS_ENABLED
- name: Write additional functions file
template:
src: templates/additional_functions.php
dest: "{{ wordpress_homedir }}/wp-includes/additional_functions.php"
- name: Extend functions.php file
lineinfile:
path: "{{ wordpress_homedir }}/wp-includes/functions.php"
regexp: '^require.+additional_functions.php'
line: require( ABSPATH . WPINC . '/additional_functions.php' );
- import_tasks: openid-connect.yml - import_tasks: openid-connect.yml
when: WP_OPENID_CONNECT_ENABLED when: WP_OPENID_CONNECT_ENABLED
- import_tasks: smtp.yml
when: WP_SMTP_ENABLED
- import_tasks: multilingual.yml - import_tasks: multilingual.yml
when: WP_MULTILINGUAL_ENABLED when: WP_MULTILINGUAL_ENABLED
--- ---
- name: Install openid connect plugin - name: Install openid connect plugin
shell: wp {{ cli_args }} plugin install daggerhart-openid-connect-generic --activate shell: wp {{ cli_args }} plugin install daggerhart-openid-connect-generic --activate
- name: Set openid connect plugin options - name: Set openid connect plugin options
command: wp {{ cli_args }} option set openid_connect_generic_settings --format=json '{{ WP_OPENID_CONNECT_SETTINGS | tojson }}' command: wp {{ cli_args }} option set openid_connect_generic_settings --format=json '{{ WP_OPENID_CONNECT_SETTINGS | tojson }}'
- name: Extend functions.php file
lineinfile:
path: "{{ wordpress_homedir }}/wp-includes/functions.php"
regexp: '^require.+additional_functions.php'
line: require( ABSPATH . WPINC . '/additional_functions.php' );
when: WP_OPENID_CONNECT_ROLE_MAPPING_ENABLED
- name: Copy additional functions file
template:
src: templates/additional_functions.php
dest: "{{ wordpress_homedir }}/wp-includes/additional_functions.php"
when: WP_OPENID_CONNECT_ROLE_MAPPING_ENABLED
- name: Define SMTP variables
command: wp {{ cli_args }} config set "{{ item.key }}" "{{ item.value }}" --add --type=constant
loop: "{{ WP_SMTP_SETTINGS | dict2items }}"
- name: Define SMTP variables
command: wp {{ cli_args }} config set "{{ item.key }}" "{{ item.value }}" --add --raw --type=constant
loop: "{{ WP_SMTP_RAW_SETTINGS | dict2items }}"
<?php <?php
{% if WP_OPENID_CONNECT_ROLE_MAPPING_ENABLED %}
add_action('openid-connect-generic-update-user-using-current-claim', function( $user, $user_claim) { add_action('openid-connect-generic-update-user-using-current-claim', function( $user, $user_claim) {
// Based on some data in the user_claim, modify the user. // Based on some data in the user_claim, modify the user.
if ( array_key_exists( '{{ WP_OPENID_CONNECT_SETTINGS.role_key }}', $user_claim ) ) { if ( array_key_exists( '{{ WP_OPENID_CONNECT_SETTINGS.role_key }}', $user_claim ) ) {
...@@ -10,3 +11,19 @@ add_action('openid-connect-generic-update-user-using-current-claim', function( $ ...@@ -10,3 +11,19 @@ add_action('openid-connect-generic-update-user-using-current-claim', function( $
} }
} }
}, 10, 2); }, 10, 2);
{% endif %}
{% if WP_SMTP_ENABLED %}
// SMTP Authentication
add_action( 'phpmailer_init', 'send_smtp_email' );
function send_smtp_email( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = SMTP_HOST;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = SMTP_PASS;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
$phpmailer->FromName = SMTP_NAME;
}
{% endif %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment