forked from potsda.mn/mobilizon
Merge branch 'v3.0.4' into 'stable-3.0'
Fix LDAP and participant export See merge request framasoft/mobilizon!1362
This commit is contained in:
commit
5bb09927a3
|
@ -112,6 +112,9 @@ export const CONFIG = gql`
|
||||||
isDefault
|
isDefault
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exportFormats {
|
||||||
|
eventParticipants
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -132,9 +132,11 @@ defmodule Mobilizon.Service.Auth.LDAPAuthenticator do
|
||||||
) ::
|
) ::
|
||||||
String.t() | {:error, :ldap_registration_missing_attributes} | any()
|
String.t() | {:error, :ldap_registration_missing_attributes} | any()
|
||||||
defp search_user(connection, ldap, base, uid, email, group) do
|
defp search_user(connection, ldap, base, uid, email, group) do
|
||||||
|
Logger.debug("Searching for user")
|
||||||
# We may need to bind before performing the search
|
# We may need to bind before performing the search
|
||||||
res =
|
res =
|
||||||
if Keyword.get(ldap, :require_bind_for_search, true) do
|
if Keyword.get(ldap, :require_bind_for_search, true) do
|
||||||
|
Logger.debug("Doing binding before search as it's required")
|
||||||
admin_field = Keyword.get(ldap, :bind_uid)
|
admin_field = Keyword.get(ldap, :bind_uid)
|
||||||
admin_password = Keyword.get(ldap, :bind_password)
|
admin_password = Keyword.get(ldap, :bind_password)
|
||||||
bind_user(connection, base, uid, admin_field, admin_password)
|
bind_user(connection, base, uid, admin_field, admin_password)
|
||||||
|
@ -153,7 +155,9 @@ defmodule Mobilizon.Service.Auth.LDAPAuthenticator do
|
||||||
@spec do_search_user(any(), String.t(), String.t(), String.t(), String.t() | boolean()) ::
|
@spec do_search_user(any(), String.t(), String.t(), String.t(), String.t() | boolean()) ::
|
||||||
String.t() | {:error, :ldap_registration_missing_attributes} | any()
|
String.t() | {:error, :ldap_registration_missing_attributes} | any()
|
||||||
defp do_search_user(connection, base, uid, email, group) do
|
defp do_search_user(connection, base, uid, email, group) do
|
||||||
with {:ok, {:eldap_search_result, [{:eldap_entry, _, attributes}], _}} <-
|
Logger.debug("Searching user")
|
||||||
|
|
||||||
|
with {:ok, {:eldap_search_result, [{:eldap_entry, _, attributes}], _, _}} <-
|
||||||
:eldap.search(connection, [
|
:eldap.search(connection, [
|
||||||
{:base, to_charlist(base)},
|
{:base, to_charlist(base)},
|
||||||
{:filter, search_filter(email, group)},
|
{:filter, search_filter(email, group)},
|
||||||
|
|
|
@ -62,7 +62,8 @@ defmodule Mobilizon.Service.Auth.LDAPAuthenticatorTest do
|
||||||
wholeSubtree: fn -> :ok end,
|
wholeSubtree: fn -> :ok end,
|
||||||
search: fn _connection, _options ->
|
search: fn _connection, _options ->
|
||||||
{:ok,
|
{:ok,
|
||||||
{:eldap_search_result, [{:eldap_entry, '', [{'cn', [to_charlist("MyUser")]}]}], []}}
|
{:eldap_search_result, [{:eldap_entry, '', [{'cn', [to_charlist("MyUser")]}]}], [],
|
||||||
|
[]}}
|
||||||
end,
|
end,
|
||||||
close: fn _connection ->
|
close: fn _connection ->
|
||||||
send(self(), :close_connection)
|
send(self(), :close_connection)
|
||||||
|
@ -110,7 +111,8 @@ defmodule Mobilizon.Service.Auth.LDAPAuthenticatorTest do
|
||||||
wholeSubtree: fn -> :ok end,
|
wholeSubtree: fn -> :ok end,
|
||||||
search: fn _connection, _options ->
|
search: fn _connection, _options ->
|
||||||
{:ok,
|
{:ok,
|
||||||
{:eldap_search_result, [{:eldap_entry, '', [{'cn', [to_charlist("MyUser")]}]}], []}}
|
{:eldap_search_result, [{:eldap_entry, '', [{'cn', [to_charlist("MyUser")]}]}], [],
|
||||||
|
[]}}
|
||||||
end,
|
end,
|
||||||
close: fn _connection ->
|
close: fn _connection ->
|
||||||
send(self(), :close_connection)
|
send(self(), :close_connection)
|
||||||
|
|
Loading…
Reference in a new issue