(refs #78)Fix for LDAP authentication.

This commit is contained in:
takezoe
2013-08-17 01:10:06 +09:00
parent 231fd268df
commit df5600f03f
4 changed files with 17 additions and 22 deletions

View File

@@ -27,9 +27,10 @@ trait SignInControllerBase extends ControllerBase { self: SystemSettingsService
post("/signin", form){ form =>
val settings = loadSystemSettings()
settings.authType match {
case "LDAP" => ldapAuthentication(form, settings)
case _ => defaultAuthentication(form)
if(settings.ldapAuthentication){
ldapAuthentication(form, settings)
} else {
defaultAuthentication(form)
}
}

View File

@@ -23,8 +23,8 @@ trait SystemSettingsControllerBase extends ControllerBase with FlashMapSupport {
"password" -> trim(label("SMTP Password", optional(text()))),
"ssl" -> trim(label("Enable SSL", optional(boolean())))
)(Smtp.apply)),
"authType" -> trim(label("Auth Type", text(required))),
"ldap" -> optional(_.get("authType") == Some("LDAP"), mapping(
"ldapAuthentication" -> trim(label("LDAP", boolean())),
"ldap" -> optionalIfNotChecked("ldapAuthentication", mapping(
"host" -> trim(label("LDAP host", text(required))),
"port" -> trim(label("LDAP port", number(required))),
"baseDN" -> trim(label("BaseDN", text(required))),

View File

@@ -19,7 +19,8 @@ trait SystemSettingsService {
smtp.ssl.foreach(x => props.setProperty(SmtpSsl, x.toString))
}
}
if(settings.authType == "LDAP"){
props.setProperty(LdapAuthentication, settings.ldapAuthentication.toString)
if(settings.ldapAuthentication){
settings.ldap.map { ldap =>
props.setProperty(LdapHost, ldap.host)
props.setProperty(LdapPort, ldap.port.toString)
@@ -51,14 +52,14 @@ trait SystemSettingsService {
} else {
None
},
getValue(props, AuthType, ""),
if(getValue(props, AuthType, "") == "LDAP"){
getValue(props, LdapAuthentication, false),
if(getValue(props, LdapAuthentication, false)){
Some(Ldap(
getValue(props, LdapHost, ""),
getValue(props, LdapPort, 389),
getValue(props, LdapBaseDN, ""),
getValue(props, LdapUserNameAttribute, "uid"),
getValue(props, LdapUserNameAttribute, "mail")))
getValue(props, LdapMailAddressAttribute, "mail")))
} else {
None
}
@@ -75,7 +76,7 @@ object SystemSettingsService {
gravatar: Boolean,
notification: Boolean,
smtp: Option[Smtp],
authType: String,
ldapAuthentication: Boolean,
ldap: Option[Ldap])
case class Ldap(
@@ -94,13 +95,13 @@ object SystemSettingsService {
private val AllowAccountRegistration = "allow_account_registration"
private val Gravatar = "gravatar"
private val AuthType = "auth_type"
private val Notification = "notification"
private val SmtpHost = "smtp.host"
private val SmtpPort = "smtp.port"
private val SmtpUser = "smtp.user"
private val SmtpPassword = "smtp.password"
private val SmtpSsl = "smtp.ssl"
private val LdapAuthentication = "ldap_authentication"
private val LdapHost = "ldap.host"
private val LdapPort = "ldap.port"
private val LdapBaseDN = "ldap.baseDN"

View File

@@ -40,13 +40,7 @@
<label><strong>Authentication</strong></label>
<fieldset>
<label>
<input type="radio" id="authTypeDefault" name="authType" value="Default"@if(settings.authType != "LDAP"){ checked}/>
Default
</label>
</fieldset>
<fieldset>
<label>
<input type="radio" id="authTypeLDAP" name="authType" value="LDAP"@if(settings.authType == "LDAP"){ checked}/>
<input type="checkbox" id="ldapAuthentication" name="ldapAuthentication"@if(settings.ldap){ checked}/>
LDAP
</label>
</fieldset>
@@ -147,9 +141,8 @@ $(function(){
$('.notification input').prop('disabled', !$(this).prop('checked'));
}).change();
$('input[name=authType]').click(function(){
$('.ldap input').prop('disabled', $('input[name=authType]:checked').val() != "LDAP");
});
$('input[name=authType]:checked').click();
$('#ldapAuthentication').change(function(){
$('.ldap input').prop('disabled', !$(this).prop('checked'));
}).change();
});
</script>