How to get HttpServletRequest @Context in DropWizard Auth

I use Basic Auth in Dropwizard 0.8 and I need to access the request context in my SimpleAuthenticator class, in addition to the basic credentials.

Perhaps for this I need my own implementation of AuthFactory?

I want to implement basic access control for Basic Auth based on the requested resource path.

thank

John

+4
source share
2 answers
    @PermitAll
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getResponse(**@Context** SecurityContext context) {
        SimplePrincipal principal = (SimplePrincipal)context.getUserPrincipal();

        return Response.ok("{\"Hello\": \"" + principal.getUsername() + "\"}").build();
    }

Using @Context is enough for basic atleast authorization for Dropwizard version 0.9.2

+1
source

0.8, 0.9+ @Auth @PermitAll , , . ? ?

auth 0.9. Dropwizard: BasicAuth .

0

All Articles