Skip to content

Build shibboleth-idp for testing purposes #91216

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 8 commits into from
Nov 3, 2022

Conversation

jakelandis
Copy link
Contributor

@jakelandis jakelandis commented Oct 31, 2022

We currently use unicon/shibboleth-idp:3.4.2 to help test our SAML integration.
That container is no longer actively supported and does not support
ARM architectures.

This commit is a partial clone from https://github.com/Unicon/shibboleth-idp-dockerized 3.4.3.

Changes from upstream include:

  • Use openjdk:11.0.16-jre as the base image for support for ARM architectures
  • Handle missing keystore download from Jetty
  • Fix URL paths for artifacts to download

Changes to this repository include:

  • Copied required Jetty configuration files from upstream project
  • Updates to docker compose
  • Placed the missing keystore Jetty downloads in a separate location (jetty-custom)

The final result is a bit messy. Mixing cloned files with custom files and mixing
Jetty and IDP concerns. However, it is not much messier than prior and now
that we control building the image we can more easily upgrade shibboleth IDP
The upgrade to the latest version is fairly involved and as such we will need to
deviate more from the clone which should allow some additional clean up.

part of: #71378
related: #91144
supersedes: #89674

===
Below is a comparison report from this PR to the upstream Dockerfile.
compare.pdf

All files except build.gradle, docker-compose.yml, and Dockerfile are copy/pasted.

@jakelandis
Copy link
Contributor Author

slightly more readable diff: compare.pdf

@jakelandis
Copy link
Contributor Author

to test manually : ./gradlew :x-pack:qa:saml-idp-tests:javaRestTest --info --stacktrace , note since c2id is part of the same test fixture you may need to comment that container out from the build (at least until #91144 is merged).

@jakelandis jakelandis marked this pull request as ready for review October 31, 2022 17:49
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Oct 31, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

- ./idp/shibboleth-idp/conf:/opt/shibboleth-idp/conf
- ./idp/shibboleth-idp/credentials:/opt/shibboleth-idp/credentials
- ./idp/shibboleth-idp/metadata:/opt/shibboleth-idp/metadata
- ./idp/shib-jetty-base/start.d/ssl.ini:/opt/shib-jetty-base/start.d/ssl.ini
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these are now copied via the Dockerfile

depends_on:
- openldap
environment:
- JETTY_MAX_HEAP=64m
- JETTY_BROWSER_SSL_KEYSTORE_PASSWORD=secret
- JETTY_BACKCHANNEL_SSL_KEYSTORE_PASSWORD=secret
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is now baked into the image


[files]
# keystore originally sourced from https://github.com/eclipse/jetty.project/raw/jetty-9.3.x/jetty-server/src/main/config/etc/keystore
/opt/shib-jetty-base/etc/keystore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the only change in this file.

@jakelandis
Copy link
Contributor Author

test failure : https://gradle-enterprise.elastic.co/s/donalxonp3lge might be related or could be a latent issue... looking now.

Cannot get property 'test.fixtures.shibboleth-idp.tcp.4443' on extra properties extension as it does not exist

@jakelandis
Copy link
Contributor Author

Cannot get property 'test.fixtures.shibboleth-idp.tcp.4443' on extra properties extension as it does not exist

This is only an issue for a brand new image build. i.e. if the image is already built then there are no issue.

Further up in the log "Gateway cannot be read from container inspection - trying to read from network inspection" is unique for this container. When run in debug mode you can see an empty port mapping

"PortBindings": {
                "4443/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": ""
                    }
                ]
            },

after a bit googling... I think this might be due to the docker plugin trying reading the build container, not the final container, so I added a "restart: always" which fixes the issue but now there is another issue. The other issue I believe is that the port from $outputDir/idp-metadata.xml is not always updated. To fix that I switched from a Copy to Sync task and set outputs.upToDateWhen { false } for that task. Pretty sure the last 1/2 of that is a latent bug with running these tests.

Fixed on 82b2b26 (#91216)

from idpFixtureProject.files('idp/shibboleth-idp/credentials/idp-browser.pem', 'idp/shibboleth-idp/metadata/idp-metadata.xml',
'idp/shibboleth-idp/credentials/sp-signing.key', 'idp/shibboleth-idp/credentials/sp-signing.crt');
into outputDir
outputs.upToDateWhen { false } //ensure this copy is always done to prevent stale configuration
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is kinda hacky ... I think I can fix this, but would prefer to do so on a different PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw the comments in slack. I dont' think this is necessary. A sync task will also do a delete, followed by a copy so in what scenario would there be stale content here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think what is happening is

First run: this task not upto date, copies the files, next task creates new file (with the same name) in the output directory

Second run: this task reports up to date , even with sync because I think guess that the Sync task is only tracking the files it touches and did not touch the file was replaced by the other task (it has same name but it is a different file/inode), since it is up to date it does nothing and the elder file is still there and is used.

I didn't spent too much time with this, so I could be wrong. It is pretty to reproduce by echoing out the contents of $outputDir/idp-metadata.xml in a doFirst of the setupPorts task.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's quite odd. If one of the output files is modified it should trigger the task to be out-of-date, in which case, it would be the same behavior as just being never up to date as we have here. Kinda gross but yeah, I have plans to ditch all this build logic around test fixtures. It's positively awful.

@jakelandis jakelandis merged commit 1f3ec5f into elastic:main Nov 3, 2022
@jakelandis jakelandis deleted the arm_for_shibboleth branch November 3, 2022 18:52
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
7.17 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 91216

jakelandis added a commit to jakelandis/elasticsearch that referenced this pull request Nov 3, 2022
We currently use unicon/shibboleth-idp:3.4.2 to help test our SAML integration.
That container is no longer actively supported and does not support
ARM architectures.

This commit is a partial clone from Unicon/shibboleth-idp-dockerized 3.4.3.

Changes from upstream include:

    Use openjdk:11.0.16-jre as the base image for support for ARM architectures
    Handle missing keystore download from Jetty
    Fix URL paths for artifacts to download

Changes to this repository include:

    Copied required Jetty configuration files from upstream project
    Updates to docker compose
    Placed the missing keystore Jetty downloads in a separate location (jetty-custom)

The final result is a bit messy. Mixing cloned files with custom files and mixing
Jetty and IDP concerns. However, it is not much messier than prior and now
that we control building the image we can more easily upgrade shibboleth IDP
The upgrade to the latest version is fairly involved and as such we will need to
deviate more from the clone which should allow some additional clean up.

part of: elastic#71378
related: elastic#91144
supersedes: elastic#89674
elasticsearchmachine pushed a commit that referenced this pull request Nov 3, 2022
We currently use unicon/shibboleth-idp:3.4.2 to help test our SAML integration.
That container is no longer actively supported and does not support
ARM architectures.

This commit is a partial clone from Unicon/shibboleth-idp-dockerized 3.4.3.

Changes from upstream include:

    Use openjdk:11.0.16-jre as the base image for support for ARM architectures
    Handle missing keystore download from Jetty
    Fix URL paths for artifacts to download

Changes to this repository include:

    Copied required Jetty configuration files from upstream project
    Updates to docker compose
    Placed the missing keystore Jetty downloads in a separate location (jetty-custom)

The final result is a bit messy. Mixing cloned files with custom files and mixing
Jetty and IDP concerns. However, it is not much messier than prior and now
that we control building the image we can more easily upgrade shibboleth IDP
The upgrade to the latest version is fairly involved and as such we will need to
deviate more from the clone which should allow some additional clean up.

part of: #71378
related: #91144
supersedes: #89674
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Security/Security Security issues without another label Team:Security Meta label for security team v7.17.8 v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants