Girish Ramakrishnan 9 vuotta sitten
vanhempi
commit
b57bddbb1a
2 muutettua tiedostoa jossa 30 lisäystä ja 0 poistoa
  1. 1 0
      Dockerfile
  2. 29 0
      start.sh

+ 1 - 0
Dockerfile

@@ -12,6 +12,7 @@ RUN curl -o /app/code/wp https://raw.githubusercontent.com/wp-cli/builds/gh-page
 RUN chmod +x /app/code/wp
 
 # Get the plugins
+RUN curl -L -o /app/code/authLdap.zip https://github.com/gramakri/authLdap/zipfile/7ac3cbf4368d1ccaf4596db9aae1f9fe96d2b46c
 RUN curl -L -o /app/code/disable-wordpress-updates.zip https://downloads.wordpress.org/plugin/disable-wordpress-updates.1.4.7.zip
 RUN curl -L -o /app/code/wp-mail-smtp.zip https://downloads.wordpress.org/plugin/wp-mail-smtp.0.9.5.zip
 

+ 29 - 0
start.sh

@@ -42,6 +42,8 @@ if [[ -z "$(ls -A /app/data)" ]]; then
 
     $WP plugin install --activate --force /app/code/wp-mail-smtp.zip
     mv /app/data/wp-content/plugins/wp-mail-smtp /app/data/wp-content/mu-plugins/
+
+    $WP plugin install --activate --force /app/code/authLdap.zip
 else
     # Update wordpress
     $WP core update-db
@@ -59,6 +61,33 @@ $WP option update smtp_host ${MAIL_SMTP_SERVER}
 $WP option update smtp_port ${MAIL_SMTP_PORT}
 $WP option update smtp_auth false
 
+# configure LDAP
+# https://github.com/heiglandreas/authLdap/blob/master/authLdap.php#L644
+ldapConfig=$(cat <<EOF
+[
+    'Enabled'       => true,
+    'CachePW'       => false,
+    'URI'           => 'ldap://${LDAP_SERVER}:${LDAP_PORT}/${LDAP_USERS_BASE_DN}',
+    'Filter'        => '(uid=%s)',
+    'NameAttr'      => 'displayname',
+    'SecName'       => '',
+    'UidAttr'       => '', // 'uid'
+    'MailAttr'      => '', // 'mail'
+    'WebAttr'       => '',
+    'Groups'        => array([ 'administrator' => 'cn=admins,${LDAP_GROUPS_BASE_DN}' ]),
+    'Debug'         => false,
+    'GroupAttr'     => 'memberof',
+    'GroupFilter'   => '(&(objectClass=user)(uid=%s))',
+    'DefaultRole'   => 'editor',
+    'GroupEnable'   => true,
+    'GroupOverUser' => true,
+    'Version'       => 1
+]
+EOF
+)
+authLDAPOptions=$(echo "${ldapConfig}" | php5 -r 'echo serialize(eval("return " . file_get_contents("php://stdin") . ";"));')
+$WP option update authLDAPOptions "${authLDAPOptions}"
+
 chown -R www-data:www-data /app/data
 
 echo "Starting apache"