Skip to content

Hass.io Authentication Modules for Home Assistant

License

Notifications You must be signed in to change notification settings

pvizeli/hassio-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authorize helpers for Home Assistant user system

Nginx-Frontend

WORKDIR /usr/src

ARG HASSIO_AUTH_VERSION
RUN apk add --no-cache \
        nginx nginx-mod-http-lua lua-resty-http \
    && git clone --depth 1 -b $HASSIO_AUTH_VERSION https://github.com/home-assistant/hassio-auth \
    && cp -f hassio-auth/nginx-frontend/ha-auth.lua /etc/nginx/ \
    && rm -r /usr/src/hassio-auth
WAIT_PIDS=()
PORT=8431

if [ "$SSL" == "true" ];
    sed -i "s/%%PORT%%/${PORT}/g" /etc/nginx/nginx-ssl.conf
    sed -i "s/%%CERTFILE%%/${CERTFILE}/g" /etc/nginx/nginx-ssl.conf
    sed -i "s/%%KEYFILE%%/${KEYFILE}/g" /etc/nginx/nginx-ssl.conf

    nginx -c /etc/nginx/nginx-ssl.conf &
else
    sed -i "s/%%PORT%%/${PORT}/g" /etc/nginx/nginx.conf

    nginx -c /etc/nginx/nginx.conf &
fi
WAIT_PIDS+=($!)

# Register stop
function stop_addon() {
    echo "Kill Processes..."
    kill -15 "${WAIT_PIDS[@]}"
    wait "${WAIT_PIDS[@]}"
    echo "Done."
}
trap "stop_addon" SIGTERM SIGHUP

# Wait until all is done
wait "${WAIT_PIDS[@]}"

PAM

WORKDIR /usr/src

ARG HASSIO_AUTH_VERSION
RUN apk add --no-cache \
        musl libcurl linux-pam \
    && apk add --no-cache --virtual .build-dependencies \
        musl-dev curl-dev linux-pam-dev gcc git make \
    && git clone --depth 1 -b $HASSIO_AUTH_VERSION https://github.com/home-assistant/hassio-auth \
    && cd hassio-auth/pam \
    && make \
    && cp -f pam_hassio.so /lib/security/ \
    && apk del .build-dependencies \
    && rm -r /usr/src/hassio-auth