commit 3b272fa0317b415366d9f6ce6066ed8ef97e40c6 Author: Simon Bruder Date: Fri Apr 12 12:27:43 2019 +0000 init diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..bd32ee2 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,13 @@ +kind: pipeline +name: default + +steps: +- name: docker + image: plugins/docker + settings: + registry: r.sbruder.de + username: + from_secret: docker_username + password: + from_secret: docker_password + repo: r.sbruder.de/httpd-ldap diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ac36743 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM httpd:alpine + +RUN mkdir /srv/www + +COPY assets /usr/local/apache2/conf/assets +COPY httpd.conf /usr/local/apache2/conf/httpd.conf + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/assets/listing.css b/assets/listing.css new file mode 100644 index 0000000..c4a0752 --- /dev/null +++ b/assets/listing.css @@ -0,0 +1,44 @@ +body, html { + background-color: #fdf6e3; + color: #657b83; + font-family: "TeX Gyre Heros", "Roboto", "Helvetica", "Arial", sans-serif; +} + +tr:nth-child(even) { + background: #eee8d5; +} + +th, td { + padding: 0.1em 0.5em; +} + +th { + text-align: left; + font-weight: bold; + background: #eee8d5; + border-bottom: 1px solid #657b83; +} + +a { + color: #586e75; +} + +a:hover { + color: #073642; +} + +table { + width: 100%; +} + +#search-field { + width: 100%; + border: none; + margin-bottom: 15px; + background: #eee8d5; + color: inherit; +} + +.indexbreakrow { + display: none; +} diff --git a/assets/listing.js b/assets/listing.js new file mode 100644 index 0000000..fd99307 --- /dev/null +++ b/assets/listing.js @@ -0,0 +1,32 @@ +document.addEventListener('DOMContentLoaded', () => { + let searchField = document.createElement('input') + searchField.id = 'search-field' + searchField.autofocus = true + document.querySelector('body').insertBefore(searchField, document.querySelector('table')) + + const rows = [...document.querySelectorAll('tr.even, tr.odd')] + + pdLink = rows[0].querySelector('.indexcolname a') + if (pdLink.innerText == 'Parent Directory') { + pdLink.href = '../' + pdLink.text = '..' + } + + document.querySelector('#search-field').addEventListener("input", e => { + const searchValue = e.target.value.toLowerCase() + rows.forEach(row => { + console.log(row) + const file = row.querySelector('.indexcolname a').innerText + if (!file.toLowerCase().startsWith(searchValue)) { + row.style.display = 'none' + } else { + row.style.display = 'table-row' + } + }) + + const visibleRows = [...document.querySelectorAll('tr[style="display: table-row;"]')] + if (visibleRows.length === 1) { + window.location = visibleRows[0].querySelector('td a').href + } + }) +}) diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..55898ba --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/ash +sed -i \ + -e "s/@@LDAP_SERVER@@/$LDAP_SERVER/" \ + -e "s/@@LDAP_BASE@@/$LDAP_BASE/" \ + -e "s/@@LDAP_USER@@/$LDAP_USER/" \ + -e "s/@@LDAP_PASSWORD@@/$LDAP_PASSWORD/" \ + /usr/local/apache2/conf/httpd.conf + +exec httpd-foreground diff --git a/httpd.conf b/httpd.conf new file mode 100644 index 0000000..c373814 --- /dev/null +++ b/httpd.conf @@ -0,0 +1,51 @@ +ServerRoot "/usr/local/apache2" +ServerName "localhost" +Listen 80 + +LoadModule mpm_event_module modules/mod_mpm_event.so + +LoadModule auth_basic_module modules/mod_auth_basic.so +LoadModule authn_core_module modules/mod_authn_core.so +LoadModule authnz_ldap_module modules/mod_authnz_ldap.so +LoadModule authz_core_module modules/mod_authz_core.so +LoadModule authz_user_module modules/mod_authz_user.so +LoadModule ldap_module modules/mod_ldap.so + +LoadModule mime_module modules/mod_mime.so +LoadModule unixd_module modules/mod_unixd.so +LoadModule autoindex_module modules/mod_autoindex.so +LoadModule alias_module modules/mod_alias.so + +User daemon +Group daemon + +DocumentRoot "/srv/www" + + Options Indexes FollowSymLinks + IndexOptions FancyIndexing + IndexOptions HTMLTable + IndexOptions SuppressColumnsorting + IndexOptions SuppressLastModified + IndexOptions SuppressDescription + IndexOptions SuppressHTMLPreamble + IndexOptions SuppressIcon + IndexStyleSheet "/directory-listing-assets/listing.css" + IndexHeadInsert "" + + AuthName "files" + AuthBasicProvider ldap + AuthType Basic + + AuthLDAPURL "ldap://@@LDAP_SERVER@@/@@LDAP_BASE@@" "STARTTLS" + AuthLDAPBindDN "@@LDAP_USER@@" + AuthLDAPBindPassword "@@LDAP_PASSWORD@@" + + Require valid-user + + +Alias "/directory-listing-assets" "/usr/local/apache2/conf/assets" + +ErrorLog /proc/self/fd/2 +LogLevel warn + +TypesConfig conf/mime.types