Skip to content

Commit

Permalink
[aem-universal-editor-service] remove UES TLS cert and use local-ssl-…
Browse files Browse the repository at this point in the history
…proxy instead
  • Loading branch information
juan-ayala committed Sep 17, 2024
1 parent d5d1e3b commit f259789
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 47 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Dev Container Features

## `aem-sdk`
## Software Distribution
You will need to download the required packages from [Adobe's software distribution](https://experience.adobe.com/#/downloads). The reason for this is to avoid having to keep these features up-to-date with new versions. Instead you download and place the packages in the `.devcontainer` folder. And the features will look for and unpack packages from there.

![Software Distribution](software-distribution.png)

## [aem-sdk](/tree/main/src/aem-sdk)
> Install and run AEM author, publish and dispatcher. You must have access to the AEM SDK. It is only available through the Adobe software distribution site. This feature only facilitates the setup process. See: [Developing AEM Inside a Dev Container](https://theaemmaven.com/post/developing-aem-inside-a-dev-container)
## `aem-repo-tool`
## [aem-repo-tool](/tree/main/src/aem-repo-tool)
> Install the AEM repo tool. You will still need to setup the [key bindings](https://github.com/Adobe-Marketing-Cloud/tools/tree/master/repo) to your liking. See: [AEM Repo Tool](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/developer-tools/repo-tool)
## `aem-universal-editor-service`
## [aem-universal-editor-service](/tree/main/src/aem-universal-editor-service)
> Install a local Universal Editor Service. You must have access to the archive that contains the CJS file. It is only available through the Adobe software distribution site. See: [Local AEM Development with the Universal Editor](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/developing/universal-editor/local-dev)
Binary file added software-distribution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions src/aem-universal-editor-service/bin/start-ues
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,26 @@ function get_ues_zip()
[ ! -f "${zip}" ] && return 1 || echo "${zip}"
}

if [ ! -f "${AEM_UES_FEATURE_DIR}/universal-editor-service.cjs" ]; then
cd ${AEM_UES_FEATURE_DIR}

# Install UES if not installed
if [ ! -f universal-editor-service.cjs ]; then
ueszip=$(get_ues_zip) || ues_zip_not_found
sudo unzip -d ${AEM_UES_FEATURE_DIR} ${ueszip}
sudo unzip ${ueszip}
fi

cd ${AEM_UES_FEATURE_DIR}

# Source node version manager
source ${NVM_DIR}/nvm.sh

# Install node version
nvm install ${AEM_UES_NODE_VERSION}
# And required global packages
nvm exec ${AEM_UES_NODE_VERSION} \
npm install -g local-ssl-proxy concurrently

# Run TLS termination for UES and Author
nvm exec ${AEM_UES_NODE_VERSION} \
concurrently --kill-others \
"node universal-editor-service.cjs" \
"local-ssl-proxy --source ${AEM_UES_AUTHOR_HTTPS_PORT} --target ${AEM_UES_AUTHOR_HTTP_PORT}"
"node universal-editor-service.cjs" \
"local-ssl-proxy --source ${AEM_UES_HTTPS_PORT} --target ${AEM_UES_HTTP_PORT}" \
"local-ssl-proxy --source ${AEM_UES_AUTHOR_HTTPS_PORT} --target ${AEM_UES_AUTHOR_HTTP_PORT}"
11 changes: 8 additions & 3 deletions src/aem-universal-editor-service/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "aem-universal-editor-service",
"version": "1.2.0",
"version": "1.3.0",
"name": "Adobe Experience Manager Universal Editor Service",
"description": "Setup the AEM Universal Editor Service for local development.",
"options": {
Expand All @@ -19,9 +19,14 @@
"description": "Universal Editor Service version.",
"default": "automatic"
},
"uesPort": {
"uesHttpPort": {
"type": "string",
"description": "Universal Editor Service port.",
"description": "Universal Editor Service HTTP port.",
"default": "8001"
},
"uesHttpsPort": {
"type": "string",
"description": "Universal Editor Service HTTPS port.",
"default": "8000"
},
"authorHttpPort": {
Expand Down
19 changes: 6 additions & 13 deletions src/aem-universal-editor-service/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,18 @@ propertiesFile="${AEM_UES_FEATURE_DIR}/options.sh"
echo "AEM_UES_DOWNLOADS_DIR=\"${UESDOWNLOADSDIRECTORY}\"" >> ${propertiesFile}
echo "AEM_UES_NODE_VERSION=\"${UESNODEVERSION:-'20'}\"" >> ${propertiesFile}
echo "AEM_UES_VERSION=\"${UESVERSION:-'automatic'}\"" >> ${propertiesFile}
echo "AEM_UES_PORT=\"${UESPORT:-'8000'}\"" >> ${propertiesFile}
echo "AEM_UES_HTTP_PORT=\"${UESHTTPPORT:-'8001'}\"" >> ${propertiesFile}
echo "AEM_UES_HTTPS_PORT=\"${UESHTTPSPORT:-'8000'}\"" >> ${propertiesFile}
echo "AEM_UES_AUTHOR_HTTP_PORT=\"${AUTHORHTTPPORT:-'4502'}\"" >> ${propertiesFile}
echo "AEM_UES_AUTHOR_HTTPS_PORT=\"${AUTHORHTTPSPORT:-'44302'}\"" >> ${propertiesFile}
source ${propertiesFile}

# copy custom scripts
cp -r "$(dirname $0)/bin" ${AEM_UES_FEATURE_DIR}

# create ssl cert and private key
openssl req -newkey rsa:2048 -nodes -keyout "${AEM_UES_FEATURE_DIR}/key.pem" \
-x509 -days 365 -out "${AEM_UES_FEATURE_DIR}/certificate.pem" -subj '/CN=localhost'
# and allow remote user to read private key
chgrp ${_REMOTE_USER} "${AEM_UES_FEATURE_DIR}/key.pem"
chmod g+r "${AEM_UES_FEATURE_DIR}/key.pem"

# create .env file
cat <<EOF >> "${AEM_UES_FEATURE_DIR}/.env"
UES_PORT=${AEM_UES_PORT}
UES_PRIVATE_KEY=./key.pem
UES_CERT=./certificate.pem
if [ ! -f "${AEM_UES_FEATURE_DIR}/.env" ]; then
cat <<EOF > "${AEM_UES_FEATURE_DIR}/.env"
UES_PORT=${AEM_UES_HTTP_PORT}
UES_TLS_REJECT_UNAUTHORIZED=false
EOF
fi
10 changes: 6 additions & 4 deletions test/aem-universal-editor-service/defaults-with-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ check "ues node version default" \
[ "${AEM_UES_NODE_VERSION}" = "20" ]
check "ues version default" \
[ "${AEM_UES_VERSION}" = "automatic" ]
check "ues port default" \
[ "${AEM_UES_PORT}" = "8000" ]
check "ues port default" \
check "ues http port default" \
[ "${AEM_UES_HTTP_PORT}" = "8001" ]
check "ues https port default" \
[ "${AEM_UES_HTTPS_PORT}" = "8000" ]
check "author http port default" \
[ "${AEM_UES_AUTHOR_HTTP_PORT}" = "4502" ]
check "ues port default" \
check "author https port default" \
[ "${AEM_UES_AUTHOR_HTTPS_PORT}" = "44302" ]

# Check that ues installs and exec the node script
Expand Down
12 changes: 7 additions & 5 deletions test/aem-universal-editor-service/options-with-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ source ${AEM_UES_FEATURE_DIR}/options.sh
check "downloads directory set" \
echo "${AEM_UES_DOWNLOADS_DIR}" | grep -E "^/workspaces/[0-9]+/.devcontainer$"
check "ues node version default" \
[ "${AEM_UES_NODE_VERSION}" = "22" ]
[ "${AEM_UES_NODE_VERSION}" = "16" ]
check "ues version default" \
[ "${AEM_UES_VERSION}" = "mock-2024.02.01" ]
check "ues port default" \
[ "${AEM_UES_PORT}" = "9090" ]
check "ues port default" \
check "ues http port default" \
[ "${AEM_UES_HTTP_PORT}" = "9091" ]
check "ues https port default" \
[ "${AEM_UES_HTTPS_PORT}" = "9090" ]
check "author http port default" \
[ "${AEM_UES_AUTHOR_HTTP_PORT}" = "4510" ]
check "ues port default" \
check "author https port default" \
[ "${AEM_UES_AUTHOR_HTTPS_PORT}" = "44310" ]

# Check that ues installs and exec the node script
Expand Down
5 changes: 3 additions & 2 deletions test/aem-universal-editor-service/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"features": {
"aem-universal-editor-service": {
"uesDownloadsDirectory": "${containerWorkspaceFolder}/.devcontainer",
"uesNodeVersion": "22",
"uesNodeVersion": "16",
"uesVersion": "mock-2024.02.01",
"uesPort": "9090",
"uesHttpPort": "9091",
"uesHttpsPort": "9090",
"authorHttpPort": "4510",
"authorHttpsPort": "44310"
}
Expand Down
18 changes: 7 additions & 11 deletions test/aem-universal-editor-service/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,18 @@ check "ues node version default" \
[ "${AEM_UES_NODE_VERSION}" = "20" ]
check "ues version default" \
[ "${AEM_UES_VERSION}" = "automatic" ]
check "ues port default" \
[ "${AEM_UES_PORT}" = "8000" ]
check "ues port default" \
check "ues http port default" \
[ "${AEM_UES_HTTP_PORT}" = "8001" ]
check "ues https port default" \
[ "${AEM_UES_HTTPS_PORT}" = "8000" ]
check "author http port default" \
[ "${AEM_UES_AUTHOR_HTTP_PORT}" = "4502" ]
check "ues port default" \
check "author https port default" \
[ "${AEM_UES_AUTHOR_HTTPS_PORT}" = "44302" ]
# Check start-ues in PATH is executable
check "start-ues is +x" \
stat -c '%A' $(which start-ues) | grep 'x.*x.*x'
# Check config files created
check "can read key" \
stat -c '%a' "${AEM_UES_FEATURE_DIR}/key.pem" | grep 640
check "key group set to remote user" \
stat -c '%G' "${AEM_UES_FEATURE_DIR}/key.pem" | grep "${_REMOTE_USER}"
check "created certificate" \
[ -f "${AEM_UES_FEATURE_DIR}/certificate.pem" ]
# Check .env file created
check "created .env" \
[ -f "${AEM_UES_FEATURE_DIR}/.env" ]

Expand Down

0 comments on commit f259789

Please sign in to comment.