From 6b7fd7fb7bc094f4488e50234ce21dd69bbb7793 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Thu, 26 Jan 2017 09:59:32 +0900 Subject: [PATCH] (refs #499)Log authentication failure --- .../gitbucket/core/service/AccountService.scala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/scala/gitbucket/core/service/AccountService.scala b/src/main/scala/gitbucket/core/service/AccountService.scala index 0032ceaeb..50db9c5c9 100644 --- a/src/main/scala/gitbucket/core/service/AccountService.scala +++ b/src/main/scala/gitbucket/core/service/AccountService.scala @@ -14,13 +14,20 @@ trait AccountService { private val logger = LoggerFactory.getLogger(classOf[AccountService]) - def authenticate(settings: SystemSettings, userName: String, password: String)(implicit s: Session): Option[Account] = - if(settings.ldapAuthentication){ + def authenticate(settings: SystemSettings, userName: String, password: String)(implicit s: Session): Option[Account] = { + val account = if (settings.ldapAuthentication) { ldapAuthentication(settings, userName, password) } else { defaultAuthentication(userName, password) } + if(account.isEmpty){ + logger.info(s"Failed to authentication: $userName") + } + + account + } + /** * Authenticate by internal database. */ @@ -68,7 +75,7 @@ trait AccountService { } } case Left(errorMessage) => { - logger.info(s"LDAP Authentication Failed: ${errorMessage}") + logger.info(s"LDAP error: ${errorMessage}") defaultAuthentication(userName, password) } }