init
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Bruder 2019-04-12 12:27:43 +00:00
commit 3b272fa031
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
6 changed files with 159 additions and 0 deletions

13
.drone.yml Normal file
View file

@ -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

10
Dockerfile Normal file
View file

@ -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"]

44
assets/listing.css Normal file
View file

@ -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;
}

32
assets/listing.js Normal file
View file

@ -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
}
})
})

9
entrypoint.sh Executable file
View file

@ -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

51
httpd.conf Normal file
View file

@ -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"
<Directory "/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 "<script src=\"/directory-listing-assets/listing.js\"></script>"
AuthName "files"
AuthBasicProvider ldap
AuthType Basic
AuthLDAPURL "ldap://@@LDAP_SERVER@@/@@LDAP_BASE@@" "STARTTLS"
AuthLDAPBindDN "@@LDAP_USER@@"
AuthLDAPBindPassword "@@LDAP_PASSWORD@@"
Require valid-user
</Directory>
Alias "/directory-listing-assets" "/usr/local/apache2/conf/assets"
ErrorLog /proc/self/fd/2
LogLevel warn
TypesConfig conf/mime.types