In this recipe, we will explore how to secure API endpoints using the HTTP basic authentication scheme with Play 2.0. We will use the Apache Commons Codec library for Base64 encoding and decoding for this recipe. This dependency is implicitly imported by Play and we will not need to explicitly declare it to our library dependencies in
For Java, we need to perform the following steps:
foo_javaapplication with Hot-Reloading enabled:
play.mvc.Security.Authenticatorimplementation class in
foo_java/app/controllers/BasicAuthenticator.javawith the following content:
package controllers; import org.apache.commons.codec.binary.Base64; import ...