Add connection info module

To extract client ID at authentication time.

[#166271318]

References #1767
This commit is contained in:
Arnaud Cogoluègnes 2019-06-14 14:26:23 +02:00
parent 7f6a8342bc
commit 6037931ac5
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
%% The contents of this file are subject to the Mozilla Public License
%% Version 1.1 (the "License"); you may not use this file except in
%% compliance with the License. You may obtain a copy of the License
%% at https://www.mozilla.org/MPL/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and
%% limitations under the License.
%%
%% The Original Code is RabbitMQ.
%%
%% The Initial Developer of the Original Code is GoPivotal, Inc.
%% Copyright (c) 2019 Pivotal Software, Inc. All rights reserved.
%%
-module(rabbit_web_mqtt_connection_info).
%% Module to add the MQTT client ID to authentication properties
%% API
-export([additional_authn_params/4]).
additional_authn_params(_Creds, _VHost, _Pid, Infos) ->
case proplists:get_value(variable_map, Infos, undefined) of
VariableMap when is_map(VariableMap) ->
case maps:get(<<"client_id">>, VariableMap, []) of
ClientId when is_binary(ClientId)->
[{client_id, ClientId}];
[] ->
[]
end;
_ ->
[]
end.