├── examples └── rabbitmq-auth-backend-java │ ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java │ ├── src │ └── main │ │ └── java │ │ └── com │ │ └── rabbitmq │ │ └── authbackend │ │ ├── ResourceType.java │ │ ├── ResourcePermission.java │ │ ├── AuthBackend.java │ │ ├── examples │ │ ├── TestMain.java │ │ ├── Main.java │ │ └── ExampleAuthBackend.java │ │ ├── LoginResult.java │ │ └── AuthServer.java │ ├── pom.xml │ ├── mvnw.cmd │ └── mvnw ├── LICENSE ├── .gitignore ├── test ├── test_SUITE_data │ └── run_backend.sh ├── config_schema_SUITE_data │ └── rabbitmq_auth_backend_amqp.snippets ├── unit_SUITE.erl ├── config_schema_SUITE.erl └── test_SUITE.erl ├── src ├── rabbit_auth_backend_amqp_app.erl ├── rabbit_auth_backend_amqp_sup.erl └── rabbit_auth_backend_amqp.erl ├── .github └── workflows │ └── main.yaml ├── priv └── schema │ └── rabbitmq_auth_backend_amqp.schema ├── Makefile ├── CONTRIBUTING.md ├── CODE_OF_CONDUCT.md ├── README.md ├── LICENSE-MPL-RabbitMQ └── rabbitmq-components.mk /examples/rabbitmq-auth-backend-java/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/rabbitmq-auth-backend-amqp/HEAD/examples/rabbitmq-auth-backend-java/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/src/main/java/com/rabbitmq/authbackend/ResourceType.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.authbackend; 2 | 3 | public enum ResourceType { 4 | EXCHANGE, QUEUE, TOPIC 5 | } 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This package is licensed under the MPL 2.0. For the MPL 2.0, please see LICENSE-MPL-RabbitMQ. 2 | 3 | If you have any questions regarding licensing, please contact us at 4 | info@rabbitmq.com. 5 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/src/main/java/com/rabbitmq/authbackend/ResourcePermission.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.authbackend; 2 | 3 | public enum ResourcePermission { 4 | READ, WRITE, CONFIGURE 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.lock 3 | .*.sw? 4 | .sw? 5 | .tool-versions 6 | erl_crash.dump 7 | rabbitmq_auth_backend_ip_range.d 8 | 9 | cover/ 10 | deps/ 11 | doc/ 12 | ebin/ 13 | .erlang.mk/ 14 | escript/ 15 | logs/ 16 | plugins/ 17 | sbin/ 18 | tmp/ 19 | -------------------------------------------------------------------------------- /test/test_SUITE_data/run_backend.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ex 4 | 5 | DIR=$(cd $(dirname $0) && pwd) 6 | 7 | EXAMPLE_DIRECTORY=${DIR}/../../examples/rabbitmq-auth-backend-java 8 | 9 | cd $EXAMPLE_DIRECTORY 10 | exec ./mvnw compile exec:java -Dexec.args="${AMQP_PORT}" -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /src/rabbit_auth_backend_amqp_app.erl: -------------------------------------------------------------------------------- 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-2020 VMware, Inc. or its affiliates. All rights reserved. 6 | %% 7 | 8 | -module(rabbit_auth_backend_amqp_app). 9 | 10 | -behaviour(application). 11 | -export([start/2, stop/1]). 12 | 13 | start(_Type, _StartArgs) -> 14 | rabbit_auth_backend_amqp_sup:start_link(). 15 | 16 | stop(_State) -> 17 | ok. 18 | -------------------------------------------------------------------------------- /test/config_schema_SUITE_data/rabbitmq_auth_backend_amqp.snippets: -------------------------------------------------------------------------------- 1 | [{auth_backend_amqp, 2 | "auth_backends.1 = amqp 3 | auth_amqp.username = user 4 | auth_amqp.vhost = my_vhost 5 | auth_amqp.exchange = exchange_name 6 | auth_amqp.timeout = 100", 7 | [{rabbit,[{auth_backends,[rabbit_auth_backend_amqp]}]}, 8 | {rabbitmq_auth_backend_amqp,[{username,<<"user">>}, 9 | {vhost,<<"my_vhost">>}, 10 | {exchange,<<"exchange_name">>}, 11 | {timeout,100}]}], 12 | [rabbitmq_auth_backend_amqp]}]. 13 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | pull_request: 4 | branches: 5 | - 'main' 6 | push: 7 | branches: 8 | - 'main' 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build-test: 13 | name: Build and test on Erlang/OTP ${{ matrix.otp-version }} 14 | runs-on: ubuntu-latest 15 | strategy: 16 | matrix: 17 | otp-version: [25, 26] 18 | steps: 19 | - uses: actions/checkout@v3 20 | - uses: erlef/setup-beam@v1 21 | with: 22 | otp-version: ${{matrix.otp-version}} 23 | elixir-version: 1.15.7 24 | - run: make 25 | - run: make tests 26 | -------------------------------------------------------------------------------- /src/rabbit_auth_backend_amqp_sup.erl: -------------------------------------------------------------------------------- 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-2020 VMware, Inc. or its affiliates. All rights reserved. 6 | %% 7 | 8 | -module(rabbit_auth_backend_amqp_sup). 9 | 10 | -include_lib("rabbit_common/include/rabbit.hrl"). 11 | 12 | -behaviour(supervisor). 13 | -export([start_link/0]). 14 | -export([init/1]). 15 | 16 | %%---------------------------------------------------------------------------- 17 | 18 | start_link() -> 19 | supervisor2:start_link(?MODULE, []). 20 | 21 | init([]) -> 22 | {ok, {{one_for_one,3,10}, 23 | [{rabbit_auth_backend_amqp, 24 | {rabbit_auth_backend_amqp, start_link, []}, 25 | transient, ?WORKER_WAIT, worker, [rabbit_auth_backend_amqp]}]}}. 26 | -------------------------------------------------------------------------------- /priv/schema/rabbitmq_auth_backend_amqp.schema: -------------------------------------------------------------------------------- 1 | {mapping, "auth_amqp.username", "rabbitmq_auth_backend_amqp.username", 2 | [{datatype, string}]}. 3 | 4 | {translation, "rabbitmq_auth_backend_amqp.username", 5 | fun(Conf) -> 6 | list_to_binary(cuttlefish:conf_get("auth_amqp.username", Conf)) 7 | end}. 8 | 9 | {mapping, "auth_amqp.vhost", "rabbitmq_auth_backend_amqp.vhost", 10 | [{datatype, string}]}. 11 | 12 | {translation, "rabbitmq_auth_backend_amqp.vhost", 13 | fun(Conf) -> 14 | list_to_binary(cuttlefish:conf_get("auth_amqp.vhost", Conf)) 15 | end}. 16 | 17 | {mapping, "auth_amqp.exchange", "rabbitmq_auth_backend_amqp.exchange", 18 | [{datatype, string}]}. 19 | 20 | {translation, "rabbitmq_auth_backend_amqp.exchange", 21 | fun(Conf) -> 22 | list_to_binary(cuttlefish:conf_get("auth_amqp.exchange", Conf)) 23 | end}. 24 | 25 | 26 | {mapping, "auth_amqp.timeout", "rabbitmq_auth_backend_amqp.timeout", 27 | [{datatype, [{enum, [infinity]}, integer]}]}. 28 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/src/main/java/com/rabbitmq/authbackend/AuthBackend.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.authbackend; 2 | 3 | /** 4 | * A Java-ish representation of the RabbitMQ authentication backend API 5 | */ 6 | public interface AuthBackend { 7 | public LoginResult login(String username); 8 | 9 | public LoginResult login(String username, 10 | String password); 11 | 12 | boolean checkVhost(String username, 13 | String vhost); 14 | 15 | boolean checkResource(String username, 16 | String vhost, 17 | String resourceName, 18 | ResourceType resourceType, 19 | ResourcePermission permission); 20 | 21 | boolean checkTopic(String username, 22 | String vhost, 23 | String resourceName, 24 | ResourceType resourceType, 25 | ResourcePermission permission, 26 | String routingKey); 27 | } 28 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/src/main/java/com/rabbitmq/authbackend/examples/TestMain.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.authbackend.examples; 2 | 3 | import com.rabbitmq.client.AuthenticationFailureException; 4 | import com.rabbitmq.client.Connection; 5 | import com.rabbitmq.client.ConnectionFactory; 6 | 7 | import java.io.IOException; 8 | import java.util.concurrent.TimeoutException; 9 | 10 | public class TestMain { 11 | public static void main(String[] args) throws IOException, TimeoutException { 12 | ConnectionFactory factory = new ConnectionFactory(); 13 | factory.setUsername("simon"); 14 | factory.setPassword("simon"); 15 | Connection conn = factory.newConnection(); 16 | conn.close(); 17 | 18 | try { 19 | factory.setUsername("simon"); 20 | factory.setPassword("wrong"); 21 | conn = factory.newConnection(); 22 | conn.close(); 23 | throw new RuntimeException("Expected auth failure!"); 24 | } 25 | catch (AuthenticationFailureException e) { 26 | // ok 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/src/main/java/com/rabbitmq/authbackend/LoginResult.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.authbackend; 2 | 3 | public class LoginResult { 4 | public LoginResult(boolean success) { 5 | this(success, new String[]{}); 6 | } 7 | 8 | public LoginResult(boolean success, String[] tags) { 9 | this.success = success; 10 | this.tags = tags; 11 | } 12 | 13 | private boolean success; 14 | private String[] tags; 15 | 16 | public boolean isSuccess() { 17 | return success; 18 | } 19 | 20 | public void setSuccess(boolean success) { 21 | this.success = success; 22 | } 23 | 24 | public String[] getTags() { 25 | return tags; 26 | } 27 | 28 | public void setTags(String[] tags) { 29 | this.tags = tags; 30 | } 31 | 32 | public String toString() { 33 | if (success) { 34 | String r = ""; 35 | for (int i = 0; i < tags.length; i++) { 36 | r += tags[i] + ","; 37 | } 38 | return r; 39 | } 40 | else { 41 | return "refused"; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PROJECT = rabbitmq_auth_backend_amqp 2 | PROJECT_DESCRIPTION = RabbitMQ AMQP Authentication Backend 3 | PROJECT_MOD = rabbit_auth_backend_amqp_app 4 | RABBITMQ_VERSION ?= v3.11.x 5 | 6 | define PROJECT_ENV 7 | [ 8 | {exchange, <<"authentication">>}, 9 | {vhost, <<"/">>}, 10 | {username, <<"guest">>}, 11 | {timeout, infinity} 12 | ] 13 | endef 14 | 15 | define PROJECT_APP_EXTRA_KEYS 16 | {broker_version_requirements, ["3.11.0"]} 17 | endef 18 | 19 | DEPS = rabbit_common rabbit amqp_client 20 | TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers 21 | 22 | DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk 23 | DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk 24 | 25 | # FIXME: Use erlang.mk patched for RabbitMQ, while waiting for PRs to be 26 | # reviewed and merged. 27 | 28 | ERLANG_MK_REPO = https://github.com/rabbitmq/erlang.mk.git 29 | ERLANG_MK_COMMIT = rabbitmq-tmp 30 | 31 | include rabbitmq-components.mk 32 | 33 | dep_amqp_client = git_rmq-subfolder rabbitmq-erlang-client $(RABBITMQ_VERSION) 34 | dep_rabbit_common = git_rmq-subfolder rabbitmq-common $(RABBITMQ_VERSION) 35 | dep_rabbit = git_rmq-subfolder rabbitmq-server $(RABBITMQ_VERSION) 36 | dep_rabbitmq_ct_client_helpers = git_rmq-subfolder rabbitmq-ct-client-helpers $(RABBITMQ_VERSION) 37 | dep_rabbitmq_ct_helpers = git_rmq-subfolder rabbitmq-ct-helpers $(RABBITMQ_VERSION) 38 | include erlang.mk 39 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/src/main/java/com/rabbitmq/authbackend/examples/Main.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.authbackend.examples; 2 | 3 | import com.rabbitmq.authbackend.AuthBackend; 4 | import com.rabbitmq.authbackend.AuthServer; 5 | import com.rabbitmq.client.Channel; 6 | import com.rabbitmq.client.Connection; 7 | import com.rabbitmq.client.ConnectionFactory; 8 | 9 | import java.io.IOException; 10 | import java.net.ConnectException; 11 | import java.util.Date; 12 | 13 | /** 14 | * 15 | */ 16 | public class Main { 17 | private static final ConnectionFactory FACTORY = new ConnectionFactory(); 18 | private static final String EXCHANGE = "authentication"; 19 | private static final AuthBackend BACKEND = new ExampleAuthBackend(); 20 | 21 | public static void main(String[] args) throws IOException { 22 | FACTORY.setPort(Integer.parseInt(args[0])); 23 | try { 24 | while (true) { 25 | System.out.print(new Date() + " Connecting..."); 26 | try { 27 | Connection conn = FACTORY.newConnection(); 28 | Channel ch = conn.createChannel(); 29 | System.out.println(" done"); 30 | 31 | new AuthServer(BACKEND, ch, EXCHANGE).mainloop(); 32 | System.out.println(new Date() + " Connection died"); 33 | } 34 | catch (ConnectException e) { 35 | System.out.println(" failed"); 36 | } 37 | Thread.sleep(1000); 38 | } 39 | 40 | } catch (Exception ex) { 41 | System.err.println("Main thread caught exception: " + ex); 42 | ex.printStackTrace(); 43 | System.exit(1); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.rabbitmq 7 | rabbitmq-auth-backend-amqp-example 8 | 5.7.1 9 | jar 10 | 11 | rabbitmq-auth-backend-amqp-example 12 | RabbitMQ Auth Backend AMQP Example 13 | https://www.rabbitmq.com 14 | 15 | 16 | UTF-8 17 | 18 | 19 | 20 | 21 | com.rabbitmq 22 | amqp-client 23 | 5.18.0 24 | 25 | 26 | 27 | 28 | 29 | 30 | maven-compiler-plugin 31 | 3.8.1 32 | 33 | 1.8 34 | 1.8 35 | 36 | 37 | 38 | org.codehaus.mojo 39 | exec-maven-plugin 40 | 1.6.0 41 | 42 | com.rabbitmq.authbackend.examples.Main 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /test/unit_SUITE.erl: -------------------------------------------------------------------------------- 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) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. 6 | %% 7 | 8 | -module(unit_SUITE). 9 | 10 | -include_lib("common_test/include/ct.hrl"). 11 | 12 | -compile(export_all). 13 | 14 | all() -> 15 | [ 16 | {group, non_parallel_tests} 17 | ]. 18 | 19 | groups() -> 20 | [ 21 | {non_parallel_tests, [], [ 22 | table 23 | ]} 24 | ]. 25 | 26 | init_per_group(_, Config) -> Config. 27 | end_per_group(_, Config) -> Config. 28 | 29 | table(_Config) -> 30 | [{<<"action">>,longstr,<<"check_resource">>}, 31 | {<<"username">>,longstr,<<"simon">>}, 32 | {<<"vhost">>,longstr,<<"/">>}, 33 | {<<"resource">>,longstr,<<"queue">>}, 34 | {<<"name">>,longstr,<<"mqtt-subscription-01">>}, 35 | {<<"permission">>,longstr,<<"read">>}] = rabbit_auth_backend_amqp:table( 36 | [{action,check_resource}, 37 | {username,<<"simon">>}, 38 | {vhost,<<"/">>}, 39 | {resource,queue}, 40 | {name,<<"mqtt-subscription-01">>}, 41 | {permission,read}] 42 | ), 43 | 44 | [{<<"action">>,longstr,<<"check_topic">>}, 45 | {<<"routing_key">>,longstr,<<"amq.topic">>}, 46 | {<<"variable_map.client_id">>,longstr,<<"TestPublisher">>}, 47 | {<<"variable_map.username">>,longstr,<<"simon">>}, 48 | {<<"variable_map.vhost">>,longstr,<<"/">>}] = rabbit_auth_backend_amqp:table( 49 | [{action,check_topic}, 50 | {routing_key,<<"amq.topic">>}, 51 | {variable_map,#{<<"client_id">> => <<"TestPublisher">>, 52 | <<"username">> => <<"simon">>, 53 | <<"vhost">> => <<"/">>}}]), 54 | ok. 55 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/src/main/java/com/rabbitmq/authbackend/examples/ExampleAuthBackend.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.authbackend.examples; 2 | 3 | import com.rabbitmq.authbackend.AuthBackend; 4 | import com.rabbitmq.authbackend.LoginResult; 5 | import com.rabbitmq.authbackend.ResourcePermission; 6 | import com.rabbitmq.authbackend.ResourceType; 7 | 8 | /** 9 | * 10 | */ 11 | public class ExampleAuthBackend implements AuthBackend { 12 | private static final LoginResult ACCEPTED = new LoginResult(true, new String[]{"administrator"}); 13 | private static final LoginResult REFUSED = new LoginResult(false); 14 | 15 | public LoginResult login(String username) { 16 | if (username.equals("smacmullen.eng.vmware.com")) { 17 | return ACCEPTED; 18 | } 19 | 20 | return REFUSED; 21 | } 22 | 23 | public LoginResult login(String username, 24 | String password) { 25 | if (username.equals("simon") && password.equals("simon")) { 26 | return ACCEPTED; 27 | } 28 | 29 | return REFUSED; 30 | } 31 | 32 | public boolean checkVhost(String username, 33 | String vhost) { 34 | return vhost.equals("/"); 35 | } 36 | 37 | public boolean checkResource(String username, 38 | String vhost, 39 | String resourceName, 40 | ResourceType resourceType, 41 | ResourcePermission permission) { 42 | return true; 43 | } 44 | 45 | public boolean checkTopic(String username, 46 | String vhost, 47 | String resourceName, 48 | ResourceType resourceType, 49 | ResourcePermission permission, 50 | String routingKey) { 51 | return routingKey.startsWith("a"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/config_schema_SUITE.erl: -------------------------------------------------------------------------------- 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) 2016-2020 VMware, Inc. or its affiliates. All rights reserved. 6 | %% 7 | 8 | -module(config_schema_SUITE). 9 | 10 | -compile(export_all). 11 | 12 | all() -> 13 | [ 14 | run_snippets 15 | ]. 16 | 17 | %% ------------------------------------------------------------------- 18 | %% Testsuite setup/teardown. 19 | %% ------------------------------------------------------------------- 20 | 21 | init_per_suite(Config) -> 22 | rabbit_ct_helpers:log_environment(), 23 | Config1 = rabbit_ct_helpers:run_setup_steps(Config), 24 | rabbit_ct_config_schema:init_schemas(rabbitmq_auth_backend_amqp, Config1). 25 | 26 | 27 | end_per_suite(Config) -> 28 | rabbit_ct_helpers:run_teardown_steps(Config). 29 | 30 | init_per_testcase(Testcase, Config) -> 31 | rabbit_ct_helpers:testcase_started(Config, Testcase), 32 | Config1 = rabbit_ct_helpers:set_config(Config, [ 33 | {rmq_nodename_suffix, Testcase} 34 | ]), 35 | rabbit_ct_helpers:run_steps(Config1, 36 | rabbit_ct_broker_helpers:setup_steps() ++ 37 | rabbit_ct_client_helpers:setup_steps()). 38 | 39 | end_per_testcase(Testcase, Config) -> 40 | Config1 = rabbit_ct_helpers:run_steps(Config, 41 | rabbit_ct_client_helpers:teardown_steps() ++ 42 | rabbit_ct_broker_helpers:teardown_steps()), 43 | rabbit_ct_helpers:testcase_finished(Config1, Testcase). 44 | 45 | %% ------------------------------------------------------------------- 46 | %% Testcases. 47 | %% ------------------------------------------------------------------- 48 | 49 | run_snippets(Config) -> 50 | ok = rabbit_ct_broker_helpers:rpc(Config, 0, 51 | ?MODULE, run_snippets1, [Config]). 52 | 53 | run_snippets1(Config) -> 54 | rabbit_ct_config_schema:run_snippets(Config). 55 | 56 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | RabbitMQ projects use pull requests to discuss, collaborate on and accept code contributions. 4 | Pull requests is the primary place of discussing code changes. 5 | 6 | ## How to Contribute 7 | 8 | The process is fairly standard: 9 | 10 | * Fork the repository or repositories you plan on contributing to 11 | * Run `make` 12 | * Create a branch with a descriptive name in the relevant repositories 13 | * Make your changes, run tests, ensure correct code formatting, commit with a [descriptive message](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), push to your fork 14 | * Submit pull requests with an explanation what has been changed and **why** 15 | * Submit a filled out and signed [Contributor Agreement](https://cla.pivotal.io/) if needed (see below) 16 | * Be patient. We will get to your pull request eventually 17 | 18 | If what you are going to work on is a substantial change, please first ask the core team 19 | of their opinion on [RabbitMQ mailing list](https://groups.google.com/forum/#!forum/rabbitmq-users). 20 | 21 | ## Running Tests 22 | 23 | See [this guide on how to use Bazel and BuildBuddy for RabbitMQ core development](https://github.com/rabbitmq/contribute/wiki/Bazel-and-BuildBuddy). 24 | 25 | ## Formatting the RabbitMQ CLI 26 | 27 | The RabbitMQ CLI uses the standard [Elixir code formatter](https://hexdocs.pm/mix/main/Mix.Tasks.Format.html). To ensure correct code formatting of the CLI: 28 | 29 | ``` 30 | cd deps/rabbitmq_cli 31 | mix format 32 | ``` 33 | 34 | Running `make` will validate the CLI formatting and issue any necessary warnings. Alternatively, run the format checker in the `deps/rabbitmq_cli` directory: 35 | 36 | ``` 37 | mix format --check-formatted 38 | ``` 39 | 40 | ## Code of Conduct 41 | 42 | See [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md). 43 | 44 | ## Contributor Agreement 45 | 46 | If you want to contribute a non-trivial change, please submit a signed copy of our 47 | [Contributor Agreement](https://cla.pivotal.io/) around the time 48 | you submit your pull request. This will make it much easier (in some cases, possible) 49 | for the RabbitMQ team at Pivotal to merge your contribution. 50 | 51 | ## Where to Ask Questions 52 | 53 | If something isn't clear, feel free to ask on our [mailing list](https://groups.google.com/forum/#!forum/rabbitmq-users) 54 | and [community Slack](https://rabbitmq-slack.herokuapp.com/). 55 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of fostering an open 4 | and welcoming community, we pledge to respect all people who contribute through reporting 5 | issues, posting feature requests, updating documentation, submitting pull requests or 6 | patches, and other activities. 7 | 8 | We are committed to making participation in this project a harassment-free experience for 9 | everyone, regardless of level of experience, gender, gender identity and expression, 10 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, 11 | religion, or nationality. 12 | 13 | Examples of unacceptable behavior by participants include: 14 | 15 | * The use of sexualized language or imagery 16 | * Personal attacks 17 | * Trolling or insulting/derogatory comments 18 | * Public or private harassment 19 | * Publishing other's private information, such as physical or electronic addresses, 20 | without explicit permission 21 | * Other unethical or unprofessional conduct 22 | 23 | Project maintainers have the right and responsibility to remove, edit, or reject comments, 24 | commits, code, wiki edits, issues, and other contributions that are not aligned to this 25 | Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors 26 | that they deem inappropriate, threatening, offensive, or harmful. 27 | 28 | By adopting this Code of Conduct, project maintainers commit themselves to fairly and 29 | consistently applying these principles to every aspect of managing this project. Project 30 | maintainers who do not follow or enforce the Code of Conduct may be permanently removed 31 | from the project team. 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an 34 | individual is representing the project or its community. 35 | 36 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 37 | contacting a project maintainer at [info@rabbitmq.com](mailto:info@rabbitmq.com). All complaints will 38 | be reviewed and investigated and will result in a response that is deemed necessary and 39 | appropriate to the circumstances. Maintainers are obligated to maintain confidentiality 40 | with regard to the reporter of an incident. 41 | 42 | This Code of Conduct is adapted from the 43 | [Contributor Covenant](https://contributor-covenant.org), version 1.3.0, available at 44 | [contributor-covenant.org/version/1/3/0/](https://contributor-covenant.org/version/1/3/0/) 45 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/src/main/java/com/rabbitmq/authbackend/AuthServer.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.authbackend; 2 | 3 | import com.rabbitmq.client.AMQP; 4 | import com.rabbitmq.client.Channel; 5 | import com.rabbitmq.client.Delivery; 6 | import com.rabbitmq.client.RpcServer; 7 | 8 | import java.io.IOException; 9 | import java.io.UnsupportedEncodingException; 10 | import java.util.Map; 11 | 12 | /** 13 | * Simple RPC server that unpacks arguments and defers to an AuthBackend 14 | */ 15 | public class AuthServer extends RpcServer { 16 | private AuthBackend authBackend; 17 | 18 | public AuthServer(AuthBackend authBackend, Channel channel, String exchangeName) throws IOException { 19 | super(channel); 20 | this.authBackend = authBackend; 21 | channel.queueBind(getQueueName(), exchangeName, ""); 22 | } 23 | 24 | public byte[] handleCall(Delivery request, 25 | AMQP.BasicProperties replyProperties) 26 | { 27 | Map headers = request.getProperties().getHeaders(); 28 | String action = get("action", headers); 29 | 30 | if (action.equals("login")) { 31 | String username = get("username", headers); 32 | String password = get("password", headers); 33 | LoginResult res = password == null ? authBackend.login(username) : 34 | authBackend.login(username, password); 35 | return bytes(res.toString().toLowerCase()); 36 | } 37 | else if (action.equals("check_vhost")) { 38 | return bool(authBackend.checkVhost( 39 | get("username", headers), 40 | get("vhost", headers))); 41 | } 42 | else if (action.equals("check_resource")) { 43 | return bool(authBackend.checkResource( 44 | get("username", headers), 45 | get("vhost", headers), 46 | get("name", headers), 47 | ResourceType.valueOf(getU("resource", headers)), 48 | ResourcePermission.valueOf(getU("permission", headers)))); 49 | } 50 | else if (action.equals("check_topic")) { 51 | return bool(authBackend.checkTopic( 52 | get("username", headers), 53 | get("vhost", headers), 54 | get("name", headers), 55 | ResourceType.valueOf(getU("resource", headers)), 56 | ResourcePermission.valueOf(getU("permission", headers)), 57 | get("routing_key", headers))); 58 | } 59 | 60 | throw new RuntimeException("Unexpected action " + action); 61 | } 62 | 63 | private String getU(String key, Map headers) { 64 | return get(key,headers).toUpperCase(); 65 | } 66 | 67 | private String get(String key, Map headers) { 68 | Object o = headers.get(key); 69 | return o == null ? null : o.toString(); 70 | } 71 | 72 | private byte[] bytes(String s) { 73 | try { 74 | return s.getBytes("utf-8"); 75 | } catch (UnsupportedEncodingException e) { 76 | throw new RuntimeException(e); 77 | } 78 | } 79 | 80 | private byte[] bool(boolean b) { 81 | return bytes(b ? "allow" : "deny"); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | This plugin provides the ability for your RabbitMQ server to perform 4 | authentication (determining who can log in) and authorisation 5 | (determining what permissions they have) by connecting to an 6 | authorisation server over RPC-over-AMQP. 7 | 8 | The plugin requires RabbitMQ 3.2.x or a later version. 9 | 10 | Note: this is a rarely used plugin, and could be made rather 11 | more robust. 12 | 13 | ## Downloading 14 | 15 | You can download a pre-built binary of this plugin from 16 | the [Community Plugins page](http://www.rabbitmq.com/community-plugins.html). 17 | 18 | ## Building 19 | 20 | You can build and install it like any other plugin (see 21 | [the plugin development guide](http://www.rabbitmq.com/plugin-development.html)). 22 | 23 | This plugin depends on the Erlang client. 24 | 25 | ## Enabling the plugin 26 | 27 | To enable the plugin, set the value of the `auth_backends` configuration item 28 | for the `rabbit` application to include `rabbit_auth_backend_amqp`. 29 | `auth_backends` is a list of authentication providers to try in order. 30 | 31 | Obviously your authentication server cannot vouch for itself, so 32 | you'll need another backend with at least one user in it. You should 33 | probably use the internal database: 34 | 35 | [{rabbit, 36 | [{auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_amqp]}] 37 | }]. 38 | 39 | ## Configuring the plugin 40 | 41 | You need to configure the plugin to know which exchange to publish 42 | authentication requests to. 43 | 44 | Below is a minimal `rabbitmq.conf` example (currently only in master): 45 | 46 | auth_backends.1 = internal 47 | auth_backends.2 = amqp 48 | 49 | auth_amqp.username = guest 50 | auth_amqp.vhost = / 51 | auth_amqp.exchange = authentication 52 | 53 | Or, in the classic config format (`rabbitmq.config`, prior to 3.7.0) or `advanced.config`: 54 | 55 | [ 56 | {rabbit, [{auth_backends, [rabbit_auth_backend_internal, 57 | rabbit_auth_backend_amqp]}]}, 58 | {rabbitmq_auth_backend_amqp, 59 | [{username, <<"guest">>}, 60 | {vhost, <<"/">>}, 61 | {exchange, <<"authentication">>}]} 62 | ]. 63 | 64 | Authentication requests will be packed into the headers of incoming 65 | messages. There are four types of request: `login`, `check_vhost`, 66 | `check_resource` and `check_topic`. Responses should be returned in the message 67 | body. Responses to `login` requests should be "refused" if login is 68 | unsuccessful or a comma-separated list of tags for the user if login 69 | is successful. Responses to the other types should be the words 70 | "allow" or "deny". 71 | 72 | It will probably be a good idea to look at the Java example for more 73 | details. 74 | 75 | You can also specify a `timeout` config item. This should be an 76 | integer number of milliseconds to wait for a response from the RPC 77 | server, or `infinity` to wait forever (the default). If the RPC server 78 | does not respond in time, the request for access is denied. 79 | 80 | ## Example App (in Java) 81 | 82 | In `examples/rabbitmq-auth-backend-java` there's a Java based 83 | authentication server framework based around the 84 | `com.rabbitmq.authbackend.AuthBackend` interface with a very trivial 85 | implementation in `com.rabbitmq.authbackend.examples` (which will 86 | authenticate "simon" / "simon"). This implementation also checks 87 | the routing key starts by `a` when publishing to a topic exchange 88 | or consuming from a topic. 89 | (a.k.a. [topic authorisation](http://www.rabbitmq.com/access-control.html#topic-authorisation)). 90 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.5"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /test/test_SUITE.erl: -------------------------------------------------------------------------------- 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-2012 VMware, Inc. All rights reserved. 6 | %% 7 | 8 | -module(test_SUITE). 9 | 10 | -include_lib("eunit/include/eunit.hrl"). 11 | -include_lib("common_test/include/ct.hrl"). 12 | -include_lib("amqp_client/include/amqp_client.hrl"). 13 | 14 | -compile(export_all). 15 | 16 | all() -> 17 | [ 18 | {group, non_parallel_tests} 19 | ]. 20 | 21 | groups() -> 22 | [ 23 | {non_parallel_tests, [], [ 24 | with_backend, 25 | topic_authorisation 26 | ]} 27 | ]. 28 | 29 | %% ------------------------------------------------------------------- 30 | %% Testsuite setup/teardown. 31 | %% ------------------------------------------------------------------- 32 | %% 33 | configure_backend(Config) -> 34 | rabbit_ct_helpers:merge_app_env(Config, 35 | {rabbit, [ 36 | {auth_backends, 37 | [rabbit_auth_backend_internal, 38 | rabbit_auth_backend_amqp]}]}). 39 | 40 | init_per_suite(Config) -> 41 | rabbit_ct_helpers:log_environment(), 42 | Config1 = rabbit_ct_helpers:set_config(Config, [ 43 | {rmq_nodename_suffix, ?MODULE} 44 | ]), 45 | 46 | rabbit_ct_helpers:run_setup_steps(Config1, 47 | [ fun configure_backend/1 ] ++ 48 | rabbit_ct_broker_helpers:setup_steps()). 49 | 50 | end_per_suite(Config) -> 51 | rabbit_ct_helpers:run_teardown_steps(Config, 52 | rabbit_ct_broker_helpers:teardown_steps()). 53 | 54 | init_per_group(_, Config) -> Config. 55 | 56 | end_per_group(_, Config) -> Config. 57 | 58 | init_per_testcase(Testcase, Config) -> 59 | rabbit_ct_helpers:testcase_started(Config, Testcase), 60 | start_backend(Config). 61 | 62 | end_per_testcase(Testcase, Config) -> 63 | stop_backend(Config), 64 | rabbit_ct_helpers:testcase_finished(Config, Testcase). 65 | 66 | start_backend(Config) -> 67 | Parent = self(), 68 | Child = spawn(fun() -> start_backend(Config, Parent) end), 69 | Config1 = rabbit_ct_helpers:set_config(Config, {backend_pid, Child}), 70 | wait_for_backend(Config1). 71 | 72 | start_backend(Config, Parent) -> 73 | Script = filename:join([?config(data_dir, Config), "run_backend.sh"]), 74 | BuildDir = filename:join([?config(priv_dir, Config), "build"]), 75 | ok = filelib:ensure_dir(filename:join(BuildDir, "dummy")), 76 | AmqpPort = rabbit_ct_broker_helpers:get_node_config(Config, 0, 77 | tcp_port_amqp), 78 | Port = erlang:open_port({spawn_executable, Script}, [ 79 | use_stdio, 80 | stderr_to_stdout, 81 | exit_status, 82 | {env, [ 83 | {"AMQP_PORT", integer_to_list(AmqpPort)} 84 | ]}]), 85 | backend_loop(Port, Parent, ""). 86 | 87 | backend_loop(Port, Parent, Output) -> 88 | receive 89 | {Port, {data, Line}} -> 90 | backend_loop(Port, Parent, Output ++ Line); 91 | {Port, {exit_status, X}} -> 92 | print_port_data(Output), 93 | ct:pal(?LOW_IMPORTANCE, "Backend exited with ~p", 94 | [integer_to_list(X)]), 95 | Parent ! {backend_exited, X}; 96 | stop -> 97 | print_port_data(Output), 98 | {os_pid, Pid} = erlang:port_info(Port, os_pid), 99 | ct:pal(?LOW_IMPORTANCE, "Stopping backend (system PID: ~p)...", [Pid]), 100 | KillCmd = case os:type() of 101 | {unix, _} -> ["kill", integer_to_list(Pid)]; 102 | {win32, _} -> ["taskkill", "/PID", integer_to_list(Pid)] 103 | end, 104 | rabbit_ct_helpers:exec(KillCmd, []), 105 | backend_loop(Port, Parent, "") 106 | after 200 -> 107 | print_port_data(Output), 108 | backend_loop(Port, Parent, "") 109 | end. 110 | 111 | print_port_data([]) -> ok; 112 | print_port_data(Output) -> ct:pal(?LOW_IMPORTANCE, "Backend:~n~s", [Output]). 113 | 114 | wait_for_backend(Config) -> 115 | Source = #resource{ 116 | virtual_host = <<"/">>, 117 | kind = exchange, 118 | name = <<"authentication">>}, 119 | Bindings = rabbit_ct_broker_helpers:rpc(Config, 0, 120 | rabbit_binding, list_for_source, [Source]), 121 | case Bindings of 122 | [] -> 123 | receive 124 | {backend_exited, X} -> 125 | Code = integer_to_list(X), 126 | exit("Failed to start backend; exited with code " ++ Code) 127 | after 200 -> 128 | wait_for_backend(Config) 129 | end; 130 | _ -> 131 | %% Once there is a queue bound to the `authentication` 132 | %% exchange, we assume it's the test backend. 133 | Config 134 | end. 135 | 136 | stop_backend(Config) -> 137 | Child = ?config(backend_pid, Config), 138 | Child ! stop, 139 | receive 140 | {backend_exited, _} -> 141 | ok 142 | end. 143 | 144 | %% ------------------------------------------------------------------- 145 | %% Testcases. 146 | %% ------------------------------------------------------------------- 147 | 148 | with_backend(Config) -> 149 | 150 | AmqpPort = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp), 151 | Host = rabbit_ct_helpers:get_config(Config, rmq_hostname), 152 | {ok, Con} = amqp_connection:start(#amqp_params_network{host = Host, 153 | port = AmqpPort, 154 | username = <<"simon">>, 155 | password = <<"simon">>}), 156 | 157 | ok = amqp_connection:close(Con), 158 | 159 | {error, {auth_failure, _}} = 160 | amqp_connection:start(#amqp_params_network{host = Host, 161 | port = AmqpPort, 162 | username = <<"karl">>, 163 | password = <<"bananas">>}). 164 | 165 | topic_authorisation(Config) -> 166 | %% backend lets pass if routing key starts by 'a' 167 | %% should pass 168 | test_publish(Config, <<"a.b.c">>, ok), 169 | %% should not pass 170 | test_publish(Config, <<"b.c">>, fail), 171 | ok. 172 | 173 | 174 | test_publish(Config, RoutingKey, ExpectedResult) -> 175 | AmqpPort = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp), 176 | Host = rabbit_ct_helpers:get_config(Config, rmq_hostname), 177 | {ok, Connection} = amqp_connection:start(#amqp_params_network{host = Host, 178 | port = AmqpPort, 179 | username = <<"simon">>, 180 | password = <<"simon">>}), 181 | {ok, Channel} = amqp_connection:open_channel(Connection), 182 | ActualResult = try 183 | Publish = #'basic.publish'{exchange = <<"amq.topic">>, routing_key = RoutingKey}, 184 | amqp_channel:cast(Channel, Publish, #amqp_msg{payload = <<"foobar">>}), 185 | amqp_channel:call(Channel, #'basic.qos'{prefetch_count = 0}), 186 | ok 187 | catch exit:_ -> fail 188 | after 189 | amqp_connection:close(Connection) 190 | end, 191 | ExpectedResult = ActualResult. 192 | -------------------------------------------------------------------------------- /src/rabbit_auth_backend_amqp.erl: -------------------------------------------------------------------------------- 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-2020 VMware, Inc. or its affiliates. All rights reserved. 6 | %% 7 | 8 | -module(rabbit_auth_backend_amqp). 9 | 10 | -include_lib("amqp_client/include/amqp_client.hrl"). 11 | 12 | -behaviour(rabbit_authn_backend). 13 | -behaviour(rabbit_authz_backend). 14 | 15 | -export([description/0]). 16 | 17 | -export([user_login_authentication/2, user_login_authorization/2, 18 | check_vhost_access/3, check_resource_access/4, check_topic_access/4, 19 | state_can_expire/0, expiry_timestamp/1]). 20 | 21 | -behaviour(gen_server). 22 | 23 | -export([start_link/0]). 24 | -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, 25 | code_change/3]). 26 | 27 | % for testing 28 | -export([table/1]). 29 | 30 | -define(SERVER, ?MODULE). 31 | -define(CHECK_RESOURCE_ACCESS_HEADERS, [username, vhost, resource, name, permission]). 32 | 33 | -record(state, {connection, channel, exchange, reply_queue, 34 | correlation_id = 0, timeout}). 35 | 36 | %%-------------------------------------------------------------------- 37 | 38 | description() -> 39 | [{name, <<"AMQP">>}, 40 | {description, <<"AMQP authentication / authorisation">>}]. 41 | 42 | start_link() -> 43 | gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). 44 | 45 | %%-------------------------------------------------------------------- 46 | 47 | user_login_authentication(Username, AuthProps) -> 48 | gen_server:call(?SERVER, {login, Username, AuthProps}, infinity). 49 | 50 | user_login_authorization(Username, AuthProps) -> 51 | case user_login_authentication(Username, AuthProps) of 52 | {ok, #auth_user{impl = Impl}} -> {ok, Impl}; 53 | Else -> Else 54 | end. 55 | 56 | check_vhost_access(#auth_user{username = Username}, VHost, AuthzData = #{peeraddr := PeerAddr}) -> 57 | AuthzData1 = maps:remove(peeraddr, AuthzData), 58 | OptionsHeaders = context_as_headers(AuthzData1), 59 | gen_server:call(?SERVER, {check_vhost, [{username, Username}, 60 | {vhost, VHost}, 61 | {ip, parse_peeraddr(PeerAddr)}] ++ OptionsHeaders}, 62 | infinity). 63 | 64 | check_resource_access(#auth_user{username = Username}, 65 | #resource{virtual_host = VHost, kind = Type, name = Name}, 66 | Permission, 67 | AuthzContext) -> 68 | OptionsHeaders = context_as_headers(AuthzContext), 69 | gen_server:call(?SERVER, {check_resource, [{username, Username}, 70 | {vhost, VHost}, 71 | {resource, Type}, 72 | {name, Name}, 73 | {permission, Permission}] ++ OptionsHeaders}, 74 | infinity). 75 | 76 | check_topic_access(#auth_user{username = Username}, 77 | #resource{virtual_host = VHost, kind = topic = Type, name = Name}, 78 | Permission, 79 | Context) -> 80 | OptionsHeaders = context_as_headers(Context), 81 | gen_server:call(?SERVER, {check_topic, [{username, Username}, 82 | {vhost, VHost}, 83 | {resource, Type}, 84 | {name, Name}, 85 | {permission, Permission}] ++ OptionsHeaders}, 86 | infinity). 87 | 88 | state_can_expire() -> false. 89 | 90 | expiry_timestamp(_) -> 91 | never. 92 | 93 | %%-------------------------------------------------------------------- 94 | 95 | context_as_headers(Options) when is_map(Options) -> 96 | % filter options that would erase fixed parameters 97 | [{rabbit_data_coercion:to_atom(Key), maps:get(Key, Options)} 98 | || Key <- maps:keys(Options), 99 | lists:member( 100 | rabbit_data_coercion:to_atom(Key), 101 | ?CHECK_RESOURCE_ACCESS_HEADERS) =:= false]; 102 | context_as_headers(_) -> 103 | []. 104 | 105 | init([]) -> 106 | {ok, X} = application:get_env(exchange), 107 | {ok, Timeout} = application:get_env(timeout), 108 | case open(params()) of 109 | {ok, Conn, Ch} -> 110 | erlang:monitor(process, Ch), 111 | #'confirm.select_ok'{} = 112 | amqp_channel:call(Ch, #'confirm.select'{}), 113 | amqp_channel:register_confirm_handler(Ch, self()), 114 | amqp_channel:register_return_handler(Ch, self()), 115 | #'exchange.declare_ok'{} = 116 | amqp_channel:call( 117 | Ch, #'exchange.declare'{exchange = X, 118 | type = <<"fanout">>}), 119 | #'queue.declare_ok'{queue = Q} = 120 | amqp_channel:call(Ch, #'queue.declare'{exclusive = true}), 121 | #'basic.consume_ok'{} = 122 | amqp_channel:subscribe(Ch, #'basic.consume'{queue = Q, 123 | no_ack = true}, 124 | self()), 125 | {ok, #state{connection = Conn, 126 | channel = Ch, 127 | exchange = X, 128 | reply_queue = Q, 129 | timeout = Timeout}}; 130 | E -> 131 | {stop, E} 132 | end. 133 | 134 | handle_call({login, Username, AuthProps}, _From, State) -> 135 | Res = case rpc([{action, login}, 136 | {username, Username}] ++ AuthProps, State) of 137 | <<"refused">> -> {refused, "Denied by AMQP plugin", []}; 138 | {error, _} = E -> E; 139 | Resp -> Tags0 = string:tokens(binary_to_list(Resp),","), 140 | Tags = [list_to_atom(T) || T <- Tags0], 141 | {ok, #auth_user{username = Username, 142 | tags = Tags, 143 | impl = none}} 144 | end, 145 | {reply, Res, incr(State)}; 146 | 147 | handle_call({check_vhost, Args}, _From, State) -> 148 | {reply, bool_rpc([{action, check_vhost} | Args], State), State}; 149 | 150 | handle_call({check_resource, Args}, _From, State) -> 151 | {reply, bool_rpc([{action, check_resource} | Args], State), State}; 152 | 153 | handle_call({check_topic, Args}, _From, State) -> 154 | {reply, bool_rpc([{action, check_topic} | Args], State), State}; 155 | 156 | handle_call(_Req, _From, State) -> 157 | {reply, unknown_request, State}. 158 | 159 | handle_cast(_C, State) -> 160 | {noreply, State}. 161 | 162 | handle_info({'DOWN', _Ref, process, _Ch, Reason}, State) -> 163 | {stop, {channel_down, Reason}, State}; 164 | 165 | handle_info(_I, State) -> 166 | {noreply, State}. 167 | 168 | terminate(_, #state{connection = Conn, 169 | channel = Ch}) -> 170 | ensure_closed(Conn, Ch), 171 | ok. 172 | 173 | code_change(_, State, _) -> {ok, State}. 174 | 175 | %%-------------------------------------------------------------------- 176 | 177 | open(Params) -> 178 | case amqp_connection:start(Params) of 179 | {ok, Conn} -> case amqp_connection:open_channel(Conn) of 180 | {ok, Ch} -> erlang:monitor(process, Ch), 181 | {ok, Conn, Ch}; 182 | E -> catch amqp_connection:close(Conn), 183 | E 184 | end; 185 | E -> E 186 | end. 187 | 188 | ensure_closed(Conn, Ch) -> 189 | ensure_closed(Ch), 190 | catch amqp_connection:close(Conn). 191 | 192 | ensure_closed(Ch) -> 193 | catch amqp_channel:close(Ch). 194 | 195 | %%-------------------------------------------------------------------- 196 | 197 | %% TODO don't block while logging in! 198 | 199 | rpc(Query, State = #state{channel = Ch, 200 | reply_queue = Q, 201 | exchange = X, 202 | correlation_id = Id}) -> 203 | CId = list_to_binary(integer_to_list(Id)), 204 | Props = #'P_basic'{headers = table(Query), 205 | reply_to = Q, 206 | correlation_id = CId}, 207 | amqp_channel:cast(Ch, #'basic.publish'{exchange = X, 208 | routing_key = <<>>, 209 | mandatory = true}, 210 | #amqp_msg{props = Props, 211 | payload = <<>>}), 212 | receive 213 | {#'basic.return'{}, _} -> 214 | receive 215 | #'basic.ack'{} -> ok 216 | end, 217 | {error, rpc_server_not_listening}; 218 | #'basic.ack'{} -> 219 | await_reply(CId, State) 220 | end. 221 | 222 | await_reply(CId, State = #state{timeout = Timeout}) -> 223 | receive 224 | {#'basic.deliver'{}, 225 | #amqp_msg{props = #'P_basic'{correlation_id = CId2}, 226 | payload = Payload}} -> 227 | case CId2 of 228 | CId -> Payload; 229 | _ -> await_reply(CId, State) 230 | end 231 | after Timeout -> 232 | {error, rpc_timeout} 233 | end. 234 | 235 | bool_rpc(Query, State) -> 236 | case rpc(Query, State) of 237 | <<"allow">> -> true; 238 | <<"deny">> -> false; 239 | {error, _} = E -> E 240 | end. 241 | 242 | incr(State = #state{correlation_id = Id}) -> 243 | State#state{correlation_id = Id + 1}. 244 | 245 | table(Query) -> 246 | lists:flatten([table_row(Row) || Row <- Query]). 247 | 248 | table_row({MapKey, Map}) when is_map(Map) -> 249 | MapKeyBin = bin(MapKey), 250 | Delimiter = <<".">>, 251 | KeyPrefix = <>, 252 | [begin 253 | KeyBin = rabbit_data_coercion:to_binary(Key), 254 | KeyWithPrefix = <>, 255 | table_row({KeyWithPrefix, rabbit_data_coercion:to_binary(Value)}) 256 | end 257 | || {Key, Value} <- maps:to_list(Map)]; 258 | table_row({K, V}) -> 259 | {bin(K), longstr, bin(V)}. 260 | 261 | bin(Term) -> 262 | rabbit_data_coercion:to_binary(Term). 263 | 264 | %%-------------------------------------------------------------------- 265 | 266 | params() -> 267 | {ok, VHost} = application:get_env(vhost), 268 | {ok, Username} = application:get_env(username), 269 | #amqp_params_direct{username = Username, 270 | virtual_host = VHost}. 271 | 272 | parse_peeraddr(PeerAddr) -> 273 | handle_inet_ntoa_peeraddr(inet:ntoa(PeerAddr), PeerAddr). 274 | 275 | handle_inet_ntoa_peeraddr({error, einval}, PeerAddr) -> 276 | rabbit_data_coercion:to_list(PeerAddr); 277 | handle_inet_ntoa_peeraddr(PeerAddrStr, _PeerAddr0) -> 278 | PeerAddrStr. 279 | -------------------------------------------------------------------------------- /examples/rabbitmq-auth-backend-java/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /LICENSE-MPL-RabbitMQ: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /rabbitmq-components.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(.DEFAULT_GOAL),) 2 | # Define default goal to `all` because this file defines some targets 3 | # before the inclusion of erlang.mk leading to the wrong target becoming 4 | # the default. 5 | .DEFAULT_GOAL = all 6 | endif 7 | 8 | # PROJECT_VERSION defaults to: 9 | # 1. the version exported by rabbitmq-server-release; 10 | # 2. the version stored in `git-revisions.txt`, if it exists; 11 | # 3. a version based on git-describe(1), if it is a Git clone; 12 | # 4. 0.0.0 13 | 14 | PROJECT_VERSION := $(RABBITMQ_VERSION) 15 | 16 | ifeq ($(PROJECT_VERSION),) 17 | PROJECT_VERSION := $(shell \ 18 | if test -f git-revisions.txt; then \ 19 | head -n1 git-revisions.txt | \ 20 | awk '{print $$$(words $(PROJECT_DESCRIPTION) version);}'; \ 21 | else \ 22 | (git describe --dirty --abbrev=7 --tags --always --first-parent \ 23 | 2>/dev/null || echo rabbitmq_v0_0_0) | \ 24 | sed -e 's/^rabbitmq_v//' -e 's/^v//' -e 's/_/./g' -e 's/-/+/' \ 25 | -e 's/-/./g'; \ 26 | fi) 27 | endif 28 | 29 | # -------------------------------------------------------------------- 30 | # RabbitMQ components. 31 | # -------------------------------------------------------------------- 32 | 33 | # For RabbitMQ repositories, we want to checkout branches which match 34 | # the parent project. For instance, if the parent project is on a 35 | # release tag, dependencies must be on the same release tag. If the 36 | # parent project is on a topic branch, dependencies must be on the same 37 | # topic branch or fallback to `stable` or `main` whichever was the 38 | # base of the topic branch. 39 | 40 | dep_amqp_client = git_rmq-subfolder rabbitmq-erlang-client $(current_rmq_ref) $(base_rmq_ref) main 41 | dep_amqp10_client = git_rmq-subfolder rabbitmq-amqp1.0-client $(current_rmq_ref) $(base_rmq_ref) main 42 | dep_amqp10_common = git_rmq-subfolder rabbitmq-amqp1.0-common $(current_rmq_ref) $(base_rmq_ref) main 43 | dep_rabbit = git_rmq-subfolder rabbitmq-server $(current_rmq_ref) $(base_rmq_ref) main 44 | dep_rabbit_common = git_rmq-subfolder rabbitmq-common $(current_rmq_ref) $(base_rmq_ref) main 45 | dep_rabbitmq_amqp1_0 = git_rmq-subfolder rabbitmq-amqp1.0 $(current_rmq_ref) $(base_rmq_ref) main 46 | dep_rabbitmq_auth_backend_amqp = git_rmq rabbitmq-auth-backend-amqp $(current_rmq_ref) $(base_rmq_ref) main 47 | dep_rabbitmq_auth_backend_cache = git_rmq-subfolder rabbitmq-auth-backend-cache $(current_rmq_ref) $(base_rmq_ref) main 48 | dep_rabbitmq_auth_backend_http = git_rmq-subfolder rabbitmq-auth-backend-http $(current_rmq_ref) $(base_rmq_ref) main 49 | dep_rabbitmq_auth_backend_ldap = git_rmq-subfolder rabbitmq-auth-backend-ldap $(current_rmq_ref) $(base_rmq_ref) main 50 | dep_rabbitmq_auth_backend_oauth2 = git_rmq-subfolder rabbitmq-auth-backend-oauth2 $(current_rmq_ref) $(base_rmq_ref) main 51 | dep_rabbitmq_auth_mechanism_ssl = git_rmq-subfolder rabbitmq-auth-mechanism-ssl $(current_rmq_ref) $(base_rmq_ref) main 52 | dep_rabbitmq_aws = git_rmq-subfolder rabbitmq-aws $(current_rmq_ref) $(base_rmq_ref) main 53 | dep_rabbitmq_boot_steps_visualiser = git_rmq rabbitmq-boot-steps-visualiser $(current_rmq_ref) $(base_rmq_ref) main 54 | dep_rabbitmq_cli = git_rmq-subfolder rabbitmq-cli $(current_rmq_ref) $(base_rmq_ref) main 55 | dep_rabbitmq_codegen = git_rmq-subfolder rabbitmq-codegen $(current_rmq_ref) $(base_rmq_ref) main 56 | dep_rabbitmq_consistent_hash_exchange = git_rmq-subfolder rabbitmq-consistent-hash-exchange $(current_rmq_ref) $(base_rmq_ref) main 57 | dep_rabbitmq_ct_client_helpers = git_rmq-subfolder rabbitmq-ct-client-helpers $(current_rmq_ref) $(base_rmq_ref) main 58 | dep_rabbitmq_ct_helpers = git_rmq-subfolder rabbitmq-ct-helpers $(current_rmq_ref) $(base_rmq_ref) main 59 | dep_rabbitmq_delayed_message_exchange = git_rmq rabbitmq-delayed-message-exchange $(current_rmq_ref) $(base_rmq_ref) main 60 | dep_rabbitmq_dotnet_client = git_rmq rabbitmq-dotnet-client $(current_rmq_ref) $(base_rmq_ref) main 61 | dep_rabbitmq_event_exchange = git_rmq-subfolder rabbitmq-event-exchange $(current_rmq_ref) $(base_rmq_ref) main 62 | dep_rabbitmq_federation = git_rmq-subfolder rabbitmq-federation $(current_rmq_ref) $(base_rmq_ref) main 63 | dep_rabbitmq_federation_management = git_rmq-subfolder rabbitmq-federation-management $(current_rmq_ref) $(base_rmq_ref) main 64 | dep_rabbitmq_java_client = git_rmq rabbitmq-java-client $(current_rmq_ref) $(base_rmq_ref) main 65 | dep_rabbitmq_jms_client = git_rmq rabbitmq-jms-client $(current_rmq_ref) $(base_rmq_ref) main 66 | dep_rabbitmq_jms_cts = git_rmq rabbitmq-jms-cts $(current_rmq_ref) $(base_rmq_ref) main 67 | dep_rabbitmq_jms_topic_exchange = git_rmq-subfolder rabbitmq-jms-topic-exchange $(current_rmq_ref) $(base_rmq_ref) main 68 | dep_rabbitmq_lvc_exchange = git_rmq rabbitmq-lvc-exchange $(current_rmq_ref) $(base_rmq_ref) main 69 | dep_rabbitmq_management = git_rmq-subfolder rabbitmq-management $(current_rmq_ref) $(base_rmq_ref) main 70 | dep_rabbitmq_management_agent = git_rmq-subfolder rabbitmq-management-agent $(current_rmq_ref) $(base_rmq_ref) main 71 | dep_rabbitmq_management_exchange = git_rmq rabbitmq-management-exchange $(current_rmq_ref) $(base_rmq_ref) main 72 | dep_rabbitmq_management_themes = git_rmq rabbitmq-management-themes $(current_rmq_ref) $(base_rmq_ref) main 73 | dep_rabbitmq_message_timestamp = git_rmq rabbitmq-message-timestamp $(current_rmq_ref) $(base_rmq_ref) main 74 | dep_rabbitmq_metronome = git_rmq rabbitmq-metronome $(current_rmq_ref) $(base_rmq_ref) main 75 | dep_rabbitmq_mqtt = git_rmq-subfolder rabbitmq-mqtt $(current_rmq_ref) $(base_rmq_ref) main 76 | dep_rabbitmq_objc_client = git_rmq rabbitmq-objc-client $(current_rmq_ref) $(base_rmq_ref) main 77 | dep_rabbitmq_peer_discovery_aws = git_rmq-subfolder rabbitmq-peer-discovery-aws $(current_rmq_ref) $(base_rmq_ref) main 78 | dep_rabbitmq_peer_discovery_common = git_rmq-subfolder rabbitmq-peer-discovery-common $(current_rmq_ref) $(base_rmq_ref) main 79 | dep_rabbitmq_peer_discovery_consul = git_rmq-subfolder rabbitmq-peer-discovery-consul $(current_rmq_ref) $(base_rmq_ref) main 80 | dep_rabbitmq_peer_discovery_etcd = git_rmq-subfolder rabbitmq-peer-discovery-etcd $(current_rmq_ref) $(base_rmq_ref) main 81 | dep_rabbitmq_peer_discovery_k8s = git_rmq-subfolder rabbitmq-peer-discovery-k8s $(current_rmq_ref) $(base_rmq_ref) main 82 | dep_rabbitmq_prometheus = git_rmq-subfolder rabbitmq-prometheus $(current_rmq_ref) $(base_rmq_ref) main 83 | dep_rabbitmq_random_exchange = git_rmq-subfolder rabbitmq-random-exchange $(current_rmq_ref) $(base_rmq_ref) main 84 | dep_rabbitmq_recent_history_exchange = git_rmq-subfolder rabbitmq-recent-history-exchange $(current_rmq_ref) $(base_rmq_ref) main 85 | dep_rabbitmq_routing_node_stamp = git_rmq rabbitmq-routing-node-stamp $(current_rmq_ref) $(base_rmq_ref) main 86 | dep_rabbitmq_rtopic_exchange = git_rmq rabbitmq-rtopic-exchange $(current_rmq_ref) $(base_rmq_ref) main 87 | dep_rabbitmq_sharding = git_rmq-subfolder rabbitmq-sharding $(current_rmq_ref) $(base_rmq_ref) main 88 | dep_rabbitmq_shovel = git_rmq-subfolder rabbitmq-shovel $(current_rmq_ref) $(base_rmq_ref) main 89 | dep_rabbitmq_shovel_management = git_rmq-subfolder rabbitmq-shovel-management $(current_rmq_ref) $(base_rmq_ref) main 90 | dep_rabbitmq_stomp = git_rmq-subfolder rabbitmq-stomp $(current_rmq_ref) $(base_rmq_ref) main 91 | dep_rabbitmq_stream = git_rmq-subfolder rabbitmq-stream $(current_rmq_ref) $(base_rmq_ref) main 92 | dep_rabbitmq_stream_common = git_rmq-subfolder rabbitmq-stream-common $(current_rmq_ref) $(base_rmq_ref) main 93 | dep_rabbitmq_stream_management = git_rmq-subfolder rabbitmq-stream-management $(current_rmq_ref) $(base_rmq_ref) main 94 | dep_rabbitmq_toke = git_rmq rabbitmq-toke $(current_rmq_ref) $(base_rmq_ref) main 95 | dep_rabbitmq_top = git_rmq-subfolder rabbitmq-top $(current_rmq_ref) $(base_rmq_ref) main 96 | dep_rabbitmq_tracing = git_rmq-subfolder rabbitmq-tracing $(current_rmq_ref) $(base_rmq_ref) main 97 | dep_rabbitmq_trust_store = git_rmq-subfolder rabbitmq-trust-store $(current_rmq_ref) $(base_rmq_ref) main 98 | dep_rabbitmq_test = git_rmq rabbitmq-test $(current_rmq_ref) $(base_rmq_ref) main 99 | dep_rabbitmq_web_dispatch = git_rmq-subfolder rabbitmq-web-dispatch $(current_rmq_ref) $(base_rmq_ref) main 100 | dep_rabbitmq_web_stomp = git_rmq-subfolder rabbitmq-web-stomp $(current_rmq_ref) $(base_rmq_ref) main 101 | dep_rabbitmq_web_stomp_examples = git_rmq-subfolder rabbitmq-web-stomp-examples $(current_rmq_ref) $(base_rmq_ref) main 102 | dep_rabbitmq_web_mqtt = git_rmq-subfolder rabbitmq-web-mqtt $(current_rmq_ref) $(base_rmq_ref) main 103 | dep_rabbitmq_web_mqtt_examples = git_rmq-subfolder rabbitmq-web-mqtt-examples $(current_rmq_ref) $(base_rmq_ref) main 104 | dep_rabbitmq_website = git_rmq rabbitmq-website $(current_rmq_ref) $(base_rmq_ref) live main 105 | dep_toke = git_rmq toke $(current_rmq_ref) $(base_rmq_ref) master 106 | 107 | # Third-party dependencies version pinning. 108 | # 109 | # We do that in this file, which is copied in all projects, to ensure 110 | # all projects use the same versions. It avoids conflicts and makes it 111 | # possible to work with rabbitmq-public-umbrella. 112 | 113 | dep_accept = hex 0.3.5 114 | dep_cowboy = hex 2.8.0 115 | dep_cowlib = hex 2.9.1 116 | dep_looking_glass = git https://github.com/rabbitmq/looking_glass.git master 117 | dep_prometheus = hex 4.10.0 118 | dep_ra = hex 2.4.6 119 | dep_ranch = hex 2.1.0 120 | dep_recon = hex 2.5.3 121 | dep_redbug = hex 2.0.7 122 | dep_thoas = hex 0.4.0 123 | dep_observer_cli = hex 1.7.3 124 | dep_stdout_formatter = hex 0.2.4 125 | dep_sysmon_handler = hex 1.3.0 126 | 127 | RABBITMQ_COMPONENTS = amqp_client \ 128 | amqp10_common \ 129 | amqp10_client \ 130 | rabbit \ 131 | rabbit_common \ 132 | rabbitmq_amqp1_0 \ 133 | rabbitmq_auth_backend_amqp \ 134 | rabbitmq_auth_backend_cache \ 135 | rabbitmq_auth_backend_http \ 136 | rabbitmq_auth_backend_ldap \ 137 | rabbitmq_auth_backend_oauth2 \ 138 | rabbitmq_auth_mechanism_ssl \ 139 | rabbitmq_aws \ 140 | rabbitmq_boot_steps_visualiser \ 141 | rabbitmq_cli \ 142 | rabbitmq_codegen \ 143 | rabbitmq_consistent_hash_exchange \ 144 | rabbitmq_ct_client_helpers \ 145 | rabbitmq_ct_helpers \ 146 | rabbitmq_delayed_message_exchange \ 147 | rabbitmq_dotnet_client \ 148 | rabbitmq_event_exchange \ 149 | rabbitmq_federation \ 150 | rabbitmq_federation_management \ 151 | rabbitmq_java_client \ 152 | rabbitmq_jms_client \ 153 | rabbitmq_jms_cts \ 154 | rabbitmq_jms_topic_exchange \ 155 | rabbitmq_lvc_exchange \ 156 | rabbitmq_management \ 157 | rabbitmq_management_agent \ 158 | rabbitmq_management_exchange \ 159 | rabbitmq_management_themes \ 160 | rabbitmq_message_timestamp \ 161 | rabbitmq_metronome \ 162 | rabbitmq_mqtt \ 163 | rabbitmq_objc_client \ 164 | rabbitmq_peer_discovery_aws \ 165 | rabbitmq_peer_discovery_common \ 166 | rabbitmq_peer_discovery_consul \ 167 | rabbitmq_peer_discovery_etcd \ 168 | rabbitmq_peer_discovery_k8s \ 169 | rabbitmq_prometheus \ 170 | rabbitmq_random_exchange \ 171 | rabbitmq_recent_history_exchange \ 172 | rabbitmq_routing_node_stamp \ 173 | rabbitmq_rtopic_exchange \ 174 | rabbitmq_server_release \ 175 | rabbitmq_sharding \ 176 | rabbitmq_shovel \ 177 | rabbitmq_shovel_management \ 178 | rabbitmq_stomp \ 179 | rabbitmq_stream \ 180 | rabbitmq_stream_common \ 181 | rabbitmq_stream_management \ 182 | rabbitmq_toke \ 183 | rabbitmq_top \ 184 | rabbitmq_tracing \ 185 | rabbitmq_trust_store \ 186 | rabbitmq_web_dispatch \ 187 | rabbitmq_web_mqtt \ 188 | rabbitmq_web_mqtt_examples \ 189 | rabbitmq_web_stomp \ 190 | rabbitmq_web_stomp_examples \ 191 | rabbitmq_website 192 | 193 | # Erlang.mk does not rebuild dependencies by default, once they were 194 | # compiled once, except for those listed in the `$(FORCE_REBUILD)` 195 | # variable. 196 | # 197 | # We want all RabbitMQ components to always be rebuilt: this eases 198 | # the work on several components at the same time. 199 | 200 | FORCE_REBUILD = $(RABBITMQ_COMPONENTS) 201 | 202 | # Several components have a custom erlang.mk/build.config, mainly 203 | # to disable eunit. Therefore, we can't use the top-level project's 204 | # erlang.mk copy. 205 | NO_AUTOPATCH += $(RABBITMQ_COMPONENTS) 206 | 207 | ifeq ($(origin current_rmq_ref),undefined) 208 | ifneq ($(wildcard .git),) 209 | current_rmq_ref := $(shell (\ 210 | ref=$$(LANG=C git branch --list | awk '/^\* \(.*detached / {ref=$$0; sub(/.*detached [^ ]+ /, "", ref); sub(/\)$$/, "", ref); print ref; exit;} /^\* / {ref=$$0; sub(/^\* /, "", ref); print ref; exit}');\ 211 | if test "$$(git rev-parse --short HEAD)" != "$$ref"; then echo "$$ref"; fi)) 212 | else 213 | current_rmq_ref := main 214 | endif 215 | endif 216 | export current_rmq_ref 217 | 218 | ifeq ($(origin base_rmq_ref),undefined) 219 | ifneq ($(wildcard .git),) 220 | possible_base_rmq_ref := main 221 | ifeq ($(possible_base_rmq_ref),$(current_rmq_ref)) 222 | base_rmq_ref := $(current_rmq_ref) 223 | else 224 | base_rmq_ref := $(shell \ 225 | (git rev-parse --verify -q main >/dev/null && \ 226 | git rev-parse --verify -q $(possible_base_rmq_ref) >/dev/null && \ 227 | git merge-base --is-ancestor $$(git merge-base main HEAD) $(possible_base_rmq_ref) && \ 228 | echo $(possible_base_rmq_ref)) || \ 229 | echo main) 230 | endif 231 | else 232 | base_rmq_ref := main 233 | endif 234 | endif 235 | export base_rmq_ref 236 | 237 | # Repository URL selection. 238 | # 239 | # First, we infer other components' location from the current project 240 | # repository URL, if it's a Git repository: 241 | # - We take the "origin" remote URL as the base 242 | # - The current project name and repository name is replaced by the 243 | # target's properties: 244 | # eg. rabbitmq-common is replaced by rabbitmq-codegen 245 | # eg. rabbit_common is replaced by rabbitmq_codegen 246 | # 247 | # If cloning from this computed location fails, we fallback to RabbitMQ 248 | # upstream which is GitHub. 249 | 250 | # Macro to transform eg. "rabbit_common" to "rabbitmq-common". 251 | rmq_cmp_repo_name = $(word 2,$(dep_$(1))) 252 | 253 | # Upstream URL for the current project. 254 | RABBITMQ_COMPONENT_REPO_NAME := $(call rmq_cmp_repo_name,$(PROJECT)) 255 | RABBITMQ_UPSTREAM_FETCH_URL ?= https://github.com/rabbitmq/$(RABBITMQ_COMPONENT_REPO_NAME).git 256 | RABBITMQ_UPSTREAM_PUSH_URL ?= git@github.com:rabbitmq/$(RABBITMQ_COMPONENT_REPO_NAME).git 257 | 258 | # Current URL for the current project. If this is not a Git clone, 259 | # default to the upstream Git repository. 260 | ifneq ($(wildcard .git),) 261 | git_origin_fetch_url := $(shell git config remote.origin.url) 262 | git_origin_push_url := $(shell git config remote.origin.pushurl || git config remote.origin.url) 263 | RABBITMQ_CURRENT_FETCH_URL ?= $(git_origin_fetch_url) 264 | RABBITMQ_CURRENT_PUSH_URL ?= $(git_origin_push_url) 265 | else 266 | RABBITMQ_CURRENT_FETCH_URL ?= $(RABBITMQ_UPSTREAM_FETCH_URL) 267 | RABBITMQ_CURRENT_PUSH_URL ?= $(RABBITMQ_UPSTREAM_PUSH_URL) 268 | endif 269 | 270 | # Macro to replace the following pattern: 271 | # 1. /foo.git -> /bar.git 272 | # 2. /foo -> /bar 273 | # 3. /foo/ -> /bar/ 274 | subst_repo_name = $(patsubst %/$(1)/%,%/$(2)/%,$(patsubst %/$(1),%/$(2),$(patsubst %/$(1).git,%/$(2).git,$(3)))) 275 | 276 | # Macro to replace both the project's name (eg. "rabbit_common") and 277 | # repository name (eg. "rabbitmq-common") by the target's equivalent. 278 | # 279 | # This macro is kept on one line because we don't want whitespaces in 280 | # the returned value, as it's used in $(dep_fetch_git_rmq) in a shell 281 | # single-quoted string. 282 | dep_rmq_repo = $(if $(dep_$(2)),$(call subst_repo_name,$(PROJECT),$(2),$(call subst_repo_name,$(RABBITMQ_COMPONENT_REPO_NAME),$(call rmq_cmp_repo_name,$(2)),$(1))),$(pkg_$(1)_repo)) 283 | 284 | dep_rmq_commits = $(if $(dep_$(1)), \ 285 | $(wordlist 3,$(words $(dep_$(1))),$(dep_$(1))), \ 286 | $(pkg_$(1)_commit)) 287 | 288 | define dep_fetch_git_rmq 289 | fetch_url1='$(call dep_rmq_repo,$(RABBITMQ_CURRENT_FETCH_URL),$(1))'; \ 290 | fetch_url2='$(call dep_rmq_repo,$(RABBITMQ_UPSTREAM_FETCH_URL),$(1))'; \ 291 | if test "$$$$fetch_url1" != '$(RABBITMQ_CURRENT_FETCH_URL)' && \ 292 | git clone -q -n -- "$$$$fetch_url1" $(DEPS_DIR)/$(call dep_name,$(1)); then \ 293 | fetch_url="$$$$fetch_url1"; \ 294 | push_url='$(call dep_rmq_repo,$(RABBITMQ_CURRENT_PUSH_URL),$(1))'; \ 295 | elif git clone -q -n -- "$$$$fetch_url2" $(DEPS_DIR)/$(call dep_name,$(1)); then \ 296 | fetch_url="$$$$fetch_url2"; \ 297 | push_url='$(call dep_rmq_repo,$(RABBITMQ_UPSTREAM_PUSH_URL),$(1))'; \ 298 | fi; \ 299 | cd $(DEPS_DIR)/$(call dep_name,$(1)) && ( \ 300 | $(foreach ref,$(call dep_rmq_commits,$(1)), \ 301 | git checkout -q $(ref) >/dev/null 2>&1 || \ 302 | ) \ 303 | (echo "error: no valid pathspec among: $(call dep_rmq_commits,$(1))" \ 304 | 1>&2 && false) ) && \ 305 | (test "$$$$fetch_url" = "$$$$push_url" || \ 306 | git remote set-url --push origin "$$$$push_url") 307 | endef 308 | 309 | define dep_fetch_git_rmq-subfolder 310 | fetch_url1='https://github.com/rabbitmq/rabbitmq-server.git'; \ 311 | fetch_url2='git@github.com:rabbitmq/rabbitmq-server.git'; \ 312 | if [ ! -d $(ERLANG_MK_TMP)/rabbitmq-server ]; then \ 313 | if test "$$$$fetch_url1" != '$(RABBITMQ_CURRENT_FETCH_URL)' && \ 314 | git clone -q -n -- "$$$$fetch_url1" $(ERLANG_MK_TMP)/rabbitmq-server; then \ 315 | fetch_url="$$$$fetch_url1"; \ 316 | push_url='$(call dep_rmq_repo,$(RABBITMQ_CURRENT_PUSH_URL),rabbitmq-server)'; \ 317 | elif git clone -q -n -- "$$$$fetch_url2" $(ERLANG_MK_TMP)/rabbitmq-server; then \ 318 | fetch_url="$$$$fetch_url2"; \ 319 | push_url='$(call dep_rmq_repo,$(RABBITMQ_UPSTREAM_PUSH_URL),rabbitmq-server)'; \ 320 | fi; \ 321 | fi; \ 322 | cd $(ERLANG_MK_TMP)/rabbitmq-server && ( \ 323 | $(foreach ref,$(call dep_rmq_commits,$(1)), \ 324 | git checkout -q $(ref) >/dev/null 2>&1 || \ 325 | ) \ 326 | (echo "error: no valid pathspec among: $(call dep_rmq_commits,$(1))" \ 327 | 1>&2 && false) ) && \ 328 | (test "$$$$fetch_url" = "$$$$push_url" || \ 329 | git remote set-url --push origin "$$$$push_url") 330 | ln -s $(ERLANG_MK_TMP)/rabbitmq-server/deps/$(call dep_name,$(1)) \ 331 | $(DEPS_DIR)/$(call dep_name,$(1)); 332 | endef 333 | 334 | # -------------------------------------------------------------------- 335 | # Component distribution. 336 | # -------------------------------------------------------------------- 337 | 338 | list-dist-deps:: 339 | @: 340 | 341 | prepare-dist:: 342 | @: 343 | 344 | # -------------------------------------------------------------------- 345 | # Umbrella-specific settings. 346 | # -------------------------------------------------------------------- 347 | 348 | # If the top-level project is a RabbitMQ component, we override 349 | # $(DEPS_DIR) for this project to point to the top-level's one. 350 | # 351 | # We also verify that the guessed DEPS_DIR is actually named `deps`, 352 | # to rule out any situation where it is a coincidence that we found a 353 | # `rabbitmq-components.mk` up upper directories. 354 | 355 | possible_deps_dir_1 = $(abspath ..) 356 | possible_deps_dir_2 = $(abspath ../../..) 357 | 358 | ifeq ($(notdir $(possible_deps_dir_1)),deps) 359 | ifneq ($(wildcard $(possible_deps_dir_1)/../rabbitmq-components.mk),) 360 | deps_dir_overriden = 1 361 | DEPS_DIR ?= $(possible_deps_dir_1) 362 | DISABLE_DISTCLEAN = 1 363 | endif 364 | endif 365 | 366 | ifeq ($(deps_dir_overriden),) 367 | ifeq ($(notdir $(possible_deps_dir_2)),deps) 368 | ifneq ($(wildcard $(possible_deps_dir_2)/../rabbitmq-components.mk),) 369 | deps_dir_overriden = 1 370 | DEPS_DIR ?= $(possible_deps_dir_2) 371 | DISABLE_DISTCLEAN = 1 372 | endif 373 | endif 374 | endif 375 | 376 | ifneq ($(wildcard UMBRELLA.md),) 377 | DISABLE_DISTCLEAN = 1 378 | endif 379 | 380 | # We disable `make distclean` so $(DEPS_DIR) is not accidentally removed. 381 | 382 | ifeq ($(DISABLE_DISTCLEAN),1) 383 | ifneq ($(filter distclean distclean-deps,$(MAKECMDGOALS)),) 384 | SKIP_DEPS = 1 385 | endif 386 | endif 387 | --------------------------------------------------------------------------------