mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
(refs #335)Use string before '@' of mail address if user name is mail address in LDAP authentication.
This commit is contained in:
@@ -49,7 +49,7 @@ object LDAPUtil {
|
|||||||
){ conn =>
|
){ conn =>
|
||||||
findMailAddress(conn, userDN, ldapSettings.mailAttribute) match {
|
findMailAddress(conn, userDN, ldapSettings.mailAttribute) match {
|
||||||
case Some(mailAddress) => Right(LDAPUserInfo(
|
case Some(mailAddress) => Right(LDAPUserInfo(
|
||||||
userName = userName,
|
userName = getUserNameFromMailAddress(userName),
|
||||||
fullName = ldapSettings.fullNameAttribute.flatMap { fullNameAttribute =>
|
fullName = ldapSettings.fullNameAttribute.flatMap { fullNameAttribute =>
|
||||||
findFullName(conn, userDN, fullNameAttribute)
|
findFullName(conn, userDN, fullNameAttribute)
|
||||||
}.getOrElse(userName),
|
}.getOrElse(userName),
|
||||||
@@ -59,6 +59,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)
|
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] = {
|
(f: LDAPConnection => Either[String, A]): Either[String, A] = {
|
||||||
if (tls) {
|
if (tls) {
|
||||||
|
|||||||
Reference in New Issue
Block a user