mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 10:32:57 +01:00
Merge pull request #3480 from rommapp/fix/unauthenticated-asset-exposure
fix: stop serving private user assets via unauthenticated nginx static route
This commit is contained in:
@@ -181,8 +181,7 @@ COPY --from=frontend-build /front/dist ${WEBSERVER_FOLDER}
|
||||
|
||||
COPY ./frontend/assets ${WEBSERVER_FOLDER}/assets
|
||||
RUN mkdir -p ${WEBSERVER_FOLDER}/assets/romm && \
|
||||
ln -sf /romm/resources ${WEBSERVER_FOLDER}/assets/romm/resources && \
|
||||
ln -sf /romm/assets ${WEBSERVER_FOLDER}/assets/romm/assets
|
||||
ln -sf /romm/resources ${WEBSERVER_FOLDER}/assets/romm/resources
|
||||
COPY ./backend /backend
|
||||
|
||||
# Setup init script and config files
|
||||
|
||||
@@ -61,18 +61,17 @@ fi
|
||||
# Replace environment variables used in nginx configuration templates.
|
||||
/docker-entrypoint.d/20-envsubst-on-templates.sh >/dev/null
|
||||
|
||||
# Fix symbolic links used by nginx for assets, if they do not point to the correct location,
|
||||
# Fix symbolic links used by nginx for resources,
|
||||
# if they don't point to the correct location,
|
||||
# set by the ROMM_BASE_PATH environment variable.
|
||||
for subfolder in assets resources; do
|
||||
if [[ -L /var/www/html/assets/romm/${subfolder} ]]; then
|
||||
target=$(readlink "/var/www/html/assets/romm/${subfolder}")
|
||||
if [[ -L /var/www/html/assets/romm/resources ]]; then
|
||||
target=$(readlink "/var/www/html/assets/romm/resources")
|
||||
|
||||
# If the target is not the same as ${ROMM_BASE_PATH}/${subfolder}, recreate the symbolic link.
|
||||
if [[ ${target} != "${ROMM_BASE_PATH}/${subfolder}" ]]; then
|
||||
rm "/var/www/html/assets/romm/${subfolder}"
|
||||
ln -s "${ROMM_BASE_PATH}/${subfolder}" "/var/www/html/assets/romm/${subfolder}"
|
||||
fi
|
||||
# If the target is not the same as ${ROMM_BASE_PATH}/resources, recreate the symbolic link.
|
||||
if [[ ${target} != "${ROMM_BASE_PATH}/resources" ]]; then
|
||||
rm "/var/www/html/assets/romm/resources"
|
||||
ln -s "${ROMM_BASE_PATH}/resources" "/var/www/html/assets/romm/resources"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
||||
@@ -5,21 +5,19 @@ set -e
|
||||
echo "Starting entrypoint script..."
|
||||
|
||||
# Create symlinks for frontend
|
||||
for subfolder in assets resources; do
|
||||
if [[ -L /app/frontend/assets/romm/${subfolder} ]]; then
|
||||
target=$(readlink "/app/frontend/assets/romm/${subfolder}")
|
||||
if [[ -L /app/frontend/assets/romm/resources ]]; then
|
||||
target=$(readlink "/app/frontend/assets/romm/resources")
|
||||
|
||||
# If the target is not the same as ${ROMM_BASE_PATH}/${subfolder}, recreate the symbolic link.
|
||||
if [[ ${target} != "${ROMM_BASE_PATH}/${subfolder}" ]]; then
|
||||
rm "/app/frontend/assets/romm/${subfolder}"
|
||||
ln -s "${ROMM_BASE_PATH}/${subfolder}" "/app/frontend/assets/romm/${subfolder}"
|
||||
fi
|
||||
elif [[ ! -e /app/frontend/assets/romm/${subfolder} ]]; then
|
||||
# Ensure parent directory exists before creating symbolic link
|
||||
mkdir -p "/app/frontend/assets/romm"
|
||||
ln -s "${ROMM_BASE_PATH}/${subfolder}" "/app/frontend/assets/romm/${subfolder}"
|
||||
# If the target is not the same as ${ROMM_BASE_PATH}/resources, recreate the symbolic link.
|
||||
if [[ ${target} != "${ROMM_BASE_PATH}/resources" ]]; then
|
||||
rm "/app/frontend/assets/romm/resources"
|
||||
ln -s "${ROMM_BASE_PATH}/resources" "/app/frontend/assets/romm/resources"
|
||||
fi
|
||||
done
|
||||
elif [[ ! -e /app/frontend/assets/romm/resources ]]; then
|
||||
# Ensure parent directory exists before creating symbolic link
|
||||
mkdir -p "/app/frontend/assets/romm"
|
||||
ln -s "${ROMM_BASE_PATH}/resources" "/app/frontend/assets/romm/resources"
|
||||
fi
|
||||
|
||||
# Define a signal handler to propagate termination signals
|
||||
function handle_termination() {
|
||||
|
||||
@@ -65,7 +65,7 @@ function closeDialog() {
|
||||
<v-img
|
||||
:src="
|
||||
user.avatar_path
|
||||
? `/assets/romm/assets/${user.avatar_path}?ts=${user.updated_at}`
|
||||
? `/api/raw/assets/${user.avatar_path}?ts=${user.updated_at}`
|
||||
: defaultAvatarPath
|
||||
"
|
||||
/> </v-avatar
|
||||
|
||||
@@ -158,7 +158,7 @@ function closeDialog() {
|
||||
:src="
|
||||
imagePreviewUrl ||
|
||||
(user.avatar_path
|
||||
? `/assets/romm/assets/${user.avatar_path}?ts=${user.updated_at}`
|
||||
? `/api/raw/assets/${user.avatar_path}?ts=${user.updated_at}`
|
||||
: defaultAvatarPath)
|
||||
"
|
||||
>
|
||||
|
||||
@@ -136,7 +136,7 @@ onMounted(() => {
|
||||
<v-img
|
||||
:src="
|
||||
item.avatar_path
|
||||
? `/assets/romm/assets/${item.avatar_path}?ts=${item.updated_at}`
|
||||
? `/api/raw/assets/${item.avatar_path}?ts=${item.updated_at}`
|
||||
: defaultAvatarPath
|
||||
"
|
||||
/>
|
||||
|
||||
@@ -92,7 +92,7 @@ function onClose() {
|
||||
<v-img
|
||||
:src="
|
||||
user?.avatar_path
|
||||
? `/assets/romm/assets/${user?.avatar_path}?ts=${user?.updated_at}`
|
||||
? `/api/raw/assets/${user?.avatar_path}?ts=${user?.updated_at}`
|
||||
: defaultAvatarPath
|
||||
"
|
||||
cover
|
||||
|
||||
@@ -25,7 +25,7 @@ const { smAndDown } = useDisplay();
|
||||
<v-img
|
||||
:src="
|
||||
user?.avatar_path
|
||||
? `/assets/romm/assets/${user?.avatar_path}?ts=${user?.updated_at}`
|
||||
? `/api/raw/assets/${user?.avatar_path}?ts=${user?.updated_at}`
|
||||
: defaultAvatarPath
|
||||
"
|
||||
/>
|
||||
|
||||
@@ -92,7 +92,7 @@ onUnmounted(() => {
|
||||
:src="
|
||||
imagePreviewUrl ||
|
||||
(userToEdit.avatar_path
|
||||
? `/assets/romm/assets/${userToEdit.avatar_path}?ts=${userToEdit.updated_at}`
|
||||
? `/api/raw/assets/${userToEdit.avatar_path}?ts=${userToEdit.updated_at}`
|
||||
: defaultAvatarPath)
|
||||
"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user