diff --git a/build.gradle b/build.gradle index d184cdf..47db229 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,21 @@ // Copyright (c) 2022 AlertAvert.com. All rights reserved. // Author: Marco Massenzio (marco@alertavert.com) -// Minimalist build file just to get things going. -// See jwt-opa/build.gradle for the "real" build. plugins { id 'java' id 'jacoco' } + +ext { + // For the most recent version of the JWT-OPA library see: + // https://github.com/massenz/jwt-opa/releases + // This is likely to be the development, unreleased version. + jwtOpaVersion = "0.12.0" + + awsSdkVersion = '2.17.102' + jsonpathVersion = "2.5.0" + lombokVersion = "1.18.30" + minCoverageRatio = 0.80 + mockitoVersion = "3.6.0" + tcVersion = "1.19.1" +} diff --git a/compose.yml b/compose.yml index 2c8ff96..66c4a3c 100644 --- a/compose.yml +++ b/compose.yml @@ -6,7 +6,7 @@ services: opa: container_name: "opa" hostname: opa - image: openpolicyagent/opa:0.42.2 + image: openpolicyagent/opa:0.58.0 command: run --server --addr :8181 ports: - "8181:8181" diff --git a/jwt-opa/build.gradle b/jwt-opa/build.gradle index 2d046d4..f30e670 100644 --- a/jwt-opa/build.gradle +++ b/jwt-opa/build.gradle @@ -17,9 +17,9 @@ */ plugins { - id 'io.spring.dependency-management' version '1.1.3' id 'java' id 'jacoco' + id 'io.spring.dependency-management' version '1.1.3' id 'org.springframework.boot' version '3.1.5' // To upload the Artifact to Maven Central @@ -28,17 +28,9 @@ plugins { id 'signing' } -ext { - awsSdkVersion = '2.17.102' - jsonpathVersion = "2.5.0" - lombokVersion = "1.18.22" - minCoverageRatio = 0.80 - mockitoVersion = "3.6.0" - tcVersion = "1.15.1" -} group 'com.alertavert' -version '0.11.0' +version "${jwtOpaVersion}" // OpenJDK 17 LTS is the only Java version supported sourceCompatibility = JavaVersion.VERSION_17 diff --git a/run-example.sh b/run-example.sh index a10b84b..d267687 100755 --- a/run-example.sh +++ b/run-example.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2021 AlertAvert.com. All rights reserved. +# Copyright (c) 2021-2023 AlertAvert.com. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # http://www.apache.org/licenses/LICENSE-2.0 # @@ -13,6 +13,14 @@ OPA_SERVER=http://localhost:${OPA_PORT} POLICY_API=${OPA_SERVER}/v1/policies/userauth docker compose --project-name jwt-opa up -d + +# Sometimes the OPA server takes a while to start, so we wait for it to be ready +READY="" +while [[ -z ${READY} ]]; do + echo "Waiting for OPA server to start..." + sleep 1 + READY=$(docker logs opa 2>&1 | grep "Initializing server.") +done if [[ $(curl -s ${POLICY_API} | jq .result.id) != "userauth" ]]; then echo "Uploading userauth Policy" curl -T "${WORKDIR}/webapp-example/src/main/rego/jwt_auth.rego" -X PUT ${POLICY_API} diff --git a/webapp-example/build.gradle b/webapp-example/build.gradle index c13259a..5129a31 100644 --- a/webapp-example/build.gradle +++ b/webapp-example/build.gradle @@ -19,40 +19,29 @@ plugins { id 'java' id 'jacoco' - id 'org.springframework.boot' version '3.1.5' id 'io.spring.dependency-management' version '1.1.3' + id 'org.springframework.boot' version '3.1.5' } -group 'com.alertavert.opademo' -version = "0.4.0" +group 'com.alertavert' +version = "0.5.0" repositories { - // Adding local repository for Gradle to find jwt-opa before it gets published. - // Use: ./gradlew :jwt-opa:publishToMavenLocal - // mavenLocal() + mavenLocal() mavenCentral() } -ext { - // This can be changed to an yet-unpublished version by using mavenLocal() - // for local tests. - jwtOpaVersion = "0.10.0" - lombokVersion = "1.18.22" - tcVersion = "1.15.1" - awsSdkVersion = '2.17.102' -} - bootJar { mainClass.set('com.alertavert.opademo.JwtDemoApplication') } dependencies { - // We use the actual dependency here, instead of depending on the module in the repository so - // as to emulate an actual project using jwt-opa externally. - // Uncomment the following line (and comment out the one below) to use the local version - // while developing. - implementation project (':jwt-opa') -// implementation "com.alertavert:jwt-opa:${jwtOpaVersion}" + // ----- IMPORTANT ----- + // If you modify the following line, make sure to also update the `build.gradle` file in the + // `test-released` branch, so that the CI tests can run against the released version. + // We depend here on the the local version here, so we can verify changes while developing: + implementation project (':jwt-opa') + // ----- SECTION ENDS ----- // For the @PostConstruct annotation implementation 'javax.annotation:javax.annotation-api:1.3.2' diff --git a/webapp-example/src/main/resources/application.yaml b/webapp-example/src/main/resources/application.yaml index d65f3d2..1bbf6ad 100644 --- a/webapp-example/src/main/resources/application.yaml +++ b/webapp-example/src/main/resources/application.yaml @@ -101,7 +101,7 @@ keys: # For a PASSPHRASE, the secret is simply read from SecretsManager/Vault # The keypair is stored as a JSON-formatted secret, with two keys: "priv" and "pub". location: keypair - name: private/ec-key + name: ../private/ec-key logging: level: