mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
Merge commit Tag 1.13 ('3e82534c78a72e17dd3b79e091521d75cb4d3855') into add-features-to-ldapauth
Conflicts: src/main/scala/service/AccountService.scala src/main/scala/util/LDAPUtil.scala
This commit is contained in:
@@ -57,7 +57,7 @@ object LDAPUtil {
|
||||
} else {
|
||||
findMailAddress(conn, userDN, ldapSettings.mailAttribute.get) match {
|
||||
case Some(mailAddress) => Right(LDAPUserInfo(
|
||||
userName = userName,
|
||||
userName = getUserNameFromMailAddress(userName),
|
||||
fullName = ldapSettings.fullNameAttribute.flatMap { fullNameAttribute =>
|
||||
findFullName(conn, userDN, fullNameAttribute)
|
||||
}.getOrElse(userName),
|
||||
@@ -68,6 +68,13 @@ object LDAPUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private def getUserNameFromMailAddress(userName: String): String = {
|
||||
(userName.indexOf('@') match {
|
||||
case i if i >= 0 => userName.substring(0, i)
|
||||
case i => userName
|
||||
}).replaceAll("[^a-zA-Z0-9\\-_.]", "").replaceAll("^[_\\-]", "")
|
||||
}
|
||||
|
||||
private def bind[A](host: String, port: Int, dn: String, password: String, tls: Boolean, keystore: String, error: String)
|
||||
(f: LDAPConnection => Either[String, A]): Either[String, A] = {
|
||||
if (tls) {
|
||||
|
||||
Reference in New Issue
Block a user