How do I programmatically authenticate a user in quarkus when reading from an inbound topic?

331 Views Asked by At

Okay, I admit this is a bit of a weird question. But we are in the process of moving our application from SpringBoot to Quarkus. So far, so good until I came upon this little problem.

In Spring, we have an InputChannelInterceptor which pulls out a custom header value from all messages in Kafka. This header value contains an access token, which we can then use to authenticate the user. Specifically, we @Autowire our authentication provider, which takes that token and returns a Principal. Then you can call Spring's SecurityContextHolder.getContext().setAuthentication(...) to set the principal for the remainder of the processing context.

I need to do something like this in Quarkus. So I have an interceptor already written, which pulls the access token out of the Kafka message. But I don't know how to do the actual authentication, nor how to establish the authorized user in the security context. Quarkus has a SecurityContext class, which is available for @Inject, but it has no mechanism that I can find to set the user, only retrieve the user.

Any help would really be appreciated.

0

There are 0 best solutions below