Hi,

We have a dropwizard 1.1 service which authenticates inbound requests using 
dropwizard-auth and I'm hoping to get access to that Principal in classes 
which aren't resources.  The tl;dr for why, is we have our own internal 
authentication mechanism which retrieves a token from an http header and 
needs to pass a variant of that header back out on any outbound requests it 
makes to other services.  Unfortunately I basically have no idea how the 
jersey injection works... At all.

What I'm *hoping* to be able to do is register a ClientRequestFilter which 
will thread the Principal from the inbound HttpServletRequest through to 
the outbound jersey client request.  Something like:

```
public class AuthenticationContextInjectionFilter implements 
ClientRequestFilter {
    public static final String OUTBOUND_HEADER_NAME = "Some-Thing";

    @Inject // Or is it @Context?
    private Provider<MyPrincipalClass> principal; // Have also tried 
Provider<Principal>

    @Override
    public void filter(ClientRequestContext requestContext) throws 
IOException {
        final MyPrincipalClass principalVal = this.principal.get();
        requestContext.getHeaders().add(OUTBOUND_HEADER_NAME, 
principalVal.getHeader());
    }
}

// and in my Application
environment.jersey().register(AuthenticationContextInjectionFilter.class);
```

However, it's basically always null so however jersey's injection works is 
clearly not the way I think it works.

Is it possible to achieve what I'm trying to do here?  I can probably biff 
the value into a ThreadLocal to work around this, but that feels a little 
like i'm surrendering.  Is there some introductory documentation I could 
read on this stuff?  




-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to