How to use dropwizard-auth and allow mix of open and auth'ed APIs?

59 views
Skip to first unread message

John Bedalov

unread,
Sep 9, 2021, 12:58:59 PM9/9/21
to dropwizard-user
We have a requirement to have a mix of open and auth'ed APIs. Is there a configuration technique to do so using dropwizard-auth?

I have something working by adding my own AuthFilter that then defers to BasicAuthFilter if the path is one that I need to auth. Like this

BasicCredentialAuthFilter<PrincipalImpl> basicAuthFilter = new Builder<PrincipalImpl>()
.buildAuthFilter();

return new AuthFilter<>()
{
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
if (((ContainerRequest) requestContext).getPath(true).equals("foo")) {
basicAuthFilter.filter(requestContext);
}
}
};

Thanks for any info!

Ryan Kennedy

unread,
Sep 9, 2021, 2:16:58 PM9/9/21
to dropwiz...@googlegroups.com
Would the chained factories in dropwizard-auth meet your needs?

--
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 dropwizard-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dropwizard-user/8b64d221-d54e-4016-b8ce-0f0395513723n%40googlegroups.com.

Jochen Schalanda

unread,
Sep 9, 2021, 4:54:31 PM9/9/21
to dropwizard-user
Hi John,

when using the authentication mechanisms provided by Jersey and Dropwizard Authentication, you can use the regular @PermitAll and @RolesAllowed annotations on JAX-RS resource classes and resource methods.


Cheers,
Jochen

Reply all
Reply to author
Forward
0 new messages