From d15a7a911f80347648864cc6ed57de7cde3f164e Mon Sep 17 00:00:00 2001 From: Sudhakar Ganapathy Date: Wed, 16 Dec 2020 13:19:54 -0800 Subject: [PATCH] Adding logging --- app/controllers/BasicAuthenticationFilter.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/BasicAuthenticationFilter.scala b/app/controllers/BasicAuthenticationFilter.scala index eb2d979a8..5b6ee6a9c 100644 --- a/app/controllers/BasicAuthenticationFilter.scala +++ b/app/controllers/BasicAuthenticationFilter.scala @@ -82,7 +82,7 @@ object BasicAuthenticator { private lazy val COOKIE_NAME = "play-basic-authentication" } -case class BasicAuthenticator(config: BasicAuthenticationConfig)(implicit val mat: Materializer, ec: ExecutionContext) extends Authenticator { +case class BasicAuthenticator(config: BasicAuthenticationConfig)(implicit val mat: Materializer, ec: ExecutionContext) extends Authenticator with Logging { import BasicAuthenticator._ @@ -110,6 +110,13 @@ case class BasicAuthenticator(config: BasicAuthenticationConfig)(implicit val ma val expectedCookie = cookieValue val authorizedByCookie = requestHeader.cookies.get(COOKIE_NAME).exists(_.value == expectedCookie) + logger.info("Attempt by User :"+ config.username + " to login.") + val headers: Map[String, String] = requestHeader.headers.toSimpleMap + for ((k,v) <- headers) { + logger.info(s"key: $k, value: $v") + } + + authorizedByHeader || authorizedByCookie }