From e4a48d15d635a64aaff4eb1610cc5bd6432f2c29 Mon Sep 17 00:00:00 2001 From: Ann Catton Date: Fri, 4 Jun 2021 10:08:52 -0400 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=94=96=204.6.2-SNAPSHOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70bcbf7f..4b283fa6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ bio.overture ego - 4.5.2 + 4.6.2-SNAPSHOT ego OAuth 2.0 Authorization service that supports multiple OpenID Connect Providers From 87099cc0bca72085ae92bc434582c435060799c5 Mon Sep 17 00:00:00 2001 From: Yelizar Alturmessov Date: Fri, 16 Jul 2021 08:49:27 -0400 Subject: [PATCH 2/7] Jenkinsfile update Replace docker socket mount with docker host env vars. --- Jenkinsfile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 723681a5..08568284 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,14 +35,10 @@ spec: - name: docker image: docker:18-git tty: true - volumeMounts: - - mountPath: /var/run/docker.sock - name: docker-sock + env: + - name: DOCKER_HOST + value: tcp://localhost:2375 volumes: - - name: docker-sock - hostPath: - path: /var/run/docker.sock - type: File - name: docker-graph-storage emptyDir: {} """ From 88a6ed25eada1a3cb18d89260c57d0cd5b8bb30c Mon Sep 17 00:00:00 2001 From: Yelizar Alturmessov Date: Fri, 16 Jul 2021 11:18:39 -0400 Subject: [PATCH 3/7] Jenkinsfile update Set explicit UIDs for containers. --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 08568284..c1329b78 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,6 +24,7 @@ spec: image: docker:18.06-dind securityContext: privileged: true + runAsUser: 0 volumeMounts: - name: docker-graph-storage mountPath: /var/lib/docker @@ -38,6 +39,8 @@ spec: env: - name: DOCKER_HOST value: tcp://localhost:2375 + securityContext: + runAsUser: 1000 volumes: - name: docker-graph-storage emptyDir: {} From 6c1303ad7b64d5adcc03b09ca3a116bbf78435d9 Mon Sep 17 00:00:00 2001 From: Yelizar Alturmessov <65674408+yalturmes@users.noreply.github.com> Date: Wed, 21 Jul 2021 10:33:05 -0400 Subject: [PATCH 4/7] Update Jenkinsfile Set explicit HOME env var for docker client container. --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c1329b78..9738c04d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,8 +37,10 @@ spec: image: docker:18-git tty: true env: - - name: DOCKER_HOST - value: tcp://localhost:2375 + - name: DOCKER_HOST + value: tcp://localhost:2375 + - name: HOME + value: /home/jenkins/agent securityContext: runAsUser: 1000 volumes: From 2fd2d2390e252173003f43ff354022b48e760bd8 Mon Sep 17 00:00:00 2001 From: blabadi Date: Mon, 15 Nov 2021 09:25:06 -0500 Subject: [PATCH 5/7] wip: upgrade spring boot upgrade spring cloud version fix profiles fix vault update for new pageable interface --- docker-compose-all.yml | 31 +++++++++++++++++++ docker-compose.yml | 27 +++++----------- pom.xml | 16 ++++++++-- .../controller/resolver/PageableResolver.java | 7 ++++- .../bio/overture/ego/grpc/ProtoUtils.java | 7 ++++- .../ego/utils/IgnoreCaseSortDecorator.java | 26 ++++++++++++++++ src/main/resources/application.yml | 26 +++++++++++----- 7 files changed, 108 insertions(+), 32 deletions(-) create mode 100644 docker-compose-all.yml diff --git a/docker-compose-all.yml b/docker-compose-all.yml new file mode 100644 index 00000000..544bc940 --- /dev/null +++ b/docker-compose-all.yml @@ -0,0 +1,31 @@ +version: '3.7' +services: + api: + build: + context: ./ + dockerfile: Dockerfile + restart: always + environment: + SERVER_PORT: 8080 + SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/ego?stringtype=unspecified + SPRING_DATASOURCE_USERNAME: postgres + SPRING_DATASOURCE_PASSWORD: password + SPRING_FLYWAY_ENABLED: "true" + SPRING_FLYWAY_LOCATIONS: "classpath:flyway/sql,classpath:db/migration" + SPRING_PROFILES: demo, auth + expose: + - "8080" + ports: + - "$API_HOST_PORT:8080" + depends_on: + - postgres + postgres: + image: postgres:12.6 + restart: always + environment: + - POSTGRES_DB=ego + - POSTGRES_PASSWORD=password + expose: + - "5432" + ports: + - "8432:5432" diff --git a/docker-compose.yml b/docker-compose.yml index 544bc940..41fdfed2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,24 +1,12 @@ version: '3.7' services: - api: - build: - context: ./ - dockerfile: Dockerfile - restart: always + ego-ui: + image: overture/ego-ui:edge + network_mode: host environment: - SERVER_PORT: 8080 - SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/ego?stringtype=unspecified - SPRING_DATASOURCE_USERNAME: postgres - SPRING_DATASOURCE_PASSWORD: password - SPRING_FLYWAY_ENABLED: "true" - SPRING_FLYWAY_LOCATIONS: "classpath:flyway/sql,classpath:db/migration" - SPRING_PROFILES: demo, auth - expose: - - "8080" - ports: - - "$API_HOST_PORT:8080" - depends_on: - - postgres + REACT_APP_API: http://localhost:8081 + REACT_APP_EGO_CLIENT_ID: ego-ui + postgres: image: postgres:12.6 restart: always @@ -28,4 +16,5 @@ services: expose: - "5432" ports: - - "8432:5432" + - "5432:5432" + diff --git a/pom.xml b/pom.xml index 4b283fa6..5ae45afc 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.8.RELEASE + 2.5.6 @@ -87,6 +87,7 @@ spring-boot-starter-test test + org.springframework.security spring-security-test @@ -106,7 +107,10 @@ org.springframework.session spring-session-core - + + org.springframework.boot + spring-boot-starter-validation + com.h2database @@ -292,6 +296,12 @@ test + + org.junit.vintage + junit-vintage-engine + test + + org.springframework.boot spring-boot-devtools @@ -416,7 +426,7 @@ org.springframework.cloud spring-cloud-dependencies - Greenwich.SR2 + 2020.0.4 pom import diff --git a/src/main/java/bio/overture/ego/controller/resolver/PageableResolver.java b/src/main/java/bio/overture/ego/controller/resolver/PageableResolver.java index 9e521b2b..558b0a18 100644 --- a/src/main/java/bio/overture/ego/controller/resolver/PageableResolver.java +++ b/src/main/java/bio/overture/ego/controller/resolver/PageableResolver.java @@ -96,7 +96,7 @@ public Sort getSort() { // TODO: this is a hack for now to provide default sort on id field // ideally we should not be making assumption about field name as "id" - it will break if // field doesn't exist - return new Sort(direction, StringUtils.isEmpty(sort) ? "id" : sort); + return Sort.by(direction, StringUtils.isEmpty(sort) ? "id" : sort); } @Override @@ -114,6 +114,11 @@ public Pageable first() { return null; } + @Override + public Pageable withPage(int pageNumber) { + throw new RuntimeException("Not implemented"); + } + @Override public boolean hasPrevious() { return false; diff --git a/src/main/java/bio/overture/ego/grpc/ProtoUtils.java b/src/main/java/bio/overture/ego/grpc/ProtoUtils.java index 23a01079..c88421bb 100644 --- a/src/main/java/bio/overture/ego/grpc/ProtoUtils.java +++ b/src/main/java/bio/overture/ego/grpc/ProtoUtils.java @@ -87,6 +87,11 @@ public Pageable first() { return null; } + @Override + public Pageable withPage(int pageNumber) { + throw new RuntimeException("Not implemented"); + } + @Override public boolean hasPrevious() { return false; @@ -97,7 +102,7 @@ public boolean hasPrevious() { public static Sort parseSort(String sort) { if (sort.isEmpty()) { // Sort results by creation time, ensure static order for the page_token to refer to - return new Sort(Sort.Direction.ASC, JavaFields.CREATEDAT); + return Sort.by(Sort.Direction.ASC, JavaFields.CREATEDAT); } else { val orders = Arrays.stream(sort.split(",")) diff --git a/src/main/java/bio/overture/ego/utils/IgnoreCaseSortDecorator.java b/src/main/java/bio/overture/ego/utils/IgnoreCaseSortDecorator.java index 17c421e5..3726010b 100644 --- a/src/main/java/bio/overture/ego/utils/IgnoreCaseSortDecorator.java +++ b/src/main/java/bio/overture/ego/utils/IgnoreCaseSortDecorator.java @@ -4,6 +4,7 @@ import static org.springframework.util.StringUtils.isEmpty; import java.util.Map; +import java.util.Optional; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.val; @@ -29,11 +30,26 @@ public Sort getSort() { return Sort.by(orders); } + @Override + public Sort getSortOr(Sort sort) { + return delegate.getSortOr(sort); + } + private String getSortField(String sort) { val mapValue = SORT_MAP.get(sort); return isEmpty(mapValue) ? sort : mapValue; } + @Override + public boolean isPaged() { + return delegate.isPaged(); + } + + @Override + public boolean isUnpaged() { + return delegate.isUnpaged(); + } + /** Delegated methods */ @Override public int getPageNumber() { @@ -65,8 +81,18 @@ public Pageable first() { return delegate.first(); } + @Override + public Pageable withPage(int pageNumber) { + return delegate.withPage(pageNumber); + } + @Override public boolean hasPrevious() { return delegate.hasPrevious(); } + + @Override + public Optional toOptional() { + return Optional.of(delegate); + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 600510c6..9d3f80a5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -38,7 +38,6 @@ spring.main.allow-bean-definition-overriding: true spring.datasource: driver-class-name: org.postgresql.Driver url: jdbc:postgresql://localhost:5432/ego?stringtype=unspecified - username: postgres password: password max-active: 10 @@ -46,6 +45,9 @@ spring.datasource: min-idle: 1 spring: + cloud: + vault: + enabled: false flyway: enabled: false placeholders: @@ -198,7 +200,9 @@ initialization: # Profile - "jks" ############################################################################### spring: - profiles: jks + config: + activate: + on-profile: jks token: key-store: src/main/resources/ego-jwt.jks @@ -210,8 +214,9 @@ token: # Profile - "auth" ############################################################################### spring: - profiles: auth - profiles.include: secure + config: + activate: + on-profile: auth # security auth: @@ -231,7 +236,9 @@ logging: # Profile - "demo" ############################################################################### spring: - profiles: grpc + config: + activate: + on-profile: grpc grpc: port: 50051 @@ -241,14 +248,17 @@ grpc: # Profile - "demo" ############################################################################### spring: - profiles: demo - + config: + activate: + on-profile: demo --- ############################################################################### # Profile - "test" ############################################################################### spring: - profiles: test + config: + activate: + on-profile: test # To log the httpRequests and httpResponses for the controllers, set to true logging.test.controller.enable: false From c613878c08e30a42c13448785c218826ab501a4b Mon Sep 17 00:00:00 2001 From: blabadi Date: Wed, 17 Nov 2021 00:09:31 -0500 Subject: [PATCH 6/7] wip: fix tests --- .../model/exceptions/ExceptionHandlers.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/bio/overture/ego/model/exceptions/ExceptionHandlers.java b/src/main/java/bio/overture/ego/model/exceptions/ExceptionHandlers.java index fd4cdb42..20835a1c 100644 --- a/src/main/java/bio/overture/ego/model/exceptions/ExceptionHandlers.java +++ b/src/main/java/bio/overture/ego/model/exceptions/ExceptionHandlers.java @@ -2,8 +2,11 @@ import static java.lang.String.format; import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.NOT_FOUND; import bio.overture.ego.utils.Joiners; +import java.util.Date; +import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.validation.ConstraintViolationException; import lombok.extern.slf4j.Slf4j; @@ -17,6 +20,21 @@ @ControllerAdvice public class ExceptionHandlers { + @ExceptionHandler(NotFoundException.class) + public ResponseEntity handleConstraintViolationException( + HttpServletRequest req, NotFoundException ex) { + val message = ex.getMessage(); + log.error(message); + return new ResponseEntity( + Map.of( + "message", ex.getMessage(), + "timestamp", new Date(), + "path", req.getServletPath(), + "error", NOT_FOUND.getReasonPhrase()), + new HttpHeaders(), + NOT_FOUND); + } + @ExceptionHandler(ConstraintViolationException.class) public ResponseEntity handleConstraintViolationException( HttpServletRequest req, ConstraintViolationException ex) { From 8831029e700ec1dbe07366545f33906a5141ac07 Mon Sep 17 00:00:00 2001 From: blabadi Date: Tue, 4 Jan 2022 20:03:56 -0500 Subject: [PATCH 7/7] rc/5.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ae45afc..f8f8301b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ bio.overture ego - 4.6.2-SNAPSHOT + 5.0.0 ego OAuth 2.0 Authorization service that supports multiple OpenID Connect Providers