summaryrefslogtreecommitdiff
path: root/deps/rabbitmq_web_mqtt/src/rabbit_web_mqtt_connection_info.erl
blob: cb71ac6b766314e8aa4af8054892006b993d970b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates.  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.