mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
e843a52a04
* [Docker] Create Lite docker-compose.yml example * [Docker] Update README.md with 3 compose bundles {Local,Lite,Full} * [DOCS] Update Traefik2 proxy example * [Docker] Create Local docker-compose.yml example * [MISC] Update examples to utilise Traefik 2.2 This change enables global http -> https redirection. * [Docker] Update Local compose to utilise loopback address * [Docker] Drop compose version to 3.3 to cater for more distros * [DOCS] Adjust Getting Started * [Docker] Tweak Local bundle setup for OSX * [Docker] Optimise setup.sh for Local bundle * [Docker] Fix read-only mounting of user database * [DOCS] Implement feedback for compose bundles * [DOCS] Provide feedback on self-signed certificates * [DOCS] Implement additional feedback for compose bundles Co-authored-by: Clément Michaud <clement.michaud34@gmail.com>
95 lines
2.8 KiB
Bash
Executable File
95 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
username(){
|
|
read -ep "Enter your username for Authelia: " USERNAME
|
|
}
|
|
|
|
password(){
|
|
read -esp "Enter a password for $USERNAME: " PASSWORD
|
|
}
|
|
|
|
echo "Checking for pre-requisites"
|
|
|
|
if [[ ! -x "$(command -v docker)" ]]; then
|
|
echo "You must install Docker on your machine";
|
|
return
|
|
fi
|
|
|
|
if [[ ! -x "$(command -v docker-compose)" ]]; then
|
|
echo "You must install Docker Compose on your machine";
|
|
return
|
|
fi
|
|
|
|
echo "Pulling Authelia docker image for setup"
|
|
docker pull authelia/authelia > /dev/null
|
|
|
|
read -ep "What root domain would you like to protect? (default/no selection is example.com): " DOMAIN
|
|
|
|
if [[ $DOMAIN == "" ]]; then
|
|
DOMAIN="example.com"
|
|
fi
|
|
|
|
MODIFIED=$(cat /etc/hosts | grep $DOMAIN && echo true || echo false)
|
|
|
|
if [[ $MODIFIED == "false" ]]; then
|
|
echo "\
|
|
127.0.0.1 authelia.$DOMAIN
|
|
127.0.0.1 public.$DOMAIN
|
|
127.0.0.1 traefik.$DOMAIN
|
|
127.0.0.1 secure.$DOMAIN" >> /etc/hosts
|
|
fi
|
|
|
|
echo "Generating SSL certificate for *.$DOMAIN"
|
|
docker run -a stdout -v $PWD/traefik/certs:/tmp/certs authelia/authelia authelia certificates generate --host *.$DOMAIN --dir /tmp/certs/ > /dev/null
|
|
|
|
if [[ $DOMAIN != "example.com" ]]; then
|
|
if [[ $(uname) == "Darwin" ]]; then
|
|
sed -i '' "s/example.com/$DOMAIN/g" {docker-compose.yml,configuration.yml}
|
|
else
|
|
sed -i "s/example.com/$DOMAIN/g" {docker-compose.yml,configuration.yml}
|
|
fi
|
|
fi
|
|
|
|
username
|
|
|
|
if [[ $USERNAME != "" ]]; then
|
|
if [[ $(uname) == "Darwin" ]]; then
|
|
sed -i '' "s/<USERNAME>/$USERNAME/g" users_database.yml
|
|
else
|
|
sed -i "s/<USERNAME>/$USERNAME/g" users_database.yml
|
|
fi
|
|
else
|
|
echo "Username cannot be empty"
|
|
username
|
|
fi
|
|
|
|
password
|
|
|
|
if [[ $PASSWORD != "" ]]; then
|
|
PASSWORD=$(docker run authelia/authelia authelia hash-password $PASSWORD | sed 's/Password hash: //g')
|
|
if [[ $(uname) == "Darwin" ]]; then
|
|
sed -i '' "s/<PASSWORD>/$(echo $PASSWORD | sed -e 's/[\/&]/\\&/g')/g" users_database.yml
|
|
else
|
|
sed -i "s/<PASSWORD>/$(echo $PASSWORD | sed -e 's/[\/&]/\\&/g')/g" users_database.yml
|
|
fi
|
|
else
|
|
echo "Password cannot be empty"
|
|
password
|
|
fi
|
|
|
|
docker-compose up -d
|
|
|
|
cat << EOF
|
|
Setup completed successfully.
|
|
|
|
You can now visit the following locations:
|
|
- https://public.$DOMAIN - Bypasses Authelia
|
|
- https://traefik.$DOMAIN - Secured with Authelia one-factor authentication
|
|
- https://secure.$DOMAIN - Secured with Authelia two-factor authentication (see note below)
|
|
|
|
You will need to authorize the self-signed certificate upon visiting each domain.
|
|
To visit https://secure.$DOMAIN you will need to register a device for second factor authentication and confirm by clicking on a link sent by email. Since this is a demo with a fake email address, the content of the email will be stored in './authelia/notification.txt'.
|
|
Upon registering, you can grab this link easily by running the following command: 'grep -Eo '"https://.*" ' ./authelia/notification.txt'.
|
|
EOF
|
|
|