ldap-plugin/war/resources/WEB-INF/security/LDAPBindSecurityRealm.groovy
kohsuke c197a542d5 [HUDSON-1802] LDAP authentication with non-empty manager DN/password was not working correctly.
In 1.225.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10095 71c3de6d-444a-0410-be80-ed276b4c234a

Originally-Committed-As: 0f61ee2ca0187305f197dbddccee4c52d11fbc29
2008-06-13 21:59:57 +00:00

58 lines
2.1 KiB
Groovy

import org.acegisecurity.providers.ProviderManager
import org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider
import org.acegisecurity.providers.ldap.LdapAuthenticationProvider
import org.acegisecurity.providers.ldap.authenticator.BindAuthenticator2
import org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator
import org.acegisecurity.ldap.DefaultInitialDirContextFactory
import org.acegisecurity.ldap.search.FilterBasedLdapUserSearch
import org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider
import hudson.model.Hudson
/*
Configure LDAP as the authentication realm.
Authentication is performed by doing LDAP bind.
The 'instance' object refers to the instance of LDAPSecurityRealm
*/
initialDirContextFactory(DefaultInitialDirContextFactory, instance.getLDAPURL() ) {
if(instance.managerDN!=null) {
managerDn = instance.managerDN;
managerPassword = instance.getManagerPassword();
}
}
ldapUserSearch(FilterBasedLdapUserSearch, instance.userSearchBase, instance.userSearch, initialDirContextFactory) {
searchSubtree=true
}
bindAuthenticator(BindAuthenticator2,initialDirContextFactory) {
// this is when you the user name can be translated into DN.
// userDnPatterns = [
// "uid={0},ou=people"
// ]
// this is when we need to find it.
userSearch = ldapUserSearch;
}
authoritiesPopulator(DefaultLdapAuthoritiesPopulator,initialDirContextFactory,"ou=groups") {
// groupRoleAttribute = "ou";
}
authenticationManager(ProviderManager) {
providers = [
// talk to LDAP
bean(LdapAuthenticationProvider,bindAuthenticator,authoritiesPopulator),
// these providers apply everywhere
bean(RememberMeAuthenticationProvider) {
key = Hudson.getInstance().getSecretKey();
},
// this doesn't mean we allow anonymous access.
// we just authenticate anonymous users as such,
// so that later authorization can reject them if so configured
bean(AnonymousAuthenticationProvider) {
key = "anonymous"
}
]
}