Skip to content

Commit

Permalink
Cleanup and adding mild documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
bertrama committed Nov 5, 2024
1 parent 521eea8 commit 6071acc
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ FROM php:8.3-apache

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y jq ldap-utils libapache2-mod-authnz-external libapache2-mod-auth-openidc git \
&& apt-get install -y jq ldap-utils libapache2-mod-authnz-external libapache2-mod-auth-openidc git unzip \
&& apt-get clean \
&& (apt-get distclean || rm -rf /var/cache/apt/archives /var/lib/apt/lists/*) \
&& a2enmod authnz_ldap \
&& mkdir -p /var/cache/apache2/mod_auth_openidc/oidc-sessions /var/cache/apache2/twig /var/www/lib \
&& chown www-data:www-data /var/cache/apache2/mod_auth_openidc/oidc-sessions /var/cache/apache2/twig \
&& docker-php-ext-install pdo_mysql \
&& php -r "copy('https://getcomposer.org/download/2.7.9/composer.phar', '/usr/local/bin/composer');" \
&& php -r "copy('https://getcomposer.org/download/latest-stable/composer.phar', '/usr/local/bin/composer');" \
&& chmod +x /usr/local/bin/composer

COPY auth_openidc.conf /etc/apache2/mods-enabled/auth_openidc.conf
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Check example.env for environment variables to set.


```
docker-compose build
# Start the webserver and database server
docker-compose up -d
# Optional: Load data
docker-compose exec -T db bash -c 'mysql -u "$MARIADB_USER" -p"$MARIADB_PASSWORD" "$MARIADB_DATABASE"' < data.sql
```
31 changes: 22 additions & 9 deletions bin/update-ldap
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
TMPFILE=$(mktemp -p /tmp "update.ldif.XXXXXXXX")

username="$1"
directory_file="$2"
directory_file="https://cms.lib.umich.edu/api/solr/staff"
ldap_host="ldap://ldap.umich.edu"

if [ x"$username" = x"" ] ; then
echo "usage: $0 <username> <staff-directory-json-file>"
echo "usage: $0 <username>"
echo
echo "<username> is your uniqname"
echo "<staff-directory-json-file> is https://staff.lib.umich.edu/staff-directory.json"
exit 1
fi

Expand All @@ -19,14 +19,27 @@ changetype: modify
replace: member
EOF

for i in $(jq '.[] | .uniqname' "${directory_file}" | sed -e 's/"//g') ; do

for i in $(curl -s $directory_file| jq '.[].name[].value' | sed -e 's/"//g') ; do
echo "member: uid=$i,ou=People,dc=umich,dc=edu" >> $TMPFILE
done

ldapmodify \
-H ldap://ldap.umich.edu \
-f "${TMPFILE}"\
-D "uid=${username},ou=People,dc=umich,dc=edu" \
-W
echo "Check the line count below before entering your password."
echo
echo -n " "
wc -l "${TMPFILE}"
echo

if [ x"$(wc -l "${TMPFILE}" | awk '{print $1}')" = x"3" ] ; then
echo "No members in '${TMPFILE}'"
echo "Cowardly not updating the acls group due to uncertainty."
exit 2
else
ldapmodify \
-H "${ldap_host}" \
-f "${TMPFILE}" \
-D "uid=${username},ou=People,dc=umich,dc=edu" \
-W
fi

rm "${TMPFILE}"
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
- .env
volumes:
- "db:/var/lib/mysql"
- "./db/init-data.sql:/docker-entrypoint-initdb.d/init-data.sql"
- "./db/init-data-tables.sql:/docker-entrypoint-initdb.d/init-data.sql"

volumes:
db:
2 changes: 1 addition & 1 deletion example.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# These get picked up by the apache configuration.
# Get them from A&E or ITS as appropriate.
OIDC_REDIRECT_URI=
OIDC_PROVIDER_METADATA_URL=
OIDC_CLIENT_ID=
Expand All @@ -8,7 +9,6 @@ OIDC_CRYPTO_PASSPHRASE=
# The DB_DRIVER is used to decide which variables to look at for the DB_HOST DB_USER
# values, etc.
DB_DRIVER=MARIADB
# MARIADB_HOST
MARIADB_HOST=db
MARIADB_USER=callnumber
MARIADB_PASSWORD=callnumber
Expand Down

0 comments on commit 6071acc

Please sign in to comment.