Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented helper for password reset #1043

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ ENV HASHTOPOLIS_LOG_PATH=${HASHTOPOLIS_PATH}/log
ENV HASHTOPOLIS_CONFIG_PATH=${HASHTOPOLIS_PATH}/config
ENV HASHTOPOLIS_BINARIES_PATH=${HASHTOPOLIS_PATH}/binaries

ENV HASHTOPOLIS_SSMTP_ENABLE=0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a little bit confusing to put all the environment variabels here instead out of the .env file. since the env.example file now also have these environment variables but from there they are never used.

Personally I would say an even better solution would be to instead of using environment variables, is to create a ssmtp.conf template here and let the user fill that in. Then in the docker file it can be transferred like "COPY ssmtp-template.conf /etc/ssmtp/ssmtp.conf". That way the user has more flexibility in setting up the ssmtp configuration and is not limited to the few environment variables.

ENV [email protected]
ENV HASHTOPOLIS_SSMTP_MAILHUB=example.org:465
ENV HASHTOPOLIS_SSMTP_HOSTNAME=hashtopolis.example.org
ENV HASHTOPOLIS_SSMTP_USE_TLS=Yes
ENV HASHTOPOLIS_SSMTP_USE_STARTTLS=No
ENV HASHTOPOLIS_SSMTP_AUTH_USER=xxxx
ENV HASHTOPOLIS_SSMTP_AUTH_PASS=xxxx

# Add support for TLS inspection corporate setups, see .env.sample for details
ENV NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt

Expand All @@ -39,6 +48,7 @@ RUN apt-get update \
&& apt-get -y install git iproute2 procps lsb-release \
&& apt-get -y install mariadb-client \
&& apt-get -y install libpng-dev \
&& apt-get -y install ssmtp sudo \
\
# Install extensions (optional)
&& docker-php-ext-install pdo_mysql gd \
Expand Down Expand Up @@ -77,6 +87,11 @@ COPY --from=preprocess /HEA[D] ${HASHTOPOLIS_DOCUMENT_ROOT}/../.git/
COPY composer.json ${HASHTOPOLIS_DOCUMENT_ROOT}/../
RUN composer install --working-dir=${HASHTOPOLIS_DOCUMENT_ROOT}/..

RUN echo "www-data ALL=NOPASSWD:SETENV: /usr/local/bin/second-level-docker-entry.sh" >> /etc/sudoers.d/10_docker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like mentioned, I think www-data here should be replaced by vscode. But im not 100% sure

COPY second-level-docker-entry.sh /usr/local/bin

RUN echo "" > /etc/ssmtp/ssmtp.conf

ENV DEBIAN_FRONTEND=dialog
COPY docker-entrypoint.sh /usr/local/bin

Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ services:
HASHTOPOLIS_ADMIN_USER: $HASHTOPOLIS_ADMIN_USER
HASHTOPOLIS_ADMIN_PASSWORD: $HASHTOPOLIS_ADMIN_PASSWORD
HASHTOPOLIS_APIV2_ENABLE: $HASHTOPOLIS_APIV2_ENABLE

HASHTOPOLIS_SSMTP_ENABLE: $HASHTOPOLIS_SSMTP_ENABLE
HASHTOPOLIS_SSMTP_ROOT: $HASHTOPOLIS_SSMTP_ROOT
HASHTOPOLIS_SSMTP_MAILHUB: $HASHTOPOLIS_SSMTP_MAILHUB
HASHTOPOLIS_SSMTP_HOSTNAME: $HASHTOPOLIS_SSMTP_HOSTNAME
HASHTOPOLIS_SSMTP_USE_TLS: $HASHTOPOLIS_SSMTP_USE_TLS
HASHTOPOLIS_SSMTP_USE_STARTTLS: $HASHTOPOLIS_SSMTP_USE_STARTTLS
HASHTOPOLIS_SSMTP_AUTH_USER: $HASHTOPOLIS_SSMTP_AUTH_USER
HASHTOPOLIS_SSMTP_AUTH_PASS: $HASHTOPOLIS_SSMTP_AUTH_PASS
depends_on:
- db
ports:
Expand Down
3 changes: 3 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ for path in ${paths[@]}; do
fi
done

echo "Running required root setups."
sudo -E /usr/local/bin/second-level-docker-entry.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me this will give the following errors:

sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required

I think the reason for this error is because the user that executes entrypoint script is vscode and not www-data


echo "Testing database."
MYSQL="mysql -u${HASHTOPOLIS_DB_USER} -p${HASHTOPOLIS_DB_PASS} -h ${HASHTOPOLIS_DB_HOST}"
$MYSQL -e "SELECT 1" > /dev/null 2>&1
Expand Down
9 changes: 9 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ HASHTOPOLIS_DB_HOST=db

HASHTOPOLIS_APIV2_ENABLE=0
HASHTOPOLIS_BACKEND_URL=http://localhost:8080/api/v2

HASHTOPOLIS_SSMTP_ENABLE=0
[email protected]
HASHTOPOLIS_SSMTP_MAILHUB=example.org:465
HASHTOPOLIS_SSMTP_HOSTNAME=hashtopolis.example.org
HASHTOPOLIS_SSMTP_USE_TLS=Yes
HASHTOPOLIS_SSMTP_USE_STARTTLS=No
HASHTOPOLIS_SSMTP_AUTH_USER=username
HASHTOPOLIS_SSMTP_AUTH_PASS=password
16 changes: 16 additions & 0 deletions second-level-docker-entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# set up SSMTP config
if [[ $HASHTOPOLIS_SSMTP_ENABLE == 1 ]]; then
echo "Setting up SSMTP config..."
echo -e "\
root=${HASHTOPOLIS_SSMTP_ROOT}\n\
mailhub=${HASHTOPOLIS_SSMTP_MAILHUB}\n\
hostname=${HASHTOPOLIS_SSMTP_HOSTNAME}\n\
UseTLS=${HASHTOPOLIS_SSMTP_USE_TLS}\n\
UseSTARTTLS=${HASHTOPOLIS_SSMTP_USE_STARTTLS}\n\
AuthUser=${HASHTOPOLIS_SSMTP_AUTH_USER}\n\
AuthPass=${HASHTOPOLIS_SSMTP_AUTH_PASS}\n\
FromLineOverride=NO\n\
#Debug=YES\n" > /etc/ssmtp/ssmtp.conf
fi
1 change: 1 addition & 0 deletions src/inc/apiv2/helper/resetUserPassword.routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function getFormFields(): array {
public function actionPost($data): array|null {
UserUtils::userForgotPassword($data[User::USERNAME], $data[User::EMAIL]);

# TODO: Check how to handle custom return messages that are not object, probably we want that to be in some kind of standardized form.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have a standardized way so this comment can be removed

return ["reset" => "success"];
}
}
Expand Down
Loading