Giter Site home page Giter Site logo

majusko / grpc-jwt-spring-boot-starter Goto Github PK

View Code? Open in Web Editor NEW
38.0 38.0 7.0 191 KB

Spring boot starter for gRPC framework with JWT authorization

License: Other

Java 100.00%
annotations autowire grpc grpc-framework grpc-java grpc-library interceptor java java-library jwt jwt-authorization microservices ownerfield proto protobuf signing spring-boot springboot-starter

grpc-jwt-spring-boot-starter's Introduction

Mario Kapusta

- Driving small teams and open-source projects
- 8+ years of working on worlds high scale products
- 10+ years of commercial experience with languages Kotlin, Rust, Java, Scala, Node.js., PHP and C#
- 4+ years of designing micro-service systems using event sourcing and CQRS
- 4+ years of managing orchestration through Docker, Kubernetes, Marathon or Mesos
- 8+ years of deploying on AWS
- Client-side development using Unity 3D or AngulatJS
- Enjoying open-source development and participating in public game jams
- Creator of RampageManager.com, Learning games for kids, Bravko or Waat!?
- I wish to run my own game studio one day :) 

grpc-jwt-spring-boot-starter's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar gitter-badger avatar majusko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

grpc-jwt-spring-boot-starter's Issues

@Allow not failing, if no Token is sent by client

Hi there,

I tried to follow your instructions and make a very simple test with it:

  • Annotate a service method with @Allow(roles="admin")
  • Make a testcase to call that method without any token

I would have expected the call to fail (and therefore, also the test). But instead, it returns, successfully.

Here is an excerpt of the service:

@GRpcService
public class DataServiceImpl extends DataServiceImplBase {
	@Override
	@Allow(roles= "admin")
	public void getFirstBrick (Empty request, StreamObserver<GetBrickResponse> responseObserver) {
		...
	}
	...
}

... and here is the test:

@Test
public void testGetFirstBrick() {
	Brick brick = dataClient.getFirstBrick();
	assertThat(brick.getHeaderLevel()).isNotNull();
	assertThat(brick.getPredecessor()).isNull();
}

Could you guide me here?

Kind regards
Hauke

@Allow not failing, if multiple services exist

Hi Mario,

I am not sure, if this belongs to the previous issue. If so, we can also handle it there.

With a single grpc-service, the annotations work as expected. But when I have multiple services, at least one of them fails to apply the annotation.

In my demo project, I tried two different appraoches:

  • In the main branch, I have two .proto-files and two separated services, each in one package
  • In the branch services-in-same-directory, I put both service declarations in the same .proto-file and implemented the services in the same package.

The result for both approaches is the same. For approach 1, the first service reacts as expected, but the second doesn't:

~/repos/demo$ grpcurl --plaintext -proto ./src/main/proto/helloservice.proto -d '{"name": "test"}' localhost:6565 com.example.demo.helloservice.HelloService/SayHello
ERROR:
  Code: PermissionDenied
  Message: Missing JWT data.
~/repos/demo$ grpcurl --plaintext -proto ./src/main/proto/anotherhelloservice.proto -d '{"name": "test"}' localhost:6565 com.example.demo.anotherhelloservice.AnotherHelloService/SayHello
{
  "message": "Hello test"
}

... and for approach 2, the behaviour is the same:

~/repos/demo$ grpcurl --plaintext -proto ./src/main/proto/helloservice.proto -d '{"name": "test"}' localhost:6565 com.example.demo.helloservice.HelloService/SayHello
ERROR:
  Code: PermissionDenied
  Message: Missing JWT data.
~/repos/demo$ grpcurl --plaintext -proto ./src/main/proto/helloservice.proto -d '{"name": "test"}' localhost:6565 com.example.demo.helloservice.AnotherHelloService/SayHello
{
  "message": "Hello test"
}

Did I miss something, here?

Kind regards,
Hauke

p.s.: I also tried to even put the application starter into the same package. This also doesn't make any difference (and I would have been surprised, if so), just wanted to make sure

IllegalStateException: Authentication schemeBearer {jwtTokenHere} not supported

Hi!

I'm trying to secure my gRPC server with JWT but I can't make it work.
I already set the token generation but I can't make it validate my token since it always gives me "Authentication scheme Bearer {jwtCodeHere} not supported".

If I put a breakpoint inside AuthenticationSchemeService.class at like 24, I can see it's trying to validate my token as Basic instead of Bearer.

Repository with demo: https://github.com/mateusscheper/java-grpc-demo

How to test:

  • grpcurl -plaintext -d "{"email": "[email protected]", "password": "teste"}" localhost:9090 grpc.LoginService.login: Works. Returns JWT token;
  • grpcurl -plaintext -H "Authorization: Bearer {jwtTokenHere}" -d "{"name": "Mateus", "email": "[email protected]"}" localhost:9090 grpc.UserService.newUser: Gives "IllegalStateException: Authentication schemeBearer {jwtTokenHere} not supported".

What am I doing wrong?
Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.