Simple BasicAuthentication for Play-Framework-Apps (implemented as Filter).
-
Add as dependecy to your project:
libraryDependencies ++= Seq( "net.habashi" %% "basicauthenticator" % "1.0.0" )
or
lazy val myProject = project.dependsOn(basicauthenticator)
-
Extend HttpFilters and configure username/password for the BasicAuthenticator:
class Filters @Inject()(implicit val mat: Materializer, ec: ExecutionContext) extends HttpFilters { val username = "sonic the hedgehog" val password = "rocks" override def filters = Seq(new BasicAuthenticationFilter(username, password)) }
-
Add the extended HttpFilters as Filter to the
application.conf
# Filters play.http.filters=net.habashi.filters.Filters