I've built a small sample API using drop wizard.
I would like to implement basic authentication for the server. So that when users access the service, the service returns the data based on the user credentials sent with the request.
I went over the documentation for authentication: http://dropwizard.codahale.com/manual/auth/ but don't quite understand how it would work in an actual running example.
Can someone shed some light on how authentication would work on a url like /foo/bar/{id}/{username}?
This is how the method looks like for the above URL at the moment. Notice I am just passing the username as a text and no authentication is done at the moment.
@GET
@Path(/foo/bar/{id}/{username})
public Foo getStuff (@PathParam("id") int id, @PathParam("username")) {
return mydao.getFooFromDb(id,username)
}
Have a look at the Dropwizard OpenID example I wrote a while back on GitHub.
It provides all the source code you'll need to get it working and should act as a useful starting point for your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With