среда, 9 июня 2010 г.

Настройка JasperServer на работу с Active Directory

Пришло время настроить авторизацию в JasperServer через ActiveDirectory. Для этого необходимо поднастроить конфиги и скачать spring-ldap-1.3.0.RELEASE-all.jar

Скачанный spring-ldap-1.3.0.RELEASE-all.jar нужно скопировать в [JaperServer folder]/apache-tomcat/webapps/jasperserver/WEB-INF/lib

Теперь надо подправить конфиг для использования LDAP. Файл с настройками называется applicationContext-security.xml. Ниже приведен пример настройки на LDAP. В файле applicationContext-security.xml надо найти строку ====AUTHENTICATION==== оттуда начинаются правки. Строки с настройками для LDAP выделены красным цветом

<!-- ======================== AUTHENTICATION ======================= -->
<bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager">
<property name="providers">
<list>
<!-- not on by default-->
<ref local="ldapAuthenticationProvider"/>
<ref bean="${bean.daoAuthenticationProvider}"/>
<ref local="anonymousAuthenticationProvider"/>
<!--ref local="jaasAuthenticationProvider"/-->
</list>
</property>
</bean>

<bean id="daoAuthenticationProvider" class="org.springframework.security.providers.dao.DaoAuthenticationProvider">
<!-- jdbcDaoImpl -->
<!-- <property name="userDetailsService"><ref bean="inMemoryDaoImpl"/></property> -->
<property name="userDetailsService"><ref bean="${bean.internalUserAuthorityService}"/></property>
<property name="passwordEncoder"><ref local="passwordEncoder"/></property>
</bean>

<bean id="passwordEncoder" class="com.jaspersoft.jasperserver.api.metadata.common.service.impl.PasswordCipherer" lazy-init="false">
<property name="allowEncoding"><value>true</value></property>
<property name="keyInPlainText"><value>false</value></property>
<property name="secretKey"><value>0xC8 0x43 0x29 0x49 0xAE 0x25 0x2F 0xA1 0xC1 0xF2 0xC8 0xD9 0x31 0x01 0x2C 0x52 0x54 0x0B 0x5E 0xEA 0x9E 0x37 0xA8 0x61</value></property>
<property name="secretKeyAlgorithm"><value>DESede</value></property>
<property name="cipherTransformation"><value>DESede/CBC/PKCS5Padding</value></property>
</bean>

<bean id="anonymousProcessingFilter" class="org.springframework.security.providers.anonymous.AnonymousProcessingFilter">
<property name="key"><value>foobar</value></property>
<property name="userAttribute"><value>anonymousUser,ROLE_ANONYMOUS</value></property>
</bean>

<bean id="anonymousAuthenticationProvider" class="org.springframework.security.providers.anonymous.AnonymousAuthenticationProvider">
<property name="key"><value>foobar</value></property>
</bean>

<bean id="initialDirContextFactory" class="org.springframework.security.ldap.DefaultInitialDirContextFactory">
<!--Путь к пользователям (верхний уровень) -->
<constructor-arg value="ldap://inside.lavtech.ru:389/OU=OU,OU=Lavtech,DC=inside,DC=lavtech,DC=ru"/>

<!-- You may not need the next propertiesD-->
<!--Путь к менеджеру контроллера домена (для поиска пользователей) -->
<property name="managerDn"><value>CN=adtest,CN=Users,DC=inside,DC=lavtech,DC=ru</value></property>
<!--пароль менеджера контроллера домена -->
<property name="managerPassword"><value>123456</value></property>
</bean>

<bean id="userSearch"
class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg index="0">
<value></value>
</constructor-arg>
<constructor-arg index="1">
<!--Логин берем из аттрибута sAMAccountName -->
<value>(sAMAccountName={0})</value>
</constructor-arg>
<constructor-arg index="2">
<ref local="initialDirContextFactory" />
</constructor-arg>
<!-- Поиск в подуровнях-->
<property name="searchSubtree">
<value>true</value>
</property>
</bean>

<!--
For LDAP authentication
-->

<bean id="ldapAuthenticationProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
<constructor-arg><ref local="initialDirContextFactory"/></constructor-arg>
<!-- авторизуемся по этому аттрибуту-->
<property name="userDnPatterns"><list><value>sAMAccountName={0}</value></list></property>
<property name="userSearch" ref="userSearch"/>
</bean>
</constructor-arg>
<constructor-arg>
<!-- разобраться с ролями (возможно есть верятность, что можно использовать роли из ActiveDirectory)-->
<bean class="org.springframework.security.ldap.populator.DefaultLdapAuthoritiesPopulator">
<constructor-arg index="0"><ref local="initialDirContextFactory"/></constructor-arg>
<constructor-arg index="1"><value></value></constructor-arg>
<property name="groupRoleAttribute"><value>cn</value></property>
<!--property name="groupSearchFilter"><value>(&(uniqueMember={0})(objectclass=groupofuniquenames))</value></property-->
<property name="searchSubtree"><value>true</value></property>
</bean>
</constructor-arg>
</bean>

Теперь можно авторизовываться через ActiveDirectory


Эту статью Вы можете прочитать на новом блоге 

Комментариев нет:

Отправить комментарий

Примечание. Отправлять комментарии могут только участники этого блога.