A basic auth filter for play


Maven Central Build Status

forthebadge forthebadge forthebadge forthebadge

A basic auth filter for play


For now, this library is only built with scala2.12.x and play2.6.x. Pull requests are welcome.


Add the latest version to your dependencies in build.sbt, replacing x.x.x with the newest version from Maven Central

libraryDependencies += "com.lambdaminute" %% "play-basic-auth" % "x.x.x"
package controllers

import com.lambdaminute.playbasicauth.{BasicAuthFilter, User}
import play.api.ApplicationLoader.Context
import play.api._
import router.Routes

class MyApplicationLoader extends ApplicationLoader {
  def load(context: Context) = {
    new MyComponents(context).application

class MyComponents(context: Context)
    extends BuiltInComponentsFromContext(context)
    with AssetsComponents {

  val httpFilters = Seq(
    new BasicAuthFilter(List(User(name = "Horse", password = "carrot")), realm = "everything"))

  val homeController = new HomeController(controllerComponents)

  lazy val router = new Routes(httpErrorHandler, homeController, assets)


More examples

Please refer to the tests