-
Notifications
You must be signed in to change notification settings - Fork 715
/
LDAPAuthConfig.scala
33 lines (26 loc) · 1.07 KB
/
LDAPAuthConfig.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package controllers.auth.ldap
import controllers.auth.AuthConfig
import play.api.Configuration
class LDAPAuthConfig(config: Configuration) extends AuthConfig {
implicit val conf = config
final val userTemplate = getSetting("user-template")
final val method = getSetting("method")
final val url = getSetting("url")
final val baseDN = getSetting("base-dn")
final val groupMembership: Option[LDAPGroupSearchConfig] = {
val bindDN = getSetting("bind-dn")
val bindPwd = getSetting("bind-pw")
val groupAuthConfig = config.get[Configuration]("group-search")
groupAuthConfig.getOptional[String]("group").map { group =>
LDAPGroupSearchConfig(
bindDN,
bindPwd,
groupAuthConfig.getOptional[String]("base-dn").getOrElse(baseDN),
getSetting("user-attr")(groupAuthConfig),
groupAuthConfig.getOptional[String]("user-attr-template").getOrElse(userTemplate),
group
)
}
}
}
case class LDAPGroupSearchConfig(bindDN: String, bindPwd: String, baseDN: String, userAttr: String, userAttrTemplate:String, group: String)