From cdf0899554a20ba7f82616fa44e795ca38dc4c9f Mon Sep 17 00:00:00 2001 From: Alexander Furer Date: Wed, 21 Oct 2020 17:55:37 +0300 Subject: [PATCH] release 4.2.0, fixes #159 --- README.adoc | 18 ++++++- ReleaseNotes.adoc | 6 ++- build.gradle | 4 -- gradle.properties | 6 ++- grpc-spring-boot-starter-demo/build.gradle | 52 +++++++++++-------- .../io/grpc/examples/CalculatorGrpc.java | 2 +- .../io/grpc/examples/GreeterGrpc.java | 2 +- .../io/grpc/examples/SecuredGreeterGrpc.java | 2 +- grpc-spring-boot-starter/build.gradle | 2 +- .../GrpcServiceAuthorizationConfigurer.java | 7 ++- 10 files changed, 62 insertions(+), 39 deletions(-) diff --git a/README.adoc b/README.adoc index d8ffebc4..cfc16672 100644 --- a/README.adoc +++ b/README.adoc @@ -23,7 +23,7 @@ Starting from release `4.0.0` the starter is compiled and tested against Spring == Setup -[source,gradle] +[source,groovy] ---- repositories { mavenCentral() @@ -31,12 +31,26 @@ repositories { } dependencies { - compile 'io.github.lognet:grpc-spring-boot-starter:4.1.0' + compile 'io.github.lognet:grpc-spring-boot-starter:4.2.0' } ---- +If you are using Spring Boot Dependency Management plugin, it might pull not the same version as the version this started was compiled against, causing binary incompatibility issue. + +In this case you'll need to forcibly and implicitly set the `grpc` version to use (see link:ReleaseNotes.adoc[version matrix here^] ): + +[source,groovy] +---- +configurations.all { + resolutionStrategy.eachDependency { details -> + if ("io.grpc".equalsIgnoreCase(details.requested.group)) { + details.useVersion "1.33.0" + } + } +} +---- + [IMPORTANT] Starting from release `3.0.0` the artifacts are published to *maven central*. Pay attention that `group` has changed from `org.lognet` to `io.github.lognet`. diff --git a/ReleaseNotes.adoc b/ReleaseNotes.adoc index 1e69f75e..982aa755 100644 --- a/ReleaseNotes.adoc +++ b/ReleaseNotes.adoc @@ -1,5 +1,9 @@ +== Version 4.2.0 +* gRPC version upgraded to 1.33.0 +* Fixed the issue with default method-level `@Secured` annotation (see #159) + == Version 4.1.0 -* gRPC version upgraded to 1.31.2 +* gRPC version upgraded to 1.32.2 * Fixed the issue with obtaining `Authentication` details in secured method implementation. * Fixed the issue with providing client-side user credentials. diff --git a/build.gradle b/build.gradle index a7f40781..f460ef5f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,4 @@ buildscript { - ext { - springBoot_2_X_Version = '2.3.3.RELEASE' - grpcVersion = '1.32.2' - } repositories { mavenCentral() jcenter() diff --git a/gradle.properties b/gradle.properties index 0584a7f0..2b42948a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,8 @@ -version=4.2.0-SNAPSHOT +grpcVersion=1.33.0 +springBootVersion=2.3.3.RELEASE +springCloudVersion=Hoxton.SR6 + +version=4.2.0 group=io.github.lognet description=Spring Boot starter for Google RPC. gitHubUrl=https\://github.com/LogNet/grpc-spring-boot-starter diff --git a/grpc-spring-boot-starter-demo/build.gradle b/grpc-spring-boot-starter-demo/build.gradle index 1c234c16..66b185c1 100644 --- a/grpc-spring-boot-starter-demo/build.gradle +++ b/grpc-spring-boot-starter-demo/build.gradle @@ -1,32 +1,37 @@ - buildscript { repositories { mavenCentral() } dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBoot_2_X_Version}") + classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'com.google.protobuf' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' -ext { - set('springCloudVersion', "Hoxton.SR6") + + +dependencyManagement { + imports { + mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}" + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" + } } + dependencies { - compile "org.springframework.boot:spring-boot-starter-actuator" - compile 'org.springframework.boot:spring-boot-starter-web' + implementation "org.springframework.boot:spring-boot-starter-actuator" + implementation 'org.springframework.boot:spring-boot-starter-web' - compile "org.springframework.security:spring-security-config" - compile "org.springframework.security:spring-security-oauth2-jose" - compile "org.springframework.security:spring-security-oauth2-resource-server" + implementation "org.springframework.security:spring-security-config" + implementation "org.springframework.security:spring-security-oauth2-jose" + implementation "org.springframework.security:spring-security-oauth2-resource-server" - compile project(':grpc-spring-boot-starter') - compile project(':grpc-client-spring-boot-starter') + implementation project(':grpc-spring-boot-starter') + implementation project(':grpc-client-spring-boot-starter') testCompile 'org.springframework.boot:spring-boot-starter-aop' testCompile 'org.springframework.boot:spring-boot-starter-test' @@ -40,15 +45,22 @@ dependencies { testRuntime "org.springframework.cloud:spring-cloud-starter" - testImplementation 'org.hamcrest:hamcrest:2.1' testImplementation 'org.mockito:mockito-core:2.23.0' - //testCompile "org.testcontainers:junit-jupiter:1.14.3" + +} + +configurations.all { + resolutionStrategy.eachDependency { details -> + if ("io.grpc".equalsIgnoreCase(details.requested.group)) { + details.useVersion grpcVersion + } + } } sourceSets { main { @@ -71,7 +83,7 @@ protobuf { generateProtoTasks { ofSourceSet('main').each { task -> task.builtins { - java{ + java { outputSubDir = 'protoGen' } } @@ -85,20 +97,14 @@ protobuf { generatedFilesBaseDir = "$projectDir/src/" } -task cleanProtoGen{ - doFirst{ - delete("$projectDir/src/main/protoGen") +task cleanProtoGen { + doFirst { + delete("$projectDir/src/main/protoGen") } } clean.dependsOn cleanProtoGen -dependencyManagement { - imports { - mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBoot_2_X_Version}" - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } -} diff --git a/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/CalculatorGrpc.java b/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/CalculatorGrpc.java index b6e7a0dc..9f11ac64 100644 --- a/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/CalculatorGrpc.java +++ b/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/CalculatorGrpc.java @@ -10,7 +10,7 @@ /** */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.32.2)", + value = "by gRPC proto compiler (version 1.33.0)", comments = "Source: calculator.proto") public final class CalculatorGrpc { diff --git a/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/GreeterGrpc.java b/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/GreeterGrpc.java index 2b70dcd8..0e3ed013 100644 --- a/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/GreeterGrpc.java +++ b/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/GreeterGrpc.java @@ -13,7 +13,7 @@ * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.32.2)", + value = "by gRPC proto compiler (version 1.33.0)", comments = "Source: greeter.proto") public final class GreeterGrpc { diff --git a/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/SecuredGreeterGrpc.java b/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/SecuredGreeterGrpc.java index a4841f82..eac3fe60 100644 --- a/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/SecuredGreeterGrpc.java +++ b/grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/SecuredGreeterGrpc.java @@ -10,7 +10,7 @@ /** */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.32.2)", + value = "by gRPC proto compiler (version 1.33.0)", comments = "Source: greeter.proto") public final class SecuredGreeterGrpc { diff --git a/grpc-spring-boot-starter/build.gradle b/grpc-spring-boot-starter/build.gradle index 52a14d47..0e38e0d4 100644 --- a/grpc-spring-boot-starter/build.gradle +++ b/grpc-spring-boot-starter/build.gradle @@ -4,7 +4,7 @@ buildscript { mavenCentral() } dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBoot_2_X_Version}") + classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath "io.franzbecker:gradle-lombok:4.0.0" } } diff --git a/grpc-spring-boot-starter/src/main/java/org/lognet/springboot/grpc/security/GrpcServiceAuthorizationConfigurer.java b/grpc-spring-boot-starter/src/main/java/org/lognet/springboot/grpc/security/GrpcServiceAuthorizationConfigurer.java index fcf36009..a07a20a2 100644 --- a/grpc-spring-boot-starter/src/main/java/org/lognet/springboot/grpc/security/GrpcServiceAuthorizationConfigurer.java +++ b/grpc-spring-boot-starter/src/main/java/org/lognet/springboot/grpc/security/GrpcServiceAuthorizationConfigurer.java @@ -18,7 +18,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -118,10 +120,7 @@ public GrpcSecurity withSecuredAnnotation() { // method level security for(ServerMethodDefinition methodDefinition :serverServiceDefinition.getMethods()){ Stream.of(service.getClass().getMethods()) // get method from methodDefinition - .filter(m -> { - final String methodName = methodDefinition.getMethodDescriptor().getFullMethodName().substring(methodDefinition.getMethodDescriptor().getServiceName().length() + 1); - return methodName.equalsIgnoreCase(m.getName()); - }) + .filter(m -> 0==Objects.compare(methodDefinition.getMethodDescriptor().getBareMethodName(),m.getName(), Comparator.naturalOrder())) .findFirst() .flatMap(m->Optional.ofNullable(AnnotationUtils.findAnnotation(m, Secured.class))) .ifPresent(secured -> new AuthorizedMethod(methodDefinition.getMethodDescriptor()) .hasAnyAuthority(secured.value()));