|
8 | 8 | -module(rabbit_oauth2_resource_server).
|
9 | 9 |
|
10 | 10 | -include("oauth2.hrl").
|
| 11 | +-include_lib("kernel/include/logger.hrl"). |
11 | 12 |
|
12 | 13 | -export([
|
13 | 14 | resolve_resource_server_from_audience/1,
|
@@ -166,12 +167,27 @@ find_audience(Audience, ResourceIdList) when is_binary(Audience) ->
|
166 | 167 | AudList = binary:split(Audience, <<" ">>, [global, trim_all]),
|
167 | 168 | find_audience(AudList, ResourceIdList);
|
168 | 169 | find_audience(AudList, ResourceIdList) when is_list(AudList) ->
|
169 |
| - case intersection(AudList, ResourceIdList) of |
| 170 | + ?LOG_DEBUG("find_audience ~p -> ~p vs ~p", [AudList, |
| 171 | + normalize_to_binary_list(AudList), ResourceIdList]), |
| 172 | + case intersection(normalize_to_binary_list(AudList), ResourceIdList) of |
170 | 173 | [One] -> {ok, One};
|
171 | 174 | [_One|_Tail] -> {error, aud_matched_many_resource_servers_only_one_allowed};
|
172 | 175 | [] -> {error, no_matching_aud_found}
|
173 | 176 | end.
|
174 | 177 |
|
| 178 | +-spec normalize_to_binary_list(binary() | string() | [binary()]) -> [binary()]. |
| 179 | +normalize_to_binary_list(Input) when is_list(Input) -> |
| 180 | + case Input of |
| 181 | + [H | _] when is_binary(H) -> |
| 182 | + Input; |
| 183 | + _ when is_list(Input) -> |
| 184 | + [unicode:characters_to_binary(Part) || Part <- string:tokens(Input, " ")]; |
| 185 | + _ -> |
| 186 | + [] |
| 187 | + end; |
| 188 | +normalize_to_binary_list(Input) when is_binary(Input) -> |
| 189 | + binary:split(Input, <<" ">>, [global]). |
| 190 | + |
175 | 191 | -spec translate_error_if_any(
|
176 | 192 | {ok, resource_server()} |
|
177 | 193 | {error, not_found} |
|
|
0 commit comments