Skip to content

Commit

Permalink
Add Keys, Script and Signing Service to dev environment
Browse files Browse the repository at this point in the history
This PR adds:

- secret and public keys on dev/common/
- imports and trusts keys on container build time
- add make docker/add-signing-service

TODO:

- [ ] Route URL to spawn sign task (subclass pulp_ansible#754
  serializer)
- [ ] Surface the signature on collectionversion serializer
- [ ] Add test to sign a collection

Issue: AAH-1181

Required PR: pulp/pulp_ansible#754

env:LOCK_REQUIREMENTS=0
env:PULP_CONTAINER_REVISION=39b3000150960c554d2124ab3654e3e7b4c54352
env:PULPCORE_REVISION=f8306ac5d3af1cf9936d39abb0568e86d18cd55f
env:GALAXY_IMPORTER_REVISION=7091519f38acb8e10b85baffe7c6074b02309598
  • Loading branch information
rochacbruno committed Dec 9, 2021
1 parent c2eb855 commit d3f1de7
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 5 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ venv/
pip-wheel-metadata/
**/__pycache__/
.git/
dev/
1 change: 1 addition & 0 deletions CHANGES/1181.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add keys, script and signing service to dev env
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ DJ_MANAGER = $(shell if [ "$(RUNNING)" == "" ]; then echo manage; else echo djan

define exec_or_run
# Tries to run on existing container if it exists, otherwise starts a new one.
@echo $(1)$(2)$(3)$(4)$(5)
@echo $(1)$(2)$(3)$(4)$(5)$(6)
@if [ "$(RUNNING)" != "" ]; then \
echo "Running on existing container $(RUNNING)" 1>&2; \
./compose exec $(1) $(2) $(3) $(4) $(5); \
./compose exec $(1) $(2) $(3) $(4) $(5) $(6); \
else \
echo "Starting new container" 1>&2; \
./compose run --use-aliases --service-ports --rm $(1) $(2) $(3) $(4) $(5); \
./compose run --use-aliases --service-ports --rm $(1) $(2) $(3) $(4) $(5) $(6); \
fi
endef

Expand Down Expand Up @@ -92,6 +92,10 @@ docker/makemigrations: ## Run django migrations
docker/migrate: ## Run django migrations
$(call exec_or_run, api, $(DJ_MANAGER), migrate)

.PHONY: docker/add-signing-service
docker/add-signing-service: ## Add a Signing service using default GPG key
$(call exec_or_run, worker, $(DJ_MANAGER), add-signing-service, ansible-default, /var/lib/pulp/scripts/collection_sign.sh, [email protected])

.PHONY: docker/resetdb
docker/resetdb: ## Cleans database
# Databases must be stopped to be able to reset them.
Expand All @@ -109,6 +113,7 @@ docker/all: ## Build, migrate, loaddata, transl
make docker/migrate
make docker/loaddata
make docker/translations
make docker/add-signing-service

# Application management and debugging

Expand Down
8 changes: 7 additions & 1 deletion dev/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ RUN set -ex; \
python38-devel \
libpq \
libpq-devel \
pinentry \
&& dnf clean all \
&& rm -rf /var/cache/dnf/ \
&& rm -f /var/lib/rpm/__db.* \
Expand All @@ -54,6 +55,7 @@ ENV PATH="/venv/bin:${PATH}" \
VIRTUAL_ENV="/venv"

COPY ./requirements/requirements.common.txt /tmp/requirements.txt
COPY ./dev/common/ansible-sign.key /tmp/ansible-sign.key

RUN set -ex; \
pip install --no-cache-dir --upgrade pip \
Expand Down Expand Up @@ -83,9 +85,11 @@ RUN set -ex; \
&& mkdir --mode=2775 -p \
/var/lib/pulp/artifact \
/var/lib/pulp/tmp \
/var/lib/pulp/scripts \
/tmp/ansible \
&& chown ${USER_NAME}:${USER_GROUP} /var/lib/pulp/artifact \
&& chown ${USER_NAME}:${USER_GROUP} /var/lib/pulp/tmp \
&& chown ${USER_NAME}:${USER_GROUP} /var/lib/pulp/scripts \
&& chown ${USER_NAME}:${USER_GROUP} \
/tmp/ansible \
/etc/ansible \
Expand All @@ -98,7 +102,9 @@ RUN set -ex; \
&& chmod 0644 /var/log/galaxy_api_access.log \
&& chown galaxy:galaxy /var/log/galaxy_api_access.log \
&& mkdir -p /etc/pulp/certs/ \
&& echo "DNmNdwgyZugTax9S64J0FITTr9IHPxbuoF1F1CGPr68=" > /etc/pulp/certs/database_fields.symmetric.key
&& echo "DNmNdwgyZugTax9S64J0FITTr9IHPxbuoF1F1CGPr68=" > /etc/pulp/certs/database_fields.symmetric.key \
&& gpg --batch --import /tmp/ansible-sign.key &>/dev/null \
&& (echo trust &echo 5 &echo y &echo quit &echo save) | gpg --batch --command-fd 0 --edit-key galaxy3 &>/dev/null

# This symmetric.key is for dev only and should not be used in production
# DNmNdwgyZugTax9S64J0FITTr9IHPxbuoF1F1CGPr68=
Expand Down
Binary file added dev/common/ansible-sign-pub.gpg
Binary file not shown.
41 changes: 41 additions & 0 deletions dev/common/ansible-sign-pub.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQGNBGGyPsgBDACpWO2BexH3orSI2ksseqLjQ9h6Eq2HaBQdJLLQZZvkiWB/e3Gy
8gvO3wgP7XxcIH09kddvmEFa4BXheXNd74qKTdoKh5UX2oFnw1rDwrQjcMKxJnjm
Yku6br68kMfaNkwyQrSY7wwZ3XG/UfoWtdMehZKDZWD1YwTuaSJ5kxhsmQVxlN+U
pTMG3uEC7aykogyzIH2PWvMoaP+XDvUb7XXJs0Z54tPzF9ngYpNiwTlMrm7+Q2FG
1qognKlzEfKJ9FVSE9cO7MGCYOYCUrKcPahEMMnNDRnY5FwCEVTZhH/LgXg0pY7x
pyKAvCFi+j2QSlYlvhGKJWgZG2v9qH6DPRla5mf8+f6/gviEGum9DwwjlJ2bFWrw
fVGH7Ij9L1D3qjxFuMJkumEF9qpdfG8NZYingDsbgwjdKn6VXqmdVkUXNDwnk3gG
tPQ9wd46qrUPzjwJ+66c28XKnjOJbJ7HU1bth9q7uvnoOqgNJGJVJhX+1+CXhSIA
UnPsTOq5ivx/2DUAEQEAAbQiR2FsYXh5IERldiAzIDxnYWxheHkzQGFuc2libGUu
Y29tPokB1AQTAQgAPhYhBOvtFw6MlIDiKh0FmxUlDp7ApiV3BQJh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Ys32QwfmSLrDXYlGpjG1HUZ3J5LLjHipvZeZlmNt5rUvni/
ajQcyiP5ABEBAAGJAbwEGAEIACYWIQTr7RcOjJSA4iodBZsVJQ6ewKYldwUCYbI+
yAIbDAUJA8JnAAAKCRAVJQ6ewKYldz/uC/9JiVlWge5sswUYUiV+TcXtATN3UKRE
BEKtQYNgBW6geLwMyIsxSTBfpSoioezSZrriFirnQAtvrygUqTeX/uq4TD5qY502
EejE+onF7bHpUEfJ/biyXQuFDBqNGBsWYnXxPbhXBY+mGhY5un5mg6TEGL2SMdSj
5uhTBcaQ3BkGaqNng1nVC710nwQcMm8f9qs4uOogqy7Ndl1xtoRQZa9/Vbi3vIDC
P9GYGUdAPu1OuXvl9wFYIKlWy95CS+L25o/59JbqT+XLLiyAnEmyMvWF+JUScm6H
6wAjDoZOenmBSzgKs/7POb7z3ktZrEWvTcNHWCuH7hwYOP/zAWrble9RdUsRZF/K
dcWrMZmkDSqOch6Qbp+vc8n/Z1rFiNvyfbiAkQ/Z9BW3+iHolEGHwq4i/O9Xx5bq
NWuRMs3XgtmQpAxFi2C8nGo5E8eDUw4qKHXYNkcuOraay0wBNpoffISO4+d24GB4
I6KUd9Bv1wf+etJ50jZ0dzt+T1Qs2wKbtf0=
=PHJy
-----END PGP PUBLIC KEY BLOCK-----
Binary file added dev/common/ansible-sign.key
Binary file not shown.
20 changes: 20 additions & 0 deletions dev/common/collection_sign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

FILE_PATH=$1
SIGNATURE_PATH="$1.asc"

ADMIN_ID="[email protected]"
PASSWORD="Galaxy2022"

# Create a detached signature
gpg --quiet --batch --pinentry-mode loopback --yes --passphrase \
$PASSWORD --homedir ~/.gnupg/ --detach-sign --default-key $ADMIN_ID \
--armor --output $SIGNATURE_PATH $FILE_PATH

# Check the exit status
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo {\"file\": \"$FILE_PATH\", \"signature\": \"$SIGNATURE_PATH\"}
else
exit $STATUS
fi
4 changes: 4 additions & 0 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
entrypoint: "/bin/true"
tmpfs:
- "/var/lib/pulp/artifact"
- "/var/lib/pulp/scripts"
- "/var/lib/pulp/tmp"
- "/tmp/ansible"

Expand All @@ -44,6 +45,7 @@ services:
- './common/galaxy_ng.env'
volumes:
- "./common/settings.py:/etc/pulp/settings.py:z"
- "./common/collection_sign.sh:/var/lib/pulp/scripts/collection_sign.sh:z"
- "${COMPOSE_CONTEXT}/..:/src:z"
- "pulp:/var/lib/pulp"
tmpfs:
Expand All @@ -65,6 +67,7 @@ services:
- './common/galaxy_ng.env'
volumes:
- "./common/settings.py:/etc/pulp/settings.py:z"
- "./common/collection_sign.sh:/var/lib/pulp/scripts/collection_sign.sh:z"
- "${COMPOSE_CONTEXT}/..:/src:z"
- "pulp:/var/lib/pulp"
tmpfs:
Expand All @@ -88,6 +91,7 @@ services:
- './common/galaxy_ng.env'
volumes:
- "./common/settings.py:/etc/pulp/settings.py:z"
- "./common/collection_sign.sh:/var/lib/pulp/scripts/collection_sign.sh:z"
- "${COMPOSE_CONTEXT}/..:/src:z"
- "pulp:/var/lib/pulp"
tmpfs:
Expand Down

0 comments on commit d3f1de7

Please sign in to comment.