• Авторизация


жабба 13-05-2007 00:47 к комментариям - к полной версии - понравилось!


Установка Ejabberd под FreeBSD+AD+SSL
Задача и решение

Необходимо было построить на базе ejabberd корпоративный jabber-сервер. База пользователей хранится в M$ Active Directory, оттуда же производится авторизация. Так же необходимо что бы все пользователи видели всех пользователей домена в своём ростере. В качестве дополнительного ограничения на пользовательские ростеры выдвигается требование разбиения контактов на группы по отделам.

Что где взять
Патч для v1.0.0: http://realloc.spb.ru/files/ejabberd/ejabber_ad_001.patch.gz
Патч для v1.1.1: http://realloc.spb.ru/files/ejabberd/ejabber_ad_002.patch.gz

Как пропатчить
Копируем патч в порт с ejabberd (/usr/ports/net-im/ejabberd)
make patch
zcat ejabber_ad_002.patch.gz | patch -p1
make install clean

Как настроить AD

Для начала надо сделать некоторые вещи в AD. Создать пользователя в домене ejabberd. Необходимо создать группу, члены которой будут иметь доступ к jabber серверу и показываться в ростере. В нашем примере используется домен chloe.ku3 и группа Jabber Users. После внесения всех нужных пользователей в эту группу надо прописать им в поле департамента группу в общем ростере, которой они будут принадлежать. Например пользователь vasya@domen.ru должен быть включен в группу Jabber Users и в поле департамента у него будет прописано Support. Это заставит его контакт появиться в группе Support в ростере.

Настройка ejabberd

Тут просто опишу какие изменения необходимы в конфигурационном файле.

{auth_method, ad}.

В качестве метода аутентификации указываем AD. Из-за своеобразного видения стандартов одной маленькой и мягкой фирмой обычная ldap-авторизация с AD не работает.
{ad_servers, ["192.168.0.1"]}.
{ad_uidattr, "sAMAccountName"}.
{ad_group, "CN=Jabber Users,CN=Users,DC=avto,DC=yar,DC=ru"}.
{ad_base, "dc=avto,dc=yar,dc=ru"}.
{ad_rootdn, "CN=ejabberd,CN=Users, DC=avto,DC=yar,DC=ru "}.
{ad_password, "qwerty" }.

Тут всё просто.
ad_servers - IP или имя нашего домен-контроллера.
ad_uidattr - Атрибут, в котором хранится логин пользователя
ad_group - Группа, в которую входят правильные пользователи
ad_base - Собственно по какому домену ищем
ad_rootdn - Кем биндиться будем (ejabberd)
ad_password - Пароль того, кем биндиться будем. Анонимное с AD не работает. (qwerty)

В списке модулей надо вместо mod_vcard использовать mod_vcard_ad, и вместо mod_shared_roster надо mod_shared_roster_ad соответственно. Это позволит использовать AD ещё и для поиска и для вытягивания юзеринфо. Так же надо отключить in-band регистрацию пользователей. Во-первых она всё-равно не будет работать, а во-вторых она на корпоративном сервере ни к чему. Cделать это можно убрав mod_register из списка модулей.


Полный рабочий конфиг:

% $Id: ejabberd.cfg.example 538 2006-04-22 04:02:42Z alexey $

%override_acls.


% Users that have admin access. Add line like one of the following after you
% will be successfully registered on server to get admin access:
{acl, admin, {user, "nev"}}.
%{acl, admin, {user, "ermine"}}.

% Blocked users:
%{acl, blocked, {user, "test"}}.

% Local users:
{acl, local, {user_regexp, ""}}.

% Another examples of ACLs:
%{acl, jabberorg, {server, "jabber.org"}}.
%{acl, aleksey, {user, "aleksey", "jabber.ru"}}.
%{acl, test, {user_regexp, "^test"}}.
%{acl, test, {user_glob, "test*"}}.


% Only admins can use configuration interface:
{access, configure, [{allow, admin}]}.

% Every username can be registered via in-band registration:
% You could replace {allow, all} with {deny, all} to prevent user from using
% in-band registration
{access, register, [{allow, all}]}.

% After successful registration user will get message with following subject
% and body:
{welcome_message,
{"Welcome!",
"Welcome to Jabber Service. "
"For information about Jabber visit http://jabber.org"}}.
% Replace them with 'none' if you don't want to send such message:
%{welcome_message, none}.

% List of people who will get notifications about registered users
%{registration_watchers, ["admin1@localhost",
% "admin2@localhost"]}.

% Only admins can send announcement messages:
{access, announce, [{allow, admin}]}.


% Only non-blocked users can use c2s connections:
{access, c2s, [{deny, blocked},
{allow, all}]}.

% Set shaper with name "normal" to limit traffic speed to 1000B/s
{shaper, normal, {maxrate, 1000}}.

% Set shaper with name "fast" to limit traffic speed to 50000B/s
{shaper, fast, {maxrate, 50000}}.

% For all users except admins used "normal" shaper
{access, c2s_shaper, [{none, admin},
{normal, all}]}.

% For all S2S connections used "fast" shaper
{access, s2s_shaper, [{fast, all}]}.

% Admins of this server are also admins of MUC service:
{access, muc_admin, [{allow, admin}]}.

% All users are allowed to use MUC service:
{access, muc, [{allow, all}]}.

% This rule allows access only for local users:
{access, local, [{allow, local}]}.


% Authentication method. If you want to use internal user base, then use
% this line:
%{auth_method, internal}.

% For LDAP authentication use these lines instead of above one:
{auth_method, ad}.
{ad_servers, ["192.168.0.1"]}. % List of LDAP servers
{ad_uidattr, "sAMAccountName"}. % LDAP attribute that holds user ID
{ad_group, "CN=Jabber Users,CN=Users,DC=my,DC=domain,DC=ru"}.
{ad_base, "dc=my,dc=domain,dc=ru"}. % Search base of LDAP directory
{ad_rootdn, "CN=ejabberd,CN=Users,dc=my,dc=domain,dc=ru"}. % LDAP manager
{ad_password, "qwerty"}. % Password to LDAP manager

% For authentication via external script use the following:
%{auth_method, external}.
%{extauth_program, "/path/to/authentication/script"}.

% For authentication via ODBC use the following:
%{auth_method, odbc}.
%{odbc_server, "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"}.


% Host name:
{hosts, ["bsd.my.domain.ru"]}.

%% Anonymous login support:
%% auth_method: anonymous
%% anonymous_protocol: sasl_anon|login_anon|both
%% allow_multiple_connections: true|false
%%{host_config, "public.example.org", [{auth_method, anonymous},
%% {allow_multiple_connections, false},
%% {anonymous_protocol, sasl_anon}]}.
%% To use both anonymous and internal authentication:
%%{host_config, "public.example.org", [{auth_method, [anonymous, internal]}]}.

% Default language for server messages
{language, "ru"}.

% Listened ports:
{listen,
[{5222, ejabberd_c2s, [{access, c2s}, {shaper, c2s_shaper},
{max_stanza_size, 65536},
starttls, {certfile, "путь к сертификату/ssl.pem"}]},
{5223, ejabberd_c2s, [{access, c2s},
{max_stanza_size, 65536},
tls, {certfile, "путь к сертификату/ssl.pem"}]},
% Use these two lines instead if TLS support is not compiled
%{5222, ejabberd_c2s, [{access, c2s}, {shaper, c2s_shaper}]},
%{5223, ejabberd_c2s, [{access, c2s}, ssl, {certfile, "./ssl.pem"}]},
{5269, ejabberd_s2s_in, [{shaper, s2s_shaper},
{max_stanza_size, 131072}
]},
{5280, ejabberd_http, [http_poll, web_admin]},
{8888, ejabberd_service, [{access, all},
{hosts, ["icq.localhost", "sms.localhost"],
[{password, "secret"}]}]}
]}.


% Use STARTTLS+Dialback for S2S connections
{s2s_use_starttls, true}.
{s2s_certfile, "путь к сертификату/ssl.pem"}.
%{domain_certfile, "example.org", "./example_org.pem"}.
%{domain_certfile, "example.com", "./example_com.pem"}.

% If SRV lookup fails, then port 5269 is used to communicate with remote server
{outgoing_s2s_port, 5269}.


% Used modules:
{modules,
[
{mod_register, [{access, register}]},
{mod_roster, []},
{mod_privacy, []},
{mod_adhoc, []},
{mod_configure, []}, % Depends on mod_adhoc
{mod_configure2, []},
{mod_disco, []},
{mod_stats, []},
{mod_vcard_ad, []},
{mod_offline, []},
{mod_announce, [{access, announce}]}, % Depends on mod_adhoc
{mod_echo, [{host, "echo.localhost"}]},
{mod_private, []},
{mod_irc, []},
% Default options for mod_muc:
% host: "conference." ++ ?MYNAME
% access: all
% access_create: all
% access_admin: none (only room creator has owner privileges)
{mod_muc, [{access, muc},
{access_create, muc},
{access_admin, muc_admin}]},
% {mod_muc_log, []},
{mod_shared_roster_ad, []},
{mod_pubsub, []},
{mod_time, []},
{mod_last, []},
{mod_version, []}
]}.




% Local Variables:
% mode: erlang
% End:



Настройка клиента

Для авторизации нам необходимо иметь пароль в открытом виде. Поэтому надо в клиенте разрешить передачу пароля незашифрованным. Если использовать SSL, то ничего страшного в этой опции нету.



Генерирование сертификата SSL


#openssl req -new -x509 -newkey rsa:1024 -days 3650 -keyout privkey.pem -out server.pem
Generating a 1024 bit RSA private key
................++++++
.......................................++++++
writing new private key to 'cert.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:PA
Locality Name (eg, city) []:Pittsburgh
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section) []:Systems Administrator
Common Name (eg, YOUR name) []:localhost.example.org
Email Address []:trhodes@FreeBSD.org

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:SOME PASSWORD
An optional company name []:Another Name


#openssl rsa -in privkey.pem -out privkey.pem
#cat privkey.pem >> server.pem
#rm privkey.pem

#ee /usr/local/etc/ejabberd/ejabberd.cfg
{listen, [{5222, ejabberd_c2s, [{access, c2s}, {shaper, c2s_shaper},
starttls, {certfile, "/home/ejabberd/server.pem"}]},
{5223, ejabberd_c2s, [{access, c2s}, {shaper, c2s_shaper},
ssl, {certfile, "/home/ejabberd/server.pem"}]},

_______________________________________________________________________________
см. http://ejabberd.jabber.ru/ejabberd_ad
вверх^ к полной версии понравилось! в evernote


Вы сейчас не можете прокомментировать это сообщение.

Дневник жабба | Kool_Pit - Дневник Kool_Pit | Лента друзей Kool_Pit / Полная версия Добавить в друзья Страницы: раньше»