We work with DW+guice(in kotin) - im creating an a...
# server
n
We work with DW+guice(in kotin) - im creating an authentication filter and i was wondering if there's a way to inject the user info directly to the controller methods? or i have to use this approach as put here: https://github.com/google/guice/wiki/ServletModule#using-requestscope
r
You should at least specify what is DW.
n
sorry
dropwizard.
TLDR - i want to inject authenticated user directly to the controller method without doing something like userProvider.get inside the method body
where userProvider is of type Provider<UserInfo>
j
how are you auth-ing the user? if you're using dropwizard-auth you should just be able to add an
@Auth
annotated parameter to the resource method(s) and jersey/hk2 will inject the auth'ed principal; guice wouldn't be involved at all (unless maybe you're using one of the guice DI bridges?).
n
we're using a custom annotation+filter
n
we're not using dropwizard auth. just implmenting our own ContainerRequestFilter
j
yeah if its your own custom logic harder to help, but maybe looking at how the dw-auth source code implements
@Auth
annotated injection would be helpful