1## This Source Code Form is subject to the terms of the Mozilla Public
2## License, v. 2.0. If a copy of the MPL was not distributed with this
3## file, You can obtain one at https://mozilla.org/MPL/2.0/.
4##
5## Copyright (c) 2007-2021 VMware, Inc. or its affiliates.  All rights reserved.
6
7defmodule RabbitMQ.CLI.Diagnostics.Commands.EnableAuthAttemptSourceTrackingCommand do
8  alias RabbitMQ.CLI.Core.DocGuide
9  @behaviour RabbitMQ.CLI.CommandBehaviour
10
11  use RabbitMQ.CLI.Core.MergesNoDefaults
12  use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
13  use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
14
15  def run([], %{node: node_name}) do
16    :rabbit_misc.rpc_call(node_name, :application, :set_env,
17      [:rabbit, :track_auth_attempt_source, :true])
18  end
19
20  use RabbitMQ.CLI.DefaultOutput
21
22  def usage, do: "enable_auth_attempt_source_tracking"
23
24  def usage_doc_guides() do
25    [
26      DocGuide.access_control(),
27      DocGuide.monitoring()
28    ]
29  end
30
31  def help_section(), do: :configuration
32
33  def description(), do: "Enables the tracking of peer IP address and username of authentication attempts"
34
35  def banner([], _), do: "Enabling authentication attempt source tracking ..."
36end
37