Skip to content

Commit

Permalink
dbc22-1643 Setup basic auth on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
wmuldergov committed Jan 26, 2024
1 parent 3eb5a25 commit f4df7b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compose/frontend/StaticBuild
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ COPY ./compose/frontend/default.conf /etc/nginx/conf.d
COPY --from=buildnode /app/build /usr/share/nginx/html
RUN chmod -R 777 /run /var/log/nginx /var/cache/nginx /usr/share/nginx/html/static/js

#THREE LINES BELOW ARE TEMPORARY FOR THE PRIVATE BETA
RUN mkdir -p /etc/apache2
RUN touch /etc/apache2/.htpasswd
RUN chmod -R 777 /etc/apache2/.htpasswd


ARG DEBUG_BUILD=false

# Add debugging tools into builds if enabled
Expand Down
2 changes: 2 additions & 0 deletions compose/frontend/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ server {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
auth_basic "Beta Site";
auth_basic_user_file /etc/apache2/.htpasswd;
}

# redirect server error pages to the static page /50x.html
Expand Down
10 changes: 10 additions & 0 deletions compose/frontend/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ echo -e "window.GEOCODER_API_AUTH_KEY='${REACT_APP_GEOCODER_API_AUTH_KEY}';" >>
echo -e "window.ROUTE_PLANNER='${REACT_APP_ROUTE_PLANNER}';" >> $MAIN
echo -e "window.ROUTE_PLANNER_KEY='${REACT_APP_ROUTE_PLANNER_KEY}';" >> $MAIN
echo -e "window.REPLAY_THE_DAY='${REACT_APP_REPLAY_THE_DAY}';" >> $MAIN

#FOLLOWING SECTION IS TEMPORARY FOR THE PRIVATE BETA
# Check if $ENVIRONMENT is not set to "Prod". If it is prod we want to keep these lines
if [ "$ENV" != "Prod" ]; then
# Remove the specified lines from nginx.conf
sed -i '/auth_basic "Beta Site";/d' /etc/nginx/conf.d
sed -i '/auth_basic_user_file \/etc\/apache2\/.htpasswd;/d' /etc/nginx/conf.d
fi
#Copy the content of the secret into the .htpasswd file.
echo "$TEMP_AUTH_SECRET" >> /etc/apache2/.htpasswd

0 comments on commit f4df7b8

Please sign in to comment.