Skip to content

Fix dspace-customers 1083 finding 29: create the Shibboleth SP key when the container starts - #1693

Open
milanmajchrak wants to merge 2 commits into
dtq-devfrom
fix/shib-sp-key-at-start
Open

milanmajchrak wants to merge 2 commits into
dtq-devfrom
fix/shib-sp-key-at-start

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

References

dspace-customers issue 1083, finding 29.

Description

The dspace-shibboleth test image now creates the Shibboleth SP key pair and Apache's self-signed certificate when a container starts for the first time, not during docker build. The image itself contains no private key file.

Instructions for Reviewers

List of changes in this PR:

  • Dockerfile: the shib-keygen step is removed. The ssl-cert-snakeoil files that the ssl-cert package creates are deleted in the same step that installs it.
  • httpd-shibd-foreground.sh: runs shib-keygen -b -o /etc/shibboleth and make-ssl-cert generate-default-snakeoil before shibd and Apache start. Both keep files that already exist, so a restart or a mounted pair keeps its key. If only one of sp-key.pem and sp-cert.pem exists, the script stops with a clear message.
  • README.md: two sentences on where the keys come from and how to keep a fixed SP key.

The image is only used by docker-compose-shibboleth.yml for local tests. No CI job builds or publishes it.

How to test:

docker build -t shib-test dspace/src/main/docker/dspace-shibboleth
docker run --rm --entrypoint bash shib-test -c "find / -xdev -name '*.key' -o -name '*key*.pem'"
docker run -d --name a shib-test
docker run -d --name b shib-test
docker exec a sha256sum /etc/shibboleth/sp-key.pem /etc/ssl/private/ssl-cert-snakeoil.key
docker exec b sha256sum /etc/shibboleth/sp-key.pem /etc/ssl/private/ssl-cert-snakeoil.key
docker restart a
docker exec a sha256sum /etc/shibboleth/sp-key.pem

Result: find prints nothing, the two containers have different keys, the restart keeps the key, and shibd and apache2 run. A container started with sp-key.pem and sp-cert.pem mounted read-only keeps that pair.

Codex review (gpt-6.2-sol, high), 4 rounds: 3 findings fixed. Two were left as is: package-generated Shibboleth keys (the find above shows there are none) and no automatic recovery after an interrupted first start (the script stops with a clear message).

AI Disclosure (REQUIRED)

Were AI tools used in the creation of this PR?

  • No (This PR does NOT include AI-generated or AI-assisted content that requires disclosure.)
  • Yes (This PR includes AI-generated or AI-assisted content that requires disclosure.)

Claude Code wrote the change and checked it in Docker with the commands above.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
  • My PR follows all coding best practices based on the Code Conventions Guide.
  • My PR passes Checkstyle validation based on the Code Style Guide.
  • My PR includes Javadoc for all new (or modified) public methods and classes. It also includes Javadoc for large or complex private methods.
  • My PR passes all tests and includes new/updated Unit or Integration Tests based on the Code Testing Guide.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in any pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR modifies REST API endpoints, I've opened a separate REST Contract PR related to this change.
  • If my PR includes new configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

🤖 Generated with Claude Code

The test image ran shib-keygen at build time, so every container shared one key pair stored in an image layer. The startup script now creates it on the first start and keeps an existing or mounted pair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milanmajchrak
milanmajchrak requested a balanced review from Copilot November 18, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change to generate per-container Shibboleth credentials at startup.

No open issues 🎉

What changed in this PR

Moves Shibboleth SP key generation from image build to first container startup, giving each local test container its own credentials instead of sharing an image-baked key.

Changes:

  • Removes build-time SP key generation.
  • Generates credentials at startup, preserves existing pairs, and rejects missing or empty credential files.
  • Documents how to mount a fixed key pair.
File Description
dspace/​src/​main/​docker/​README.md Documents startup-generated credentials and fixed-key mounts.
dspace/​src/​main/​docker/​dspace-shibboleth/​httpd-shibd-foreground.sh Generates and checks the credential pair before starting Shibboleth.
dspace/​src/​main/​docker/​dspace-shibboleth/​Dockerfile Removes the build-time shib-keygen step.

Review effort: Balanced

The startup script now also runs make-ssl-cert, so the image contains no private key file. Existing files are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the change to generate local Shibboleth test credentials at container startup.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants