Skip to content

Commit

Permalink
Merge pull request #4331 from esl/fix-ldap-dialyzer
Browse files Browse the repository at this point in the history
Fix ldap dialyzer warnings on Erlang 27
  • Loading branch information
chrzaszcz authored Jul 25, 2024
2 parents 7dbbbdb + 2ce02e3 commit 08dc34c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/eldap_filter_yecc.yrl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Erlang code.

'and'(Value) -> eldap:'and'(eldap_utils:maybe_b2list(Value)).
'or'(Value) -> eldap:'or'(eldap_utils:maybe_b2list(Value)).
'not'(Value) -> eldap:'not'(eldap_utils:maybe_b2list(Value)).
'not'(Value) -> eldap:'not'(Value).
equal(Desc, Value) -> eldap:equalityMatch(Desc, eldap_utils:maybe_b2list(Value)).
approx(Desc, Value) -> eldap:approxMatch(Desc, eldap_utils:maybe_b2list(Value)).
greater(Desc, Value) -> eldap:greaterOrEqual(Desc, eldap_utils:maybe_b2list(Value)).
Expand All @@ -68,4 +68,4 @@ final(Value) -> {final, eldap_utils:maybe_b2list(Value)}.
xattr(Value) -> {type, eldap_utils:maybe_b2list(Value)}.
matchingrule(Value) -> {matchingRule, eldap_utils:maybe_b2list(Value)}.
value_of(Token) -> iolist_to_binary(element(3, Token)).
flatten(List) -> lists:flatten(List).
flatten(List) -> lists:flatten(List).
2 changes: 1 addition & 1 deletion src/eldap_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ match_filter_name({<<"%u">>, [Value | _]}, NewUIDs) when Value /= <<"">> ->
end;
match_filter_name({Name, [Value | _]}, _NewUIDs) when Value /= <<"">> ->
case binary:match(Value, <<"*">>) of
nomatch -> [eldap:equalityMatch(Name, Value)];
nomatch -> [eldap:equalityMatch(maybe_b2list(Name), maybe_b2list(Value))];
_ -> [eldap:substrings(maybe_b2list(Name),
generate_substring_list(Value))]
end;
Expand Down
17 changes: 11 additions & 6 deletions src/mongoose_ldap_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,23 @@ call_eldap(Request, State) ->
{Result, State}
end.

connect_opts(State = #{port := Port,
root_dn := RootDN,
password := Password}) ->
AnonAuth = RootDN =:= <<>> andalso Password =:= <<>>,
SSLConfig = case State of
#{tls := TLSOptions} -> [{sslopts, just_tls:make_ssl_opts(TLSOptions)}];
#{} -> []
end,
[{port, Port}, {anon_auth, AnonAuth}] ++ SSLConfig.

connect(State = #{handle := none,
servers := Servers,
port := Port,
root_dn := RootDN,
password := Password,
connect_interval := ConnectInterval}) ->
AnonAuth = RootDN =:= <<>> andalso Password =:= <<>>,
SSLConfig = case State of
#{tls := TLSOptions} -> [{sslopts, just_tls:make_ssl_opts(TLSOptions)}];
#{} -> []
end,
case eldap:open(Servers, [{port, Port}, {anon_auth, AnonAuth}] ++ SSLConfig) of
case eldap:open(Servers, connect_opts(State)) of
{ok, Handle} ->
case eldap:simple_bind(Handle, RootDN, Password) of
ok ->
Expand Down

0 comments on commit 08dc34c

Please sign in to comment.