diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 12ff88e..23a6ce8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,6 +6,20 @@ updates: schedule: interval: daily open-pull-requests-limit: 15 + labels: + - "dependency-upgrade" + commit-message: + prefix: "3.1.x" + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-major", "version-update:semver-minor"] + + - package-ecosystem: gradle + directory: "/" + target-branch: "3.0.x" + schedule: + interval: daily + open-pull-requests-limit: 15 labels: - "dependency-upgrade" commit-message: diff --git a/.gitignore b/.gitignore index 3e4fd89..a90b1f5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,3 @@ bin build out target - -credhub-server/config/*.pem -credhub-server/uaa.yml \ No newline at end of file diff --git a/README.adoc b/README.adoc index 93995a9..ac1bba5 100644 --- a/README.adoc +++ b/README.adoc @@ -33,11 +33,7 @@ Once running they can be executed with: [source,bash] ---- -./gradlew :spring-credhub-integration-tests:test -PintegrationTests ----- -[source,bash] ----- -./gradlew :spring-credhub-reactive-integration-tests:test -PintegrationTests +./gradlew build -PintegrationTests --no-parallel ---- === Working with the code diff --git a/build.gradle b/build.gradle index c123723..422d9ba 100644 --- a/build.gradle +++ b/build.gradle @@ -23,9 +23,9 @@ plugins { description = "Spring CredHub" ext { - springVersion = "6.0.4" - springBootVersion = "3.0.2" - springSecurityVersion = "6.0.1" + springVersion = "6.0.11" + springBootVersion = "3.1.3" + springSecurityVersion = "6.1.2" javadocLinks = [ "https://docs.oracle.com/en/java/javase/17/docs/api/", "https://docs.spring.io/spring-framework/docs/current/javadoc-api/" diff --git a/ci/README.adoc b/ci/README.adoc index 17f191c..cac7826 100644 --- a/ci/README.adoc +++ b/ci/README.adoc @@ -4,7 +4,7 @@ Set up the Concourse target and login: [source] ---- -$ fly -t spring-credhub login -n spring-credhub -c https://runway-ci.eng.vmware.com +$ fly -t spring-credhub login -n spring-credhub -c https://runway-ci-sfo.eng.vmware.com ---- Deploy the pipelines diff --git a/ci/config-concourse.yml b/ci/config-concourse.yml index cf973e6..8568f5b 100644 --- a/ci/config-concourse.yml +++ b/ci/config-concourse.yml @@ -1,4 +1,4 @@ artifactory-server: https://repo.spring.io build-name: spring-credhub -spring-credhub-slack-success-channel: "#sc-app-broker" -spring-credhub-slack-failure-channel: "#sc-app-broker" +spring-credhub-slack-success-channel: "#spring-cloud-app-broker" +spring-credhub-slack-failure-channel: "#spring-cloud-app-broker" diff --git a/ci/images/spring-credhub-ci/Dockerfile b/ci/images/spring-credhub-ci/Dockerfile index 7c2c457..d70fc22 100644 --- a/ci/images/spring-credhub-ci/Dockerfile +++ b/ci/images/spring-credhub-ci/Dockerfile @@ -1,17 +1,51 @@ FROM harbor-repo.vmware.com/dockerhub-proxy-cache/library/ubuntu:jammy +# Environment variables +ENV TERM dumb +ENV LC_ALL C.UTF-8 + ARG CONCOURSE_JAVA_SCRIPTS_VERSION=0.0.4 ARG CONCOURSE_RELEASE_SCRIPTS_VERSION=0.3.4 +ARG YTT_VERSION="0.45.4" -RUN apt-get update && \ - apt-get install --no-install-recommends -y \ - ca-certificates \ - curl \ - git \ - jq \ - net-tools \ - openjdk-17-jdk-headless && \ - apt-get clean +# Install packages required for bootstrapping +RUN apt-get -qy update \ + && apt-get -qy --no-install-recommends install \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg-agent \ + software-properties-common \ + && apt-get clean + +# Accept apt repository keys +RUN curl -q 'https://download.docker.com/linux/ubuntu/gpg' | apt-key add - + +# Add custom apt repositories +RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + +# Install packages +RUN apt-get -qy update \ + && apt-get -qy --no-install-recommends install \ + bsdextrautils \ + containerd.io \ + cgroupfs-mount \ + docker-ce \ + git \ + jq \ + make \ + openjdk-17-jdk \ + openssh-client \ + tcpdump \ + && apt-get clean + +RUN curl -Lo ytt "https://github.com/vmware-tanzu/carvel-ytt/releases/download/v$YTT_VERSION/ytt-linux-amd64" \ + && chmod u+x ytt && mv ytt /usr/local/bin/ + +RUN curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" \ + -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose + +WORKDIR /unpack ADD "https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v$CONCOURSE_JAVA_SCRIPTS_VERSION/concourse-java.sh" /opt/ ADD "https://repo.spring.io/ui/native/snapshot/io/spring/concourse/releasescripts/concourse-release-scripts/$CONCOURSE_RELEASE_SCRIPTS_VERSION/concourse-release-scripts-$CONCOURSE_RELEASE_SCRIPTS_VERSION.jar" /opt/ diff --git a/ci/pipeline.yml b/ci/pipeline.yml index ad8aba3..de72482 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -33,6 +33,8 @@ jobs: - get: git-repo trigger: true - task: build-project + privileged: true + tags: [ btrfs ] timeout: 1h30m file: git-repo/ci/tasks/build-project.yml vars: diff --git a/ci/pr-pipeline.yml b/ci/pr-pipeline.yml new file mode 100644 index 0000000..80e749f --- /dev/null +++ b/ci/pr-pipeline.yml @@ -0,0 +1,67 @@ +--- +aliases: + - &slack-success-notification + put: alert + params: + icon_emoji: ":concourse:" + username: concourse + channel: ((spring-credhub-slack-success-channel)) + text: "$BUILD_PIPELINE_NAME pipeline has succeeded with build <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME>!" + - &slack-failure-notification + put: alert + params: + icon_emoji: ":animal-1252:" + username: concourse + channel: ((spring-credhub-slack-failure-channel)) + text: Build <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME> of job $BUILD_JOB_NAME in the $BUILD_PIPELINE_NAME pipeline has failed! + +jobs: + - name: build + serial: true + public: true + plan: + - get: pull-request + trigger: true + version: every + - task: build-project + timeout: 1h30m + privileged: true + tags: [ btrfs ] + file: pull-request/ci/tasks/build-project.yml + input_mapping: + git-repo: pull-request + vars: + ci-image-tag: ((ci-image-tag)) + on_success: + *slack-success-notification + on_failure: + *slack-failure-notification + +resource_types: + - name: pull-request + type: registry-image + source: + repository: ((dockerhub-mirror-registry))/teliaoss/github-pr-resource + tag: latest + + - name: slack-notification + type: registry-image + source: + repository: ((dockerhub-mirror-registry))/cfcommunity/slack-notification-resource + tag: latest + +resources: + - name: pull-request + type: pull-request + check_every: 10s + source: + repository: ((spring-credhub-pr-github-pull-requests-repo)) + access_token: ((spring-credhub-pr-github-pull-requests-access-token)) + base_branch: ((branch)) + disable_forks: true + required_review_approvals: 1 + + - name: alert + type: slack-notification + source: + url: ((scs-slack-webhook)) diff --git a/ci/scripts/build-project.sh b/ci/scripts/build-project.sh index c0b51a4..0838af3 100755 --- a/ci/scripts/build-project.sh +++ b/ci/scripts/build-project.sh @@ -2,17 +2,32 @@ set -euo pipefail -readonly SKIP_TESTS="${SKIP_TESTS:-false}" - # shellcheck source=common.sh source "$(dirname "$0")/common.sh" repository=$(pwd)/distribution-repository -if [ "$SKIP_TESTS" == "true" ]; then - build_task=assemble -else - build_task=build -fi -pushd git-repo >/dev/null -./gradlew clean "${build_task}" publish -PpublicationRepository="${repository}" -popd >/dev/null +start_docker() { + pushd credhub-server >/dev/null + echo '{"registry-mirrors": ["https://harbor-mirror.spring.vmware.com"]}' > /etc/docker/daemon.json + service cgroupfs-mount start + service docker start + docker-compose up --detach + trap "stop_docker" EXIT + popd >/dev/null +} + +stop_docker() { + pushd credhub-server >/dev/null + docker-compose stop + service cgroupfs-mount stop + service docker stop + popd >/dev/null +} + +main() { + cd git-repo >/dev/null + start_docker + ./gradlew build publish -PpublicationRepository="${repository}" -PintegrationTests --no-parallel +} + +main diff --git a/ci/set-pipelines.sh b/ci/set-pipelines.sh index dfa846d..c2baea9 100755 --- a/ci/set-pipelines.sh +++ b/ci/set-pipelines.sh @@ -22,26 +22,34 @@ readonly FLY_TARGET="spring-credhub" readonly GITHUB_REPO="https://github.com/spring-projects/spring-credhub" set_pipeline() { - local pipeline_name pipeline_definition branch ci_image_tag + local pipeline_name pipeline_definition branch release_series pipeline_full_name pipeline_name="${1:?pipeline name must be provided}" pipeline_definition="${2:?pipeline definition file must be provided}" branch="${3:?branch must be provided}" - ci_image_tag="${4:-$branch}" + release_series="${4:?release_series must be provided}" + pipeline_full_name="${pipeline_name}-${release_series}" - echo "Setting $pipeline_name pipeline..." + echo "Setting $pipeline_full_name pipeline..." fly --target "$FLY_TARGET" set-pipeline \ - --pipeline "$pipeline_name" \ + --pipeline "$pipeline_full_name" \ --config "$pipeline_definition" \ --load-vars-from config-concourse.yml \ --var "github-repo=$GITHUB_REPO" \ --var "branch=$branch" \ - --var "ci-image-tag=$ci_image_tag" + --var "ci-image-tag=$release_series" } set_pipelines() { fly -t "$FLY_TARGET" sync + set_pipeline spring-credhub pipeline.yml main 3.1.x + set_pipeline spring-credhub pipeline.yml 3.0.x 3.0.x + set_pipeline spring-credhub pipeline.yml 2.3.x 2.3.x + set_pipeline spring-credhub pipeline.yml 2.2.x 2.2.x - set_pipeline spring-credhub-3.0.x pipeline.yml main spring-credhub-ci + set_pipeline spring-credhub-pr pr-pipeline.yml main 3.1.x + set_pipeline spring-credhub-pr pr-pipeline.yml 3.0.x 3.0.x + set_pipeline spring-credhub-pr pr-pipeline.yml 2.3.x 2.3.x + set_pipeline spring-credhub-pr pr-pipeline.yml 2.2.x 2.2.x } set_pipelines diff --git a/credhub-server/README.adoc b/credhub-server/README.adoc index a5ec82b..c040203 100644 --- a/credhub-server/README.adoc +++ b/credhub-server/README.adoc @@ -3,14 +3,6 @@ This directory contains artifacts that can be used to start UAA and CredHub servers that can be used to run tests against. It is derived https://github.com/orange-cloudfoundry/credhub-docker and https://github.com/ampersand8/credhub-docker. -Before running the servers for the first time, UAA needs to be configured with jwt signing keys. -To generate the configuration, ensure the `openssl` and https://carvel.dev/ytt/[`ytt`] tools are installed, the run the setup script: - -[source,bash] ----- -$ ./setup-uaa.sh ----- - From the root of this directory, start the servers using Docker Compose: [source,bash] @@ -18,4 +10,12 @@ From the root of this directory, start the servers using Docker Compose: $ docker-compose up ---- -After both servers have started successfully, UAA will be available at `http://localhost:8080/uaa` and CredHub will be available at `https://localhost:9000`. \ No newline at end of file +After both servers have started successfully, UAA will be available at `http://localhost:8080/uaa` and CredHub will be available at `https://localhost:9000`. + + +To generate the test jwt signing keys, ensure the `openssl` and https://carvel.dev/ytt/[`ytt`] tools are installed, then run the setup script: + +[source,bash] +---- +$ ./setup-uaa.sh +---- diff --git a/credhub-server/config/privkey.pem b/credhub-server/config/privkey.pem new file mode 100644 index 0000000..c1f6eb5 --- /dev/null +++ b/credhub-server/config/privkey.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAzmFA/hQZ8iIl2eaCW0XH1eZ2YuPNMhcaavyvGJwHUbXTUUhr +P7cYdNVgycqfRR+64qJ0ulsWpRdbdtQHCvTzzdX/KSTTepW2nxZNFKq+Re3M+L0L +GeL1maNJ3xLyJ6dvB9YmImI4k+suCOfNBEV03ZJmTxUw3CVjqCdKRpLunA48BeDq ++gQAMpBvL9jdMAXqEmsFhLYE/KWjdBzdjfgt7c29zHz4RX4/N9YS8Q8KWjWgo+Yg +HaNZpYs+6AZXrOEp25ZpTMhpseP6NgbNhgwKzsI5l9cV5cNvHQjODBPPsVoPgkiC +0LRBMChs5h85e6KLrnjpj4njkzmjL5L7xngMRQIDAQABAoIBABMW79oQpe29tt6W +8cvbgoaIkL7I73wIowruYIvYMt0eAnPsTO9R0lNMQW2o7l6IdtLrz/xE3K1cobs2 +FYiv67VIbBe0LlOScZf5ihu1R3BUdLc1VUeJtMoHTpfxurBsTlrdNh3MFAuqn1F3 +j4Ero4mzNv9tqF1UoAk3ySkKAkQw6le2bE4CKvN+XMLMQvYrdTKIHbNP5UYqmwQ1 +fVrdUALiXTJl5tRnWYOs+J2jdysRoti2lrHk94im9wCvHU/AqwMjnEDd1HePaWzD +SNb0T8Flk9wdb9jlhmsJBHKkG5E7yKJ/M7KgPCfbvJb3Br5W6kPSeuAS0ABE6VFZ +RcLKYKkCgYEA6zxlClAVz/vYiyhrIOXt53qEmKqH02Yfg+NeoujG8YffBeq5szsp +1iiMnRNKXMeIRpR48dqvSV5HfhK1i052tVdQAa28CObScROts+0QH8aXHq0roINO +y+leqiq94yeSCTEBpEUTWKdYpdKhMw2PDlV0EwrhRP2j5BXbKUR+musCgYEA4JjN +YZ3qxPaOqclkM50vbrQN8WUimQywePmJi0pI2RBxSnknePiAP7cW8NCsZ10YXe5B +4J8y14l17/oirtr+/S6bD1b//ZPrvX4K0mMiUVNzb05HSjYOTNwEtCc+24FHOlVW +fH50njSGRyxXBELDJGEuHBcgYaR+9aaoZ1MXyY8CgYAJA0xfw8fCK0UVt9u66/Rc +jR4td0My/1OvyvNiTIbq1CjgYijxTBADS5RvpECSI3b+NUwZACb9KaaVlwPrrXrw +4cKH/e8ZbDad7IIYRbn7bbF2lG36fW10dKGS5YZXALogrgcBE0B1ghvsZpCUky1r +AC0tWZpd+VXhNFEsWJp9NwKBgQDAvwHLG44mGH5YgagHj4bsV4N7vdKSTEyKlYSP +0GFyP2Uqh4zziTfu9j6uzjaWwlMuEVHh5l3okWRwXVc0fmbEeyHBaWVphm+SgL/i +zAbgimCPjjsqGfftyAgVX3TXRjwNeL0vPAry1prCK/BFjNIRv4ClxMcaZOQ8BxmR +CsNoSwKBgQC1KIdBUzuLkSxLAm3pEscS3F5yqpclM+eYE/ed4tT6ySqs46X2G0kQ +6VoXd5fT4YgcHszhT7PuW6j8ywNGUN2Zz3Zl8xgxkIkdEZPrL1Hq5K7uBUDeUwhn +96S9sIJEd58utQSu/FqFq14K7dFTQjMtC08T0shzTGhFnWcX85jTcA== +-----END RSA PRIVATE KEY----- diff --git a/credhub-server/config/pubkey.pem b/credhub-server/config/pubkey.pem new file mode 100644 index 0000000..4863488 --- /dev/null +++ b/credhub-server/config/pubkey.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzmFA/hQZ8iIl2eaCW0XH +1eZ2YuPNMhcaavyvGJwHUbXTUUhrP7cYdNVgycqfRR+64qJ0ulsWpRdbdtQHCvTz +zdX/KSTTepW2nxZNFKq+Re3M+L0LGeL1maNJ3xLyJ6dvB9YmImI4k+suCOfNBEV0 +3ZJmTxUw3CVjqCdKRpLunA48BeDq+gQAMpBvL9jdMAXqEmsFhLYE/KWjdBzdjfgt +7c29zHz4RX4/N9YS8Q8KWjWgo+YgHaNZpYs+6AZXrOEp25ZpTMhpseP6NgbNhgwK +zsI5l9cV5cNvHQjODBPPsVoPgkiC0LRBMChs5h85e6KLrnjpj4njkzmjL5L7xngM +RQIDAQAB +-----END PUBLIC KEY----- diff --git a/credhub-server/uaa.yml b/credhub-server/uaa.yml new file mode 100644 index 0000000..a7e2353 --- /dev/null +++ b/credhub-server/uaa.yml @@ -0,0 +1,60 @@ +scim: + users: + - credhub|password|credhub|Credhub|User|credhub.read,credhub.write +oauth: + clients: + credhub_cli: + override: true + authorized-grant-types: password,refresh_token + scope: credhub.read,credhub.write + authorities: uaa.resource + access-token-validity: 86400 + refresh-token-validity: 172800 + secret: "" + credhub_client: + override: true + authorized-grant-types: client_credentials + secret: secret + scope: uaa.none + authorities: credhub.read,credhub.write + access-token-validity: 86400 +jwt: + token: + signing-key: | + -----BEGIN RSA PRIVATE KEY----- + MIIEpAIBAAKCAQEAzmFA/hQZ8iIl2eaCW0XH1eZ2YuPNMhcaavyvGJwHUbXTUUhr + P7cYdNVgycqfRR+64qJ0ulsWpRdbdtQHCvTzzdX/KSTTepW2nxZNFKq+Re3M+L0L + GeL1maNJ3xLyJ6dvB9YmImI4k+suCOfNBEV03ZJmTxUw3CVjqCdKRpLunA48BeDq + +gQAMpBvL9jdMAXqEmsFhLYE/KWjdBzdjfgt7c29zHz4RX4/N9YS8Q8KWjWgo+Yg + HaNZpYs+6AZXrOEp25ZpTMhpseP6NgbNhgwKzsI5l9cV5cNvHQjODBPPsVoPgkiC + 0LRBMChs5h85e6KLrnjpj4njkzmjL5L7xngMRQIDAQABAoIBABMW79oQpe29tt6W + 8cvbgoaIkL7I73wIowruYIvYMt0eAnPsTO9R0lNMQW2o7l6IdtLrz/xE3K1cobs2 + FYiv67VIbBe0LlOScZf5ihu1R3BUdLc1VUeJtMoHTpfxurBsTlrdNh3MFAuqn1F3 + j4Ero4mzNv9tqF1UoAk3ySkKAkQw6le2bE4CKvN+XMLMQvYrdTKIHbNP5UYqmwQ1 + fVrdUALiXTJl5tRnWYOs+J2jdysRoti2lrHk94im9wCvHU/AqwMjnEDd1HePaWzD + SNb0T8Flk9wdb9jlhmsJBHKkG5E7yKJ/M7KgPCfbvJb3Br5W6kPSeuAS0ABE6VFZ + RcLKYKkCgYEA6zxlClAVz/vYiyhrIOXt53qEmKqH02Yfg+NeoujG8YffBeq5szsp + 1iiMnRNKXMeIRpR48dqvSV5HfhK1i052tVdQAa28CObScROts+0QH8aXHq0roINO + y+leqiq94yeSCTEBpEUTWKdYpdKhMw2PDlV0EwrhRP2j5BXbKUR+musCgYEA4JjN + YZ3qxPaOqclkM50vbrQN8WUimQywePmJi0pI2RBxSnknePiAP7cW8NCsZ10YXe5B + 4J8y14l17/oirtr+/S6bD1b//ZPrvX4K0mMiUVNzb05HSjYOTNwEtCc+24FHOlVW + fH50njSGRyxXBELDJGEuHBcgYaR+9aaoZ1MXyY8CgYAJA0xfw8fCK0UVt9u66/Rc + jR4td0My/1OvyvNiTIbq1CjgYijxTBADS5RvpECSI3b+NUwZACb9KaaVlwPrrXrw + 4cKH/e8ZbDad7IIYRbn7bbF2lG36fW10dKGS5YZXALogrgcBE0B1ghvsZpCUky1r + AC0tWZpd+VXhNFEsWJp9NwKBgQDAvwHLG44mGH5YgagHj4bsV4N7vdKSTEyKlYSP + 0GFyP2Uqh4zziTfu9j6uzjaWwlMuEVHh5l3okWRwXVc0fmbEeyHBaWVphm+SgL/i + zAbgimCPjjsqGfftyAgVX3TXRjwNeL0vPAry1prCK/BFjNIRv4ClxMcaZOQ8BxmR + CsNoSwKBgQC1KIdBUzuLkSxLAm3pEscS3F5yqpclM+eYE/ed4tT6ySqs46X2G0kQ + 6VoXd5fT4YgcHszhT7PuW6j8ywNGUN2Zz3Zl8xgxkIkdEZPrL1Hq5K7uBUDeUwhn + 96S9sIJEd58utQSu/FqFq14K7dFTQjMtC08T0shzTGhFnWcX85jTcA== + -----END RSA PRIVATE KEY----- + verification-key: | + -----BEGIN PUBLIC KEY----- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzmFA/hQZ8iIl2eaCW0XH + 1eZ2YuPNMhcaavyvGJwHUbXTUUhrP7cYdNVgycqfRR+64qJ0ulsWpRdbdtQHCvTz + zdX/KSTTepW2nxZNFKq+Re3M+L0LGeL1maNJ3xLyJ6dvB9YmImI4k+suCOfNBEV0 + 3ZJmTxUw3CVjqCdKRpLunA48BeDq+gQAMpBvL9jdMAXqEmsFhLYE/KWjdBzdjfgt + 7c29zHz4RX4/N9YS8Q8KWjWgo+YgHaNZpYs+6AZXrOEp25ZpTMhpseP6NgbNhgwK + zsI5l9cV5cNvHQjODBPPsVoPgkiC0LRBMChs5h85e6KLrnjpj4njkzmjL5L7xngM + RQIDAQAB + -----END PUBLIC KEY----- diff --git a/gradle.properties b/gradle.properties index 8c6a443..b267520 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -version=3.0.1-SNAPSHOT +version=3.1.0-SNAPSHOT org.gradle.parallel=true diff --git a/settings.gradle b/settings.gradle index 2a5476f..04681f5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -19,7 +19,7 @@ pluginManagement { id 'io.spring.nohttp' version '0.0.11' id 'io.spring.javaformat' version '0.0.35' id 'org.asciidoctor.jvm.convert' version '3.3.2' - id 'org.springframework.boot' version '3.0.2' + id 'org.springframework.boot' version '3.1.3' } repositories { gradlePluginPortal() diff --git a/spring-credhub-core/src/main/java/org/springframework/credhub/configuration/ClientHttpRequestFactoryFactory.java b/spring-credhub-core/src/main/java/org/springframework/credhub/configuration/ClientHttpRequestFactoryFactory.java index d009070..8c70096 100644 --- a/spring-credhub-core/src/main/java/org/springframework/credhub/configuration/ClientHttpRequestFactoryFactory.java +++ b/spring-credhub-core/src/main/java/org/springframework/credhub/configuration/ClientHttpRequestFactoryFactory.java @@ -26,9 +26,11 @@ import javax.net.ssl.X509TrustManager; import okhttp3.OkHttpClient.Builder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.client5.http.config.ConnectionConfig; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; @@ -163,8 +165,11 @@ public final class ClientHttpRequestFactoryFactory { RequestConfig.Builder requestConfigBuilder = RequestConfig.custom().setAuthenticationEnabled(true); if (options.getConnectionTimeout() != null) { - requestConfigBuilder - .setConnectTimeout(Timeout.ofMilliseconds(options.getConnectionTimeout().toMillis())); + BasicHttpClientConnectionManager basicHttpClientConnectionManager = new BasicHttpClientConnectionManager(); + Timeout connectTimeout = Timeout.ofMilliseconds(options.getConnectionTimeout().toMillis()); + ConnectionConfig.Builder connectionConfig = ConnectionConfig.custom().setConnectTimeout(connectTimeout); + basicHttpClientConnectionManager.setConnectionConfig(connectionConfig.build()); + httpClientBuilder.setConnectionManager(basicHttpClientConnectionManager); } httpClientBuilder.setDefaultRequestConfig(requestConfigBuilder.build()); diff --git a/spring-credhub-starter/src/main/java/org/springframework/credhub/autoconfig/CredHubOAuth2AutoConfiguration.java b/spring-credhub-starter/src/main/java/org/springframework/credhub/autoconfig/CredHubOAuth2AutoConfiguration.java index 10d611b..80b365c 100644 --- a/spring-credhub-starter/src/main/java/org/springframework/credhub/autoconfig/CredHubOAuth2AutoConfiguration.java +++ b/spring-credhub-starter/src/main/java/org/springframework/credhub/autoconfig/CredHubOAuth2AutoConfiguration.java @@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.security.oauth2.client.ClientsConfiguredCondition; import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties; -import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter; +import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper; import org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration; import org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -73,8 +73,9 @@ public class CredHubOAuth2AutoConfiguration { @ConditionalOnMissingBean @ConditionalOnClass(name = "jakarta.servlet.http.HttpServletRequest") public ClientRegistrationRepository credHubClientRegistrationRepository() { + List registrations = new ArrayList<>( - OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(this.properties).values()); + new OAuth2ClientPropertiesMapper(this.properties).asClientRegistrations().values()); return new InMemoryClientRegistrationRepository(registrations); } @@ -104,7 +105,7 @@ public class CredHubOAuth2AutoConfiguration { @ConditionalOnClass(name = "org.springframework.web.reactive.function.client.WebClient") public ReactiveClientRegistrationRepository credHubReactiveClientRegistrationRepository() { List registrations = new ArrayList<>( - OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(this.properties).values()); + new OAuth2ClientPropertiesMapper(this.properties).asClientRegistrations().values()); return new InMemoryReactiveClientRegistrationRepository(registrations); } diff --git a/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubTemplateAutoConfigurationTests.java b/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubTemplateAutoConfigurationTests.java index 782b260..c15d87d 100644 --- a/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubTemplateAutoConfigurationTests.java +++ b/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubTemplateAutoConfigurationTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties; -import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter; +import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper; import org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration; import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.FilteredClassLoader; @@ -231,7 +231,7 @@ public class CredHubTemplateAutoConfigurationTests { @Bean AuthorizedClientServiceOAuth2AuthorizedClientManager clientManager(OAuth2ClientProperties properties) { List registrations = new ArrayList<>( - OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values()); + new OAuth2ClientPropertiesMapper(properties).asClientRegistrations().values()); ClientRegistrationRepository clientRegistrationRepository = new InMemoryClientRegistrationRepository( registrations); OAuth2AuthorizedClientService authorizedClientService = new InMemoryOAuth2AuthorizedClientService( @@ -244,7 +244,7 @@ public class CredHubTemplateAutoConfigurationTests { AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager reactiveClientManager( OAuth2ClientProperties properties) { List registrations = new ArrayList<>( - OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values()); + new OAuth2ClientPropertiesMapper(properties).asClientRegistrations().values()); ReactiveClientRegistrationRepository clientRegistrationRepository = new InMemoryReactiveClientRegistrationRepository( registrations); ReactiveOAuth2AuthorizedClientService authorizedClientService = new InMemoryReactiveOAuth2AuthorizedClientService(