Skip to content

Commit

Permalink
Merge pull request #372 from overture-stack/develop
Browse files Browse the repository at this point in the history
Merges develop into master for new stable.
  • Loading branch information
andricDu authored Aug 2, 2019
2 parents 75d92d3 + 21d2552 commit e68b6ae
Show file tree
Hide file tree
Showing 81 changed files with 3,534 additions and 3,529 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ executorType: machine
jobs:
test:
docker:
- image: circleci/openjdk:8-jdk
- image: circleci/openjdk:11-jdk

working_directory: ~/repo

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM java:8-jdk
FROM openjdk:11.0.3-jdk

ARG MAVEN_VERSION=3.5.3
ARG SHA=b52956373fab1dd4277926507ab189fb797b3bc51a2a267a193c931fffad8408
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[![Slack](http://slack.overture.bio/badge.svg)](http://slack.overture.bio)

## Table of Contents

- [Documentation](#documentation)
- [Introduction](#introduction)
- [Features](#features)
- [Tech Stack](#tech-stack)
Expand All @@ -27,6 +27,10 @@
- [Shoutouts](#shoutouts)
- [Browserstack](#browserstack)

## Documentation

Explore documentation with the Ego [Read the Docs](https://ego.readthedocs.io/en/latest/).

## Introduction

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Expand Down
91 changes: 77 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@

<groupId>bio.overture</groupId>
<artifactId>ego</artifactId>
<version>2.2.1</version>
<version>2.2.2-SNAPSHOT</version>

<name>ego</name>
<description>OAuth 2.0 Authorization service that supports multiple OpenID Connect Providers</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>11</java.version>
<mapstruct.version>1.2.0.Final</mapstruct.version>
<grpc.version>1.19.0</grpc.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -59,8 +60,10 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
Expand Down Expand Up @@ -124,17 +127,17 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.7.2</version>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>jdbc</artifactId>
<version>1.7.2</version>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.7.2</version>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand All @@ -159,7 +162,7 @@
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.23.0</version>
<version>1.28.0</version>
</dependency>

<!-- Json Web Tokens -->
Expand All @@ -172,16 +175,10 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
<version>2.9.9.1</version>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.11.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.javacrumbs.json-unit</groupId>
<artifactId>json-unit-fluent</artifactId>
Expand Down Expand Up @@ -239,6 +236,39 @@
<version>${mapstruct.version}</version>
</dependency>

<!-- gRPC -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.1-jre</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
<version>${grpc.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand All @@ -251,9 +281,22 @@
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>

</dependencies>

<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>

<plugins>
<plugin>
<groupId>com.coveo</groupId>
Expand Down Expand Up @@ -300,6 +343,26 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier}</protocArtifact>
<protoSourceRoot>${basedir}/src/main/proto</protoSourceRoot>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.19.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public PolicyController(
dataType = "string",
paramType = "query",
value = "Search for ids containing this text"),
@ApiImplicitParam(
name = Fields.NAME,
required = false,
dataType = "string",
paramType = "query",
value = "Search for polices whose names containing this text"),
@ApiImplicitParam(
name = LIMIT,
required = false,
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/bio/overture/ego/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,18 @@ public void deleteGroupsFromUser(
public @ResponseBody User addApplicationsToUser(
@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = true) final String accessToken,
@PathVariable(value = "id", required = true) UUID id,
@RequestBody(required = true) List<UUID> appIds) {
return userService.addUserToApps(id, appIds);
@RequestBody(required = true) List<UUID> applicationIds) {
return userService.associateApplicationsWithUser(id, applicationIds);
}

@AdminScoped
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}/applications/{appIds}")
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}/applications/{applicationIds}")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Delete Applications from User")})
@ResponseStatus(value = HttpStatus.OK)
public void deleteApplicationsFromUser(
@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = true) final String accessToken,
@PathVariable(value = "id", required = true) UUID id,
@PathVariable(value = "appIds", required = true) List<UUID> appIds) {
userService.deleteUserFromApps(id, appIds);
@PathVariable(value = "applicationIds", required = true) List<UUID> applicationIds) {
userService.disassociateApplicationsFromUser(id, applicationIds);
}
}
71 changes: 71 additions & 0 deletions src/main/java/bio/overture/ego/grpc/GrpcServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package bio.overture.ego.grpc;

import bio.overture.ego.grpc.interceptor.AuthInterceptor;
import bio.overture.ego.grpc.service.UserServiceGrpcImpl;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.ServerInterceptors;
import java.util.Optional;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Profile("grpc")
public class GrpcServer implements CommandLineRunner, DisposableBean {

@Value("${grpc.port}")
private int port;

private Server server;

private final AuthInterceptor authInterceptor;
private final UserServiceGrpcImpl userServiceImpl;

@Autowired
public GrpcServer(
@NonNull AuthInterceptor authInterceptor, @NonNull UserServiceGrpcImpl userServiceImpl) {

this.authInterceptor = authInterceptor;

this.userServiceImpl = userServiceImpl;
}

@Override
public void run(String... args) throws Exception {

val userService = ServerInterceptors.intercept(userServiceImpl, authInterceptor);

server = ServerBuilder.forPort(port).addService(userService).build().start();

log.info("gRPC Server started, listening on " + port);
startDaemonAwaitThread();
}

private void startDaemonAwaitThread() {
Thread awaitThread =
new Thread(
() -> {
try {
this.server.awaitTermination();
} catch (InterruptedException e) {
log.error("gRPC server stopped.", e);
}
});
awaitThread.start();
}

@Override
public final void destroy() throws Exception {
log.info("Shutting down gRPC server ...");
Optional.ofNullable(server).ifPresent(Server::shutdown);
log.info("gRPC server stopped.");
}
}
Loading

0 comments on commit e68b6ae

Please sign in to comment.