Skip to content

feat(http auth): Add env vars & process to update HTTP Auth #31

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

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions castor/clever-cloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ function setupEnv(object $project): string
$setEnv('IS_PROTECTED', 'true');
$setEnv('APP_SECRET', md5(random_bytes(32)));
$setEnv('HTTPS', 'on');
$setEnv('HTTP_AUTH_CLEAR', 'false');
$setEnv('HTTP_AUTH_USERNAME', '');
$setEnv('HTTP_AUTH_PASSWORD', '');
$setEnv('MEMORY_LIMIT', '256M');
$setEnv('SYLIUS_FIXTURES_HOSTNAME', $hostname);
$setEnv('APP_JPEGOPTIM_BINARY', '/usr/host/bin/jpegoptim');
Expand Down
8 changes: 7 additions & 1 deletion clevercloud/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ export -f copy_dist_files
function protect_application() {
# Append the content of security file in `.htaccess` if protected
if [ "${IS_PROTECTED}" == "true" ]; then
echo -e "$(cat ${APP_HOME}/clevercloud/security_htaccess)\n\n$(cat ${APP_HOME}${CC_WEBROOT}/.htaccess)" > ${APP_HOME}${CC_WEBROOT}/.htaccess
echo -e "$(cat ${APP_HOME}/clevercloud/security_htaccess)\n\n$(cat ${APP_HOME}${CC_WEBROOT}/.htaccess)" >${APP_HOME}${CC_WEBROOT}/.htaccess
if [ -n "${HTTP_AUTH_USERNAME:-}" ] && [ -n "${HTTP_AUTH_PASSWORD:-}" ]; then
if [ "${HTTP_AUTH_CLEAR:-false}" == "true" ];
echo "" > ${APP_HOME}/clevercloud/.htpasswd
fi
htpasswd -b ${APP_HOME}/clevercloud/.htpasswd ${HTTP_AUTH_USERNAME} ${HTTP_AUTH_PASSWORD}
fi
fi
}
export -f protect_application
Expand Down