inm-icf-utilities/.appveyor/apache_enable_authentication
Christian Monch 672c08dff2 simplify authentication realm name
This commit simplifies the authorization
name, i.e. it removes spaces and sets it
to 'Restricted'.
2023-05-30 09:23:50 +02:00

28 lines
540 B
Bash
Executable file

#!/bin/bash
set -e -u
studies_dir="$1"; shift
user="$1"; shift
password="$1"; shift
sudo htpasswd -bc /var/www/passwords "$user" "$password"
temp_htaccess=$(mktemp)
cat > "$temp_htaccess" <<EOF
AuthType Basic
AuthName "Restricted"
AuthBasicProvider file
AuthUserFile "/var/www/passwords"
Require user test.user
EOF
while [ "$*" ]; do
echo Setting access restrictions for "$studies_dir"/"$1"
sudo cp "$temp_htaccess" "$studies_dir"/"$1"/.htaccess
sudo chmod 644 "$studies_dir"/"$1"/.htaccess
shift
done
rm -f "$temp_htaccess"