diff options
author | dcorbacho <dparracorbacho@piotal.io> | 2020-11-18 14:27:41 +0000 |
---|---|---|
committer | dcorbacho <dparracorbacho@piotal.io> | 2020-11-18 14:27:41 +0000 |
commit | f23a51261d9502ec39df0f8db47ba6b22aa7659f (patch) | |
tree | 53dcdf46e7dc2c14e81ee960bce8793879b488d3 /deps/rabbitmq_auth_backend_http/examples | |
parent | afa2c2bf6c7e0e9b63f4fb53dc931c70388e1c82 (diff) | |
parent | 9f6d64ec4a4b1eeac24d7846c5c64fd96798d892 (diff) | |
download | rabbitmq-server-git-stream-timestamp-offset.tar.gz |
Merge remote-tracking branch 'origin/master' into stream-timestamp-offsetstream-timestamp-offset
Diffstat (limited to 'deps/rabbitmq_auth_backend_http/examples')
85 files changed, 3908 insertions, 0 deletions
diff --git a/deps/rabbitmq_auth_backend_http/examples/README.md b/deps/rabbitmq_auth_backend_http/examples/README.md new file mode 100644 index 0000000000..ecdf115f84 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/README.md @@ -0,0 +1,235 @@ +# RabbitMQ HTTP Authn/Authz Backend Examples + +## Overview + +This directory provides a number of community contributed example applications that target +different platforms and frameworks: + + * Python and Django + * Java and Spring Boot + * Kotlin and Spring Boot + * C# and ASP.NET Web API + * C# and ASP.NET Core 2.1 + * PHP + +## Python Example + +`rabbitmq_auth_backend_django` is a very minimalistic [Django](https://www.djangoproject.com/) application +that rabbitmq-auth-backend-http can authenticate against. It's really +not designed to be anything other than an example. + +### Running the Example + +Run + +``` shell +start.sh +``` + +to launch it after [installing Django](https://docs.djangoproject.com/en/2.1/intro/install/). +You may need to hack `start.sh` if you are not running Debian or Ubuntu. + +The app will use a local SQLite database. It uses the standard +Django authentication database. All users get access to all vhosts and +resources. + +The app recognises two users (to make the setup easier): `admin` and `someuser`. +Passwords for those users do not matter. user `admin` as tagged as `administrator`. + +### HTTP Endpoint Examples + +`urls.py` and `auth/views.py` are the main modules that describe HTTP routes and +views (endpoints). + + +## Spring Boot Example + +`rabbitmq_auth_backend_spring_boot` is a simple [Spring Boot](https://projects.spring.io/spring-boot/) +application that rabbitmq-auth-backend-http can authenticate against. It's really +not designed to be anything other than an example. + +### Running the Example + +Import the example as a Maven project in your favorite IDE or run it directly from the command line: + +``` shell +mvn spring-boot:run +``` + +The application listens on the 8080 port. + +### HTTP Endpoint Examples + +Have a look at the `AuthBackendHttpController`. There's only one user: `guest`, +with the `guest` password. This implementation also checks the +routing key starts with an `a` when publishing to a topic exchange +or consuming from a topic. (an example of [topic authorisation](http://next.rabbitmq.com/access-control.html#topic-authorisation)). + +### rabbitmq.config Example + +Below is a [RabbitMQ config file](http://www.rabbitmq.com/configure.html) example to go with this +example: + +``` ini +auth_backends.1 = http + +auth_http.http_method = post +auth_http.user_path = http://localhost:8080/auth/user +auth_http.vhost_path = http://localhost:8080/auth/vhost +auth_http.resource_path = http://localhost:8080/auth/resource +auth_http.topic_path = http://localhost:8080/auth/topic +``` + +## Spring Boot Kotlin Example + +`rabbitmq_auth_backend_spring_boot_kotlin` is a simple [Spring Boot](https://projects.spring.io/spring-boot/) +application written in Kotlin that rabbitmq-auth-backend-http can authenticate against. It's really +not designed to be anything other than an example. +It contains examples with recommended POST methods and example RabbitMQ configuration. +It can be run the same way as the above example. + + +## ASP.NET Web API Example + +`rabbitmq_auth_backend_webapi_dotnet` is a very minimalistic ASP.NET Web API application +the plugin can authenticate against. It's really +**not designed to be anything other than an example**. + +### Running the Example + +Open the WebApiHttpAuthService.csproj in Visual Studio 2017, More details about prerequisites can be found below. + +As with other examples, RabbitMQ [authentication and authorization backends](http://www.rabbitmq.com/access-control.html) must be configured +to use this plugin and the endpoints provided by this example app. + +Then Build the solution and run it from Visual Studio. +`Controllers/AuthController.cs` contains the authentication and authorization logic. +By default All users get access to all vhosts and resources. +User "authuser" will be denied access. + +### HTTP Endpoint Examples + +Have a look at `AuthController`. + +### Development Environment + +This example was developed using + + * .NET Framework 4.5 + * Visual Studio 2017 + * Windows 10 and IIS v10.0 + +It is possible to build and run service from Visual Studio browse the endpoint without using IIS. +Port number may vary but will likely be `62190`. + +When the example is hosted on IIS, port 80 will be used by default. + +## ASP.NET Core 2.1 Example + +`rabbitmq_auth_backend_webapi_dotnetcore` is a modification of the `rabbitmq_auth_backend_webapi_dotnet` example +designed for ASP.NET Core 2.1. It's very similar to the original version but it also adds some static typing +for requests and responses. + +### Running the Example + +Open the solution file, WebApiHttpAuthService.sln` in Visual Studio 2017 or later. + +As with other examples, RabbitMQ [authentication and authorization backends](http://www.rabbitmq.com/access-control.html) must be configured +to use this plugin and the endpoints provided by this example app. + +Then build the solution and run it from Visual Studio. +`Controllers/AuthController.cs` contains the authentication and authorization logic. +By default All users get access to all vhosts and resources. +User "authuser" will be denied access. + +### HTTP Endpoint Examples + +Have a look at `AuthController`. + +### Development Environment + +This example was developed using + + * ASP.NET Core 2.1 + * Visual Studio 2017 (Visual Studio Code) + * Windows 10 + +It is possible to build and run service from Visual Studio using IIS or from Visual Studio or Visual Studio Code using cross-platform server Kestrel. + + +## PHP Example + +`rabbitmq_auth_backend_php` is a minimalistic PHP application that this plugin can authenticate against. +It's really not designed to be anything other than an example. + +### Running the Example + +The example requires PHP >= 5.4 and [Composer](https://getcomposer.org/). + +The `rabbitmq-auth-backend-http-php` library depend on `symfony/security` and `symfony/http-foundation` components. +Go to the `rabbitmq_auth_backend_php` folder and run `composer install`. + +``` shell +cd rabbitmq_auth_backend_php/ +composer install +``` + +Now you can run the PHP 5.4 server (server at http://127.0.0.1:8080) + +``` shell +composer start +``` + +Ensure the log file is writable `rabbitmq-auth-backend-http/examples/rabbitmq_auth_backend_php/var/log.log`. + +Go to `http://localhost:8080/user.php?username=Anthony&password=anthony-password`, all work properly if you see `Allow administrator` + + +### HTTP Endpoint Examples + +Have a look at the `bootstrap.php`. By default this example implement the same authorization rules than RabbitMQ. + +Users list: + +| User | password | is admin | Vhost | Configure regex | Write regex | Read regex | tags | +|--|--|--|--|--|--|--|--| +| Anthony | anthony-password | ✔️ | All | All | All | All | administrator | +| James | bond | | / | .* | .* | .* | management | +| Roger | rabbit | | | | | | monitoring | +| bunny | bugs | | | | | | policymaker | + +### rabbitmq.config Example + +Below is a [RabbitMQ config file](http://www.rabbitmq.com/configure.html) example to go with this +example: + +``` ini +auth_backends.1 = internal +auth_backends.2 = http + +auth_http.user_path = http://localhost:62190/auth/user.php +auth_http.vhost_path = http://localhost:62190/auth/vhost.php +auth_http.resource_path = http://localhost:62190/auth/resource.php +auth_http.topic_path = http://localhost:62190/auth/topic.php +``` + +See [RabbitMQ Access Control guide](http://www.rabbitmq.com/access-control.html) for more information. + +## Running with Docker Compose + +An example node can be started using a provided `docker-compose.yml` file that sets up RabbitMQ. +There's also a file that sets up the Django example above: + +```bash +docker-compose -f docker-compose.yml -f rabbitmq_auth_backend_django/docker-compose.yml up --build +``` + +Another file, `docker/nodered/docker-compose.yml`, will run [nodered](https://nodered.org/) on port 1880 +with a configured MQTT client that will connect to RabbitMQ and perform basic operations that will trigger +requests to the example service: + +```bash +docker-compose -f docker-compose.yml -f rabbitmq_auth_backend_django/docker-compose.yml -f docker/nodered/docker-compose.yml up --build +``` + +Edit the provided [config file](docker/rabbitmq.conf) and enable caching and logging settings. diff --git a/deps/rabbitmq_auth_backend_http/examples/docker-compose.yml b/deps/rabbitmq_auth_backend_http/examples/docker-compose.yml new file mode 100644 index 0000000000..15109296c3 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + rabbit: + image: rabbitmq:management + volumes: + - ./docker/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf + - ./docker/enabled_plugins:/etc/rabbitmq/enabled_plugins + ports: + - 15672:15672 + - 1883:1883 + diff --git a/deps/rabbitmq_auth_backend_http/examples/docker/enabled_plugins b/deps/rabbitmq_auth_backend_http/examples/docker/enabled_plugins new file mode 100644 index 0000000000..2016106225 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/docker/enabled_plugins @@ -0,0 +1 @@ +[rabbitmq_management,rabbitmq_auth_backend_cache,rabbitmq_auth_backend_http,rabbitmq_mqtt]. diff --git a/deps/rabbitmq_auth_backend_http/examples/docker/nodered/Dockerfile b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/Dockerfile new file mode 100644 index 0000000000..0e0c6f15d6 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/Dockerfile @@ -0,0 +1,5 @@ +FROM nodered/node-red-docker + +COPY flows.json /data/ +COPY flows_cred.json /data/ +COPY settings.js /data/ diff --git a/deps/rabbitmq_auth_backend_http/examples/docker/nodered/docker-compose.yml b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/docker-compose.yml new file mode 100644 index 0000000000..82680ffa41 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3" + +services: + nodered: + build: ./docker/nodered/ + ports: + - 1880:1880 + diff --git a/deps/rabbitmq_auth_backend_http/examples/docker/nodered/flows.json b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/flows.json new file mode 100644 index 0000000000..f8fd2a9146 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/flows.json @@ -0,0 +1 @@ +[{"id":"782c13cf.81627c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"ebd3e611.cdef38","type":"mqtt-broker","z":"","name":"as admin","broker":"rabbit","port":"1883","clientid":"adminclienid","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"90e1a809.a7ff5","type":"mqtt-broker","z":"","name":"someuser","broker":"rabbit","port":"1883","clientid":"someuserclientid","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"dac58353.662ad","type":"mqtt in","z":"782c13cf.81627c","name":"","topic":"some/topic/as/admin","qos":"2","broker":"ebd3e611.cdef38","x":160,"y":100,"wires":[["efe47f32.30786"]]},{"id":"f63b9dd3.36cde","type":"comment","z":"782c13cf.81627c","name":"admin","info":"","x":110,"y":60,"wires":[]},{"id":"e948a0d9.babb18","type":"mqtt out","z":"782c13cf.81627c","name":"","topic":"some/topic/as/admin","qos":"","retain":"","broker":"ebd3e611.cdef38","x":360,"y":160,"wires":[]},{"id":"cf18517f.444ef8","type":"inject","z":"782c13cf.81627c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":160,"wires":[["e948a0d9.babb18"]]},{"id":"efe47f32.30786","type":"debug","z":"782c13cf.81627c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":100,"wires":[]},{"id":"c7046417.f9b368","type":"mqtt in","z":"782c13cf.81627c","name":"","topic":"some/topic/as/someuser","qos":"2","broker":"90e1a809.a7ff5","x":170,"y":280,"wires":[["be230f6b.e78ec"]]},{"id":"be230f6b.e78ec","type":"debug","z":"782c13cf.81627c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":420,"y":280,"wires":[]},{"id":"f3153151.f2bee8","type":"comment","z":"782c13cf.81627c","name":"someuser","info":"","x":120,"y":240,"wires":[]}]
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/docker/nodered/flows_cred.json b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/flows_cred.json new file mode 100644 index 0000000000..bfcee00920 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/flows_cred.json @@ -0,0 +1 @@ +{"$":"00ae52fd43067c0f54608e6e26ba669f6VIl433Q1ap8mC1z8Gq4TymUQc4xgTTEKUHO5khripHCamXAJXfsezBEsKCPmAhv/1Q8GYVFbDdFH5EcYUs6u5MV4+LJ/jL01toZr6utgIoKYQmjpKoh4fHhScYrezMpKoNglVsV+HSOd91GLBGvyzldmh2JJrAMyZEPdCkDg+fobQ=="}
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/docker/nodered/settings.js b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/settings.js new file mode 100644 index 0000000000..5188aba0c9 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/docker/nodered/settings.js @@ -0,0 +1,260 @@ +/** + * Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +// The `https` setting requires the `fs` module. Uncomment the following +// to make it available: +//var fs = require("fs"); + +module.exports = { + // the tcp port that the Node-RED web server is listening on + uiPort: process.env.PORT || 1880, + + // By default, the Node-RED UI accepts connections on all IPv4 interfaces. + // To listen on all IPv6 addresses, set uiHost to "::", + // The following property can be used to listen on a specific interface. For + // example, the following would only allow connections from the local machine. + //uiHost: "127.0.0.1", + + // Retry time in milliseconds for MQTT connections + mqttReconnectTime: 15000, + + // Retry time in milliseconds for Serial port connections + serialReconnectTime: 15000, + + // Retry time in milliseconds for TCP socket connections + //socketReconnectTime: 10000, + + // Timeout in milliseconds for TCP server socket connections + // defaults to no timeout + //socketTimeout: 120000, + + // Maximum number of messages to wait in queue while attempting to connect to TCP socket + // defaults to 1000 + //tcpMsgQueueSize: 2000, + + // Timeout in milliseconds for HTTP request connections + // defaults to 120 seconds + //httpRequestTimeout: 120000, + + // The maximum length, in characters, of any message sent to the debug sidebar tab + debugMaxLength: 1000, + + // The maximum number of messages nodes will buffer internally as part of their + // operation. This applies across a range of nodes that operate on message sequences. + // defaults to no limit. A value of 0 also means no limit is applied. + //nodeMaxMessageBufferLength: 0, + + // To disable the option for using local files for storing keys and certificates in the TLS configuration + // node, set this to true + //tlsConfigDisableLocalFiles: true, + + // Colourise the console output of the debug node + //debugUseColors: true, + + // The file containing the flows. If not set, it defaults to flows_<hostname>.json + //flowFile: 'flows.json', + + // To enabled pretty-printing of the flow within the flow file, set the following + // property to true: + //flowFilePretty: true, + + // By default, credentials are encrypted in storage using a generated key. To + // specify your own secret, set the following property. + // If you want to disable encryption of credentials, set this property to false. + // Note: once you set this property, do not change it - doing so will prevent + // node-red from being able to decrypt your existing credentials and they will be + // lost. + credentialSecret: "a-secret-key", + + // By default, all user data is stored in the Node-RED install directory. To + // use a different location, the following property can be used + //userDir: '/home/nol/.node-red/', + + // Node-RED scans the `nodes` directory in the install directory to find nodes. + // The following property can be used to specify an additional directory to scan. + //nodesDir: '/home/nol/.node-red/nodes', + + // By default, the Node-RED UI is available at http://localhost:1880/ + // The following property can be used to specify a different root path. + // If set to false, this is disabled. + //httpAdminRoot: '/admin', + + // Some nodes, such as HTTP In, can be used to listen for incoming http requests. + // By default, these are served relative to '/'. The following property + // can be used to specifiy a different root path. If set to false, this is + // disabled. + //httpNodeRoot: '/red-nodes', + + // The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot', + // to apply the same root to both parts. + //httpRoot: '/red', + + // When httpAdminRoot is used to move the UI to a different root path, the + // following property can be used to identify a directory of static content + // that should be served at http://localhost:1880/. + //httpStatic: '/home/nol/node-red-static/', + + // The maximum size of HTTP request that will be accepted by the runtime api. + // Default: 5mb + //apiMaxLength: '5mb', + + // If you installed the optional node-red-dashboard you can set it's path + // relative to httpRoot + //ui: { path: "ui" }, + + // Securing Node-RED + // ----------------- + // To password protect the Node-RED editor and admin API, the following + // property can be used. See http://nodered.org/docs/security.html for details. + //adminAuth: { + // type: "credentials", + // users: [{ + // username: "admin", + // password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.", + // permissions: "*" + // }] + //}, + + // To password protect the node-defined HTTP endpoints (httpNodeRoot), or + // the static content (httpStatic), the following properties can be used. + // The pass field is a bcrypt hash of the password. + // See http://nodered.org/docs/security.html#generating-the-password-hash + //httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, + //httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, + + // The following property can be used to enable HTTPS + // See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener + // for details on its contents. + // See the comment at the top of this file on how to load the `fs` module used by + // this setting. + // + //https: { + // key: fs.readFileSync('privatekey.pem'), + // cert: fs.readFileSync('certificate.pem') + //}, + + // The following property can be used to cause insecure HTTP connections to + // be redirected to HTTPS. + //requireHttps: true, + + // The following property can be used to disable the editor. The admin API + // is not affected by this option. To disable both the editor and the admin + // API, use either the httpRoot or httpAdminRoot properties + //disableEditor: false, + + // The following property can be used to configure cross-origin resource sharing + // in the HTTP nodes. + // See https://github.com/troygoode/node-cors#configuration-options for + // details on its contents. The following is a basic permissive set of options: + //httpNodeCors: { + // origin: "*", + // methods: "GET,PUT,POST,DELETE" + //}, + + // If you need to set an http proxy please set an environment variable + // called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system. + // For example - http_proxy=http://myproxy.com:8080 + // (Setting it here will have no effect) + // You may also specify no_proxy (or NO_PROXY) to supply a comma separated + // list of domains to not proxy, eg - no_proxy=.acme.co,.acme.co.uk + + // The following property can be used to add a custom middleware function + // in front of all http in nodes. This allows custom authentication to be + // applied to all http in nodes, or any other sort of common request processing. + //httpNodeMiddleware: function(req,res,next) { + // // Handle/reject the request, or pass it on to the http in node by calling next(); + // // Optionally skip our rawBodyParser by setting this to true; + // //req.skipRawBodyParser = true; + // next(); + //}, + + // The following property can be used to verify websocket connection attempts. + // This allows, for example, the HTTP request headers to be checked to ensure + // they include valid authentication information. + //webSocketNodeVerifyClient: function(info) { + // // 'info' has three properties: + // // - origin : the value in the Origin header + // // - req : the HTTP request + // // - secure : true if req.connection.authorized or req.connection.encrypted is set + // // + // // The function should return true if the connection should be accepted, false otherwise. + // // + // // Alternatively, if this function is defined to accept a second argument, callback, + // // it can be used to verify the client asynchronously. + // // The callback takes three arguments: + // // - result : boolean, whether to accept the connection or not + // // - code : if result is false, the HTTP error status to return + // // - reason: if result is false, the HTTP reason string to return + //}, + + // Anything in this hash is globally available to all functions. + // It is accessed as context.global. + // eg: + // functionGlobalContext: { os:require('os') } + // can be accessed in a function block as: + // context.global.os + + functionGlobalContext: { + // os:require('os'), + // jfive:require("johnny-five"), + // j5board:require("johnny-five").Board({repl:false}) + }, + + // Context Storage + // The following property can be used to enable context storage. The configuration + // provided here will enable file-based context that flushes to disk every 30 seconds. + // Refer to the documentation for further options: https://nodered.org/docs/api/context/ + // + //contextStorage: { + // default: { + // module:"localfilesystem" + // }, + //}, + + // The following property can be used to order the categories in the editor + // palette. If a node's category is not in the list, the category will get + // added to the end of the palette. + // If not set, the following default order is used: + //paletteCategories: ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'], + + // Configure the logging output + logging: { + // Only console logging is currently supported + console: { + // Level of logging to be recorded. Options are: + // fatal - only those errors which make the application unusable should be recorded + // error - record errors which are deemed fatal for a particular request + fatal errors + // warn - record problems which are non fatal + errors + fatal errors + // info - record information about the general running of the application + warn + error + fatal errors + // debug - record information which is more verbose than info + info + warn + error + fatal errors + // trace - record very detailed logging + debug + info + warn + error + fatal errors + // off - turn off all logging (doesn't affect metrics or audit) + level: "info", + // Whether or not to include metric events in the log output + metrics: false, + // Whether or not to include audit events in the log output + audit: false + } + }, + + // Customising the editor + editorTheme: { + projects: { + // To enable the Projects feature, set this value to true + enabled: false + } + }, +} diff --git a/deps/rabbitmq_auth_backend_http/examples/docker/rabbitmq.conf b/deps/rabbitmq_auth_backend_http/examples/docker/rabbitmq.conf new file mode 100644 index 0000000000..12effb76ac --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/docker/rabbitmq.conf @@ -0,0 +1,22 @@ +loopback_users.guest = false +listeners.tcp.default = 5672 +management.listener.port = 15672 +management.listener.ssl = false + +auth_backends.1 = http + +## This configures rabbitmq_auth_backend_cache that delegates to +## the HTTP backend. If using this, make sure to comment the +## auth_backends.1 line above. +## +# auth_backends.1 = cache +# +# auth_cache.cached_backend = http +# auth_cache.cache_ttl = 5000 + + +auth_http.http_method = get +auth_http.user_path = http://auth-backend:8000/auth/user +auth_http.vhost_path = http://auth-backend:8000/auth/vhost +auth_http.resource_path = http://auth-backend:8000/auth/resource +auth_http.topic_path = http://auth-backend:8000/auth/topic diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/.gitignore b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/.gitignore new file mode 100644 index 0000000000..6e9bc0cd9f --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/.gitignore @@ -0,0 +1 @@ +*.sqlite3
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/Dockerfile b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/Dockerfile new file mode 100644 index 0000000000..26ba7f9283 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.7-alpine + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +WORKDIR /usr/src/app + +RUN pip install django + + +COPY . /usr/src/app + +EXPOSE 8000 + +ENTRYPOINT ["/usr/src/app/start.sh"] diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/docker-compose.yml b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/docker-compose.yml new file mode 100644 index 0000000000..dba3012840 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/docker-compose.yml @@ -0,0 +1,6 @@ +version: "3" + +services: + auth-backend: + build: ./rabbitmq_auth_backend_django + diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/manage.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/manage.py new file mode 100755 index 0000000000..1ae2e80b4b --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rabbitmq_auth_backend_django.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/__init__.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/__init__.py diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/__init__.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/__init__.py diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/models.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/models.py new file mode 100644 index 0000000000..71a8362390 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/tests.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/tests.py new file mode 100644 index 0000000000..2247054b35 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/views.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/views.py new file mode 100644 index 0000000000..066623b962 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/auth/views.py @@ -0,0 +1,41 @@ +from django.http import HttpResponse +from django.contrib.auth import authenticate +from django.views.decorators.csrf import csrf_exempt +import logging + +logger = logging.getLogger('auth_backend') + +@csrf_exempt +def user(request): + logger.info(request.GET) + if 'username' in request.GET and 'password' in request.GET: + username = request.GET['username'] + password = request.GET['password'] + if username == 'admin': + return HttpResponse("allow administrator") + + if username == 'someuser': + return HttpResponse("allow") + + user = authenticate(username=username, password=password) + if user: + if user.is_superuser: + return HttpResponse("allow administrator") + else: + return HttpResponse("allow management") + return HttpResponse("deny") + +@csrf_exempt +def vhost(request): + logger.info(request.GET) + return HttpResponse("allow") + +@csrf_exempt +def resource(request): + logger.info(request.GET) + return HttpResponse("allow") + +@csrf_exempt +def topic(request): + logger.info(request.GET) + return HttpResponse("allow") diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/settings.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/settings.py new file mode 100644 index 0000000000..df60998885 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/settings.py @@ -0,0 +1,155 @@ +""" +Django settings for rabbitmq_auth_backend_django project. + +Generated by 'django-admin startproject' using Django 1.10.5. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '_wqlwxs-s(na_@1-@3=6uc2=-ka3f)))%-v#lgx4een8^#u92c' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost', 'auth-backend'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'rabbitmq_auth_backend_django.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'rabbitmq_auth_backend_django.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' + +LOGGING = { + 'version': 1, + 'formatters': { + 'verbose': { + 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' + }, + 'simple': { + 'format': '%(levelname)s %(message)s' + }, + }, + 'handlers': { + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'formatter': 'simple' + }, + }, + 'loggers': { + 'django': { + 'handlers': ['console'], + 'propagate': True, + }, + 'auth_backend': { + 'handlers': ['console'], + 'level': 'DEBUG', + 'propagate': True, + }, + } +} +# +# if DEBUG: +# # make all loggers use the console. +# for logger in LOGGING['loggers']: +# LOGGING['loggers'][logger]['handlers'] = ['console'] diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/urls.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/urls.py new file mode 100644 index 0000000000..671d4e0215 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/urls.py @@ -0,0 +1,26 @@ +"""rabbitmq_auth_backend_django URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url +from django.contrib import admin +import rabbitmq_auth_backend_django.auth.views as views + +urlpatterns = [ + url(r'^auth/user', views.user), + url(r'^auth/vhost', views.vhost), + url(r'^auth/resource', views.resource), + url(r'^auth/topic', views.topic), + url(r'^admin/', admin.site.urls), +] diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/wsgi.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/wsgi.py new file mode 100644 index 0000000000..70a321f86f --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/rabbitmq_auth_backend_django/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for rabbitmq_auth_backend_django project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rabbitmq_auth_backend_django.settings") + +application = get_wsgi_application() diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/start.sh b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/start.sh new file mode 100755 index 0000000000..8ddb5c153d --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/start.sh @@ -0,0 +1,3 @@ +#!/bin/sh +python manage.py migrate +python manage.py runserver 0.0.0.0:8000 diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/.gitignore b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/.gitignore new file mode 100644 index 0000000000..767f63f730 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/.gitignore @@ -0,0 +1,3 @@ +vendor +var +composer.lock diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/composer.json b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/composer.json new file mode 100644 index 0000000000..ddf3e438e8 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/composer.json @@ -0,0 +1,19 @@ +{ + "description": "Example RabbitMQ http auth backend php", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Anthony", + "email": "instabledesign@gmail.com" + } + ], + "require": { + "php": ">=5.4", + "symftony/rabbitmq-auth-backend-http-php": "dev-master", + "monolog/monolog": "^1.23" + }, + "scripts": { + "start": "php -S 127.0.0.1:8080 -t src" + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/bootstrap.php b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/bootstrap.php new file mode 100644 index 0000000000..f7bf096faf --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/bootstrap.php @@ -0,0 +1,136 @@ +<?php + +require_once __DIR__.'/../vendor/autoload.php'; + +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; +use Symfony\Component\Security\Core\User\InMemoryUserProvider; +use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager; +use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; +use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; +use RabbitMQAuth\Authentication\Authenticator; +use RabbitMQAuth\Authentication\ChainAuthenticationChecker; +use RabbitMQAuth\Authentication\UserPasswordTokenChecker; +use RabbitMQAuth\Authentication\UserTokenChecker; +use RabbitMQAuth\Authorization\DefaultVoter; +use RabbitMQAuth\Controller\AuthController; +use RabbitMQAuth\Security; +use Monolog\Handler\StreamHandler; +use Monolog\Logger; + +/** + * You must can edit the following users and theyre roles (tags) + */ +$userProvider = new InMemoryUserProvider(array( + //Admin user + 'Anthony' => array( + 'password' => 'anthony-password', + 'roles' => array( + 'administrator', + // 'impersonator', // report to https://www.rabbitmq.com/validated-user-id.html + ), + ), + 'James' => array( + 'password' => 'bond', + 'roles' => array( + 'management', + ), + ), + 'Roger' => array( + 'password' => 'rabbit', + 'roles' => array( + 'monitoring', + ), + ), + 'Bunny' => array( + 'password' => 'bugs', + 'roles' => array( + 'policymaker', + ), + ), +)); + +/** + * You can edit the user permissions here + * + * $permissions = arrray( + * '{USERNAME}' => array( + * '{VHOST}' => array( + * 'ip' => '{REGEX_IP}', + * 'read' => '{REGEX_READ}', + * 'write' => '{REGEX_WRITE}', + * 'configure' => '{REGEX_CONFIGURE}', + * ), + * ), + * ); + */ +$permissions = array( + 'Anthony' => array( + 'isAdmin' => true, + ), + 'James' => array( + '/' => array( + 'ip' => '.*', + 'read' => '.*', + 'write' => '.*', + 'configure' => '.*', + ), + ), +); + +/** + * Authenticator initialisation + * + * His gonna to find the user (with user provider) and to check the authentication with the authentication checker. + * + * We are 2 types of access token: + * - UserPasswordToken use with the user endpoint (to check the username and the password validity) + * - UserToken use with resource/topic/vhost endpoint (to check the username existence) + */ +$authenticator = new Authenticator( + $userProvider, + new ChainAuthenticationChecker(array( + new UserPasswordTokenChecker(), + new UserTokenChecker(), + )) +); + +/** + * DefaultVoter is used to check the authorization. + * + * This class has the same implementation of default RabbitMQ authorization process. + * + * $permission is the configured user permission + */ +$defaultVoter = new DefaultVoter($permissions); + +/** + * This class is the initialisation of the symfony/security component + */ +$authenticationManager = new AuthenticationProviderManager(array($authenticator)); +$accessDecisionManager = new AccessDecisionManager(array($defaultVoter)); + +$tokenStorage = new TokenStorage(); + +$authorizationChecker = new AuthorizationChecker( + $tokenStorage, + $authenticationManager, + $accessDecisionManager +); + +/** + * The security class is the main class + */ +$security = new Security($authenticationManager, $authorizationChecker); + +/** + * This is the auth controller. + * + * It take the http request and return the http response + */ +$authController = new AuthController($tokenStorage, $security); + +/** Add a logger */ +$stream = new StreamHandler(__DIR__.'/../var/log.log', Logger::DEBUG); +$authenticator->setLogger((new Logger('rabbitmq_authenticator'))->pushHandler($stream)); +$defaultVoter->setLogger((new Logger('rabbitmq_default_voter'))->pushHandler($stream)); +$security->setLogger((new Logger('rabbitmq_security'))->pushHandler($stream)); diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/resource.php b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/resource.php new file mode 100644 index 0000000000..9b2448b867 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/resource.php @@ -0,0 +1,14 @@ +<?php + +require_once '../vendor/autoload.php'; +require_once 'bootstrap.php'; + +/** + * The resource action handle the request and check the authentication + authorization of the request params + * It check the QUERYSTRING params before the payload. + */ +$response = $authController->resourceAction( + \Symfony\Component\HttpFoundation\Request::createFromGlobals() // Create an request object +); + +$response->send(); // send the http response diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/topic.php b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/topic.php new file mode 100644 index 0000000000..1ad5b4f72e --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/topic.php @@ -0,0 +1,14 @@ +<?php + +require_once '../vendor/autoload.php'; +require_once 'bootstrap.php'; + +/** + * The resource action handle the request and check the authentication + authorization of the request params + * It check the QUERYSTRING params before the payload. + */ +$response = $authController->topicAction( + \Symfony\Component\HttpFoundation\Request::createFromGlobals() // Create an request object +); + +$response->send(); // send the http response diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/user.php b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/user.php new file mode 100644 index 0000000000..a8b372325a --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/user.php @@ -0,0 +1,14 @@ +<?php + +require_once '../vendor/autoload.php'; +require_once 'bootstrap.php'; + +/** + * The resource action handle the request and check the authentication + authorization of the request params + * It check the QUERYSTRING params before the payload. + */ +$response = $authController->userAction( + \Symfony\Component\HttpFoundation\Request::createFromGlobals() // Create an request object +); + +$response->send(); // send the http response diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/vhost.php b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/vhost.php new file mode 100644 index 0000000000..3f49de4a88 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/src/vhost.php @@ -0,0 +1,14 @@ +<?php + +require_once '../vendor/autoload.php'; +require_once 'bootstrap.php'; + +/** + * The resource action handle the request and check the authentication + authorization of the request params + * It check the QUERYSTRING params before the payload. + */ +$response = $authController->vhostAction( + \Symfony\Component\HttpFoundation\Request::createFromGlobals() // Create an request object +); + +$response->send(); // send the http response diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/var/log.log b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/var/log.log new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_php/var/log.log diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.gitignore b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.gitignore new file mode 100644 index 0000000000..9b769de628 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.gitignore @@ -0,0 +1,3 @@ +*.class +target +*.iml diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/MavenWrapperDownloader.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000..c32394f140 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.5"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/maven-wrapper.jar b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/maven-wrapper.jar Binary files differnew file mode 100644 index 0000000000..0d5e649888 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/maven-wrapper.jar diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/maven-wrapper.properties b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..fa87ad7ddf --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/mvnw b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/mvnw new file mode 100755 index 0000000000..d2f0ea3808 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/mvnw.cmd b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/mvnw.cmd new file mode 100644 index 0000000000..b26ab24f03 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/pom.xml b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/pom.xml new file mode 100644 index 0000000000..50f0f9135d --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/pom.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.1.5.RELEASE</version> + </parent> + + <properties> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + </properties> + + <groupId>com.rabbitmq.examples</groupId> + <artifactId>rabbitmq-auth-backend-spring-boot</artifactId> + <version>1.0-SNAPSHOT</version> + + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/AuthBackendHttpController.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/AuthBackendHttpController.java new file mode 100644 index 0000000000..0de4f340af --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/AuthBackendHttpController.java @@ -0,0 +1,68 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. + */ + +package com.rabbitmq.examples; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +import static java.util.Arrays.asList; +import static org.springframework.util.StringUtils.collectionToDelimitedString; + +/** + * + */ +@RestController +@RequestMapping(path = "/auth", method = { RequestMethod.GET, RequestMethod.POST }) +public class AuthBackendHttpController { + + private static final Logger LOGGER = LoggerFactory.getLogger(AuthBackendHttpController.class); + + private final Map<String, User> users = new HashMap<String, User>() {{ + put("guest", new User("guest", "guest", asList("administrator", "management"))); + put("springy", new User("springy", "springy", asList("administrator", "management"))); + }}; + + @RequestMapping("user") + public String user(@RequestParam("username") String username, + @RequestParam("password") String password) { + LOGGER.info("Trying to authenticate user {}", username); + User user = users.get(username); + if (user != null && user.getPassword().equals(password)) { + return "allow " + collectionToDelimitedString(user.getTags(), " "); + } else { + return "deny"; + } + } + + @RequestMapping("vhost") + public String vhost(VirtualHostCheck check) { + LOGGER.info("Checking vhost access with {}", check); + return "allow"; + } + + @RequestMapping("resource") + public String resource(ResourceCheck check) { + LOGGER.info("Checking resource access with {}", check); + return "allow"; + } + + @RequestMapping("topic") + public String topic(TopicCheck check) { + LOGGER.info("Checking topic access with {}", check); + return check.getRouting_key().startsWith("a") ? "allow" : "deny"; + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/BaseCheck.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/BaseCheck.java new file mode 100644 index 0000000000..5cf5635078 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/BaseCheck.java @@ -0,0 +1,40 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. + */ + +package com.rabbitmq.examples; + +public class BaseCheck { + + private String username; + + private String vhost; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getVhost() { + return vhost; + } + + public void setVhost(String vhost) { + this.vhost = vhost; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{" + + "username='" + username + '\'' + + ", vhost='" + vhost + '\'' + + '}'; + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/RabbitMqAuthBackendHttp.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/RabbitMqAuthBackendHttp.java new file mode 100644 index 0000000000..50d5c57e8a --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/RabbitMqAuthBackendHttp.java @@ -0,0 +1,68 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. + */ + +package com.rabbitmq.examples; + +import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.ui.ModelMap; +import org.springframework.util.StringUtils; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.context.request.WebRequestInterceptor; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.util.stream.Collectors; + +@EnableAutoConfiguration +@SpringBootApplication +public class RabbitMqAuthBackendHttp { + + public static void main(String[] args) { + SpringApplication.run(RabbitMqAuthBackendHttp.class, args); + } + + // to enable: ./mvnw spring-boot:run -Dspring-boot.run.profiles=debug + @Profile("debug") + @Configuration + static class DebugConfiguration implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + + registry.addWebRequestInterceptor(new WebRequestInterceptor() { + @Override + public void preHandle(WebRequest request) { + LoggerFactory.getLogger(DebugConfiguration.class).info( + "HTTP request parameters: {}", + request.getParameterMap() + .entrySet().stream() + .map(entry -> entry.getKey() + " = " + StringUtils.arrayToCommaDelimitedString(entry.getValue())) + .collect(Collectors.toList()) + ); + } + + @Override + public void postHandle(WebRequest request, ModelMap model) { + + } + + @Override + public void afterCompletion(WebRequest request, Exception ex) { + + } + }); + } + + } + +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/ResourceCheck.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/ResourceCheck.java new file mode 100644 index 0000000000..3df3ef3ed2 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/ResourceCheck.java @@ -0,0 +1,47 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. + */ + +package com.rabbitmq.examples; + +public class ResourceCheck extends BaseCheck { + + private String resource, name, permission; + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPermission() { + return permission; + } + + public void setPermission(String permission) { + this.permission = permission; + } + + @Override + public String toString() { + return "ResourceCheck{" + + "resource='" + resource + '\'' + + ", name='" + name + '\'' + + ", permission='" + permission + '\'' + + "} " + super.toString(); + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/TopicCheck.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/TopicCheck.java new file mode 100644 index 0000000000..9b378fe52b --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/TopicCheck.java @@ -0,0 +1,29 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. + */ + +package com.rabbitmq.examples; + +public class TopicCheck extends ResourceCheck { + + private String routing_key; + + public String getRouting_key() { + return routing_key; + } + + public void setRouting_key(String routing_key) { + this.routing_key = routing_key; + } + + @Override + public String toString() { + return "TopicCheck{" + + "routing_key='" + routing_key + '\'' + + "} " + super.toString(); + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/User.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/User.java new file mode 100644 index 0000000000..47017a0714 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/User.java @@ -0,0 +1,62 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. + */ + +package com.rabbitmq.examples; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; + +/** + * + */ +public class User { + + private final String username, password; + + private final Collection<String> tags; + + public User(String username, String password) { + this(username, password, Collections.<String>emptyList()); + } + + public User(String username, String password, Collection<String> tags) { + this.username = username; + this.password = password; + this.tags = tags; + } + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + + public Collection<String> getTags() { + return new ArrayList<String>(tags); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + User user = (User) o; + + return username.equals(user.username); + } + + @Override + public int hashCode() { + return username.hashCode(); + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/VirtualHostCheck.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/VirtualHostCheck.java new file mode 100644 index 0000000000..8cb11032f4 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/main/java/com/rabbitmq/examples/VirtualHostCheck.java @@ -0,0 +1,15 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. + */ + +package com.rabbitmq.examples; + +public class VirtualHostCheck extends BaseCheck { + + + +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/test/java/com/rabbitmq/examples/AuthBackendHttpControllerTest.java b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/test/java/com/rabbitmq/examples/AuthBackendHttpControllerTest.java new file mode 100644 index 0000000000..0b5635246a --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/test/java/com/rabbitmq/examples/AuthBackendHttpControllerTest.java @@ -0,0 +1,66 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2017-2020 VMware, Inc. or its affiliates. All rights reserved. + */ + +package com.rabbitmq.examples; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import static org.assertj.core.api.Assertions.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +@RunWith(SpringRunner.class) +@WebMvcTest(AuthBackendHttpController.class) +public class AuthBackendHttpControllerTest { + + @Autowired + private MockMvc mvc; + + @Test public void authenticationAuthorisation() throws Exception { + this.mvc.perform(get("/auth/user").param("username", "guest").param("password", "guest")) + .andExpect(status().isOk()).andExpect(content().string("allow administrator management")); + + this.mvc.perform(get("/auth/user").param("username", "guest").param("password", "wrong")) + .andExpect(status().isOk()).andExpect(content().string("deny")); + + this.mvc.perform(get("/auth/vhost").param("username", "guest").param("vhost", "/")) + .andExpect(status().isOk()).andExpect(content().string("allow")); + + this.mvc.perform(get("/auth/resource") + .param("username", "guest") + .param("vhost", "/") + .param("resource", "exchange") + .param("name", "amq.topic") + .param("permission", "write")) + .andExpect(status().isOk()).andExpect(content().string("allow")); + + this.mvc.perform(get("/auth/topic") + .param("username", "guest") + .param("vhost", "/") + .param("resource", "exchange") + .param("name", "amq.topic") + .param("permission", "write") + .param("routing_key","a.b")) + .andExpect(status().isOk()).andExpect(content().string("allow")); + + this.mvc.perform(get("/auth/topic") + .param("username", "guest") + .param("vhost", "/") + .param("resource", "exchange") + .param("name", "amq.topic") + .param("permission", "write") + .param("routing_key","b.b")) + .andExpect(status().isOk()).andExpect(content().string("deny")); + } + +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/test/resources/logback-test.xml b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..93f69d4fb0 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot/src/test/resources/logback-test.xml @@ -0,0 +1,16 @@ +<configuration> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> + </encoder> + </appender> + + <logger name="com.rabbitmq.examples" level="INFO"/> + + + <root level="WARN"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration> diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.gitignore b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.gitignore new file mode 100644 index 0000000000..82eca336e3 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.gitignore @@ -0,0 +1,25 @@ +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/build/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.mvn/wrapper/maven-wrapper.jar b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.mvn/wrapper/maven-wrapper.jar Binary files differnew file mode 100644 index 0000000000..01e6799737 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.mvn/wrapper/maven-wrapper.jar diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.mvn/wrapper/maven-wrapper.properties b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..7179346716 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/README.md b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/README.md new file mode 100644 index 0000000000..2bed62b5d5 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/README.md @@ -0,0 +1,34 @@ +# Spring Boot Kotlin Backend + +Run the backend with: + + ./mvnw spring-boot:run + +Don't forget to configure the broker to use the backend! + +Use [`http`](https://httpie.org/doc) to test your program: + + $ http -f POST http://localhost:8080/auth/user username=foo password=bar -v + POST /auth/user HTTP/1.1 + Accept: */* + Accept-Encoding: gzip, deflate + Connection: keep-alive + Content-Length: 25 + Content-Type: application/x-www-form-urlencoded; charset=utf-8 + Host: localhost:8080 + User-Agent: HTTPie/0.9.2 + + username=foo&password=bar + + HTTP/1.1 200 + Cache-Control: no-cache, no-store, max-age=0, must-revalidate + Content-Length: 5 + Content-Type: text/plain;charset=UTF-8 + Date: Thu, 01 Nov 2018 21:16:06 GMT + Expires: 0 + Pragma: no-cache + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + X-XSS-Protection: 1; mode=block + + allow diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/mvnw b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/mvnw new file mode 100755 index 0000000000..8b9da3b8b6 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/mvnw.cmd b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/mvnw.cmd new file mode 100644 index 0000000000..fef5a8f7f9 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/pom.xml b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/pom.xml new file mode 100644 index 0000000000..8d281d8aa8 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/pom.xml @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.rabbitmq.examples</groupId> + <artifactId>rabbitmq-auth-backend-spring-boot-kotlin</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>rabbitmq-auth-backend-spring-boot-kotlin</name> + <description>Demo project for https://github.com/rabbitmq/rabbitmq-auth-backend-http</description> + + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.1.0.RELEASE</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + <kotlin.version>1.3.0</kotlin.version> + <junit-jupiter.version>5.3.1</junit-jupiter.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-security</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.module</groupId> + <artifactId>jackson-module-kotlin</artifactId> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-jdk8</artifactId> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-reflect</artifactId> + </dependency> + + <dependency> + <groupId>org.springframework.security</groupId> + <artifactId>spring-security-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + <exclusion> + <groupId>org.skyscreamer</groupId> + <artifactId>jsonassert</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-test</artifactId> + <version>${kotlin.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> + <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + <plugin> + <artifactId>kotlin-maven-plugin</artifactId> + <groupId>org.jetbrains.kotlin</groupId> + <configuration> + <args> + <arg>-Xjsr305=strict</arg> + </args> + <compilerPlugins> + <plugin>spring</plugin> + </compilerPlugins> + </configuration> + <dependencies> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-maven-allopen</artifactId> + <version>${kotlin.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> + + +</project> diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/AuthController.kt b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/AuthController.kt new file mode 100644 index 0000000000..5281fa06a0 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/AuthController.kt @@ -0,0 +1,73 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2018-2020 VMware, Inc. or its affiliates. All rights reserved. + */ +package com.rabbitmq.examples; + +import org.slf4j.LoggerFactory +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestMethod +import org.springframework.web.bind.annotation.RestController + +/** + * Controller for the RabbitMQ authentication/authorisation as described + * in https://github.com/rabbitmq/rabbitmq-auth-backend-http + */ +@RequestMapping(path = ["/auth"], method = [RequestMethod.GET, RequestMethod.POST]) +@RestController +class AuthController { + + private val ALLOW = "allow" + private val DENY = "deny" + + private val logger = LoggerFactory.getLogger(AuthController::class.java!!) + + /** + * user_path + */ + @RequestMapping(value = ["/user"], produces = ["text/plain"]) + fun checkUserCredentials(passwordCheck: PasswordCheck): String { + logger.info("checkUserCredentials username: ${passwordCheck.username}") + if (passwordCheck.username == "guest" && passwordCheck.password == "guest") { + return "$ALLOW administrator management" + } else { + return DENY + } + } + + /** + * vhost_path + */ + @RequestMapping(value = ["/vhost"], produces = ["text/plain"]) + fun checkVhost(question: VirtualHostCheck): String { + logger.info("checkVhost: $question") + return ALLOW + } + + /** + * resource_path + */ + @RequestMapping(value = ["/resource"], produces = ["text/plain"]) + fun checkResource(question: ResourceCheck): String { + logger.info("checkResource: $question") + return ALLOW + } + + /** + * topic_path + */ + @RequestMapping(value = ["/topic"], produces = ["text/plain"]) + fun checkTopic(question: TopicCheck): String { + logger.info("checkTopic: $question") + return if (question.routing_key.startsWith("a", false)) ALLOW else DENY + } + +} + +data class PasswordCheck(val username: String, val password: String) +data class VirtualHostCheck(val username: String, val vhost: String) +data class ResourceCheck(val username: String, val vhost: String, val resource: String, val name: String, val permission: String) +data class TopicCheck(val username: String, val vhost: String, val resource: String, val name: String, val permission: String, val routing_key: String) diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/Configuration.kt b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/Configuration.kt new file mode 100644 index 0000000000..67a02e02c6 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/Configuration.kt @@ -0,0 +1,20 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2018-2020 VMware, Inc. or its affiliates. All rights reserved. + */ +package com.rabbitmq.examples + +import org.springframework.context.annotation.Configuration +import org.springframework.security.config.annotation.web.builders.HttpSecurity +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter + + +@Configuration +class SecurityConfiguration : WebSecurityConfigurerAdapter() { + override fun configure(http: HttpSecurity) { + http.csrf().ignoringAntMatchers("/auth/**") + } +}
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/RabbitmqAuthBackendApplication.kt b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/RabbitmqAuthBackendApplication.kt new file mode 100644 index 0000000000..fd0a8d8d65 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/kotlin/com/rabbitmq/examples/RabbitmqAuthBackendApplication.kt @@ -0,0 +1,18 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2018-2020 VMware, Inc. or its affiliates. All rights reserved. + */ +package com.rabbitmq.examples + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class RabbitmqAuthBackendSpringBootKotlinApplication + +fun main(args: Array<String>) { + runApplication<RabbitmqAuthBackendSpringBootKotlinApplication>(*args) +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/resources/application.properties b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/resources/application.properties new file mode 100644 index 0000000000..b76da5ffa8 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/resources/application.properties @@ -0,0 +1,2 @@ +logging.level.root=INFO +logging.level.com.rabbitmq.examples=INFO
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/resources/rabbitmq.conf b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/resources/rabbitmq.conf new file mode 100644 index 0000000000..02737bd5a5 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/main/resources/rabbitmq.conf @@ -0,0 +1,11 @@ +# Additional configuration for /etc/rabbitmq/rabbitmq.conf +# do not forget to initialize the plugin in the docker +# RUN rabbitmq-plugins enable --offline rabbitmq_auth_backend_http + +# http backend +auth_backends.1 = rabbit_auth_backend_http +auth_http.user_path = http://<server:port>/<path>/auth/user +auth_http.vhost_path = http://<server:port>/<path>/auth/vhost +auth_http.resource_path = http://<server:port>/<path>/auth/resource +auth_http.topic_path = http://<server:port>/<path>/auth/topic +auth_http.http_method = post
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/test/kotlin/com/rabbitmq/examples/AuthApiTest.kt b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/test/kotlin/com/rabbitmq/examples/AuthApiTest.kt new file mode 100644 index 0000000000..be899d334c --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/src/test/kotlin/com/rabbitmq/examples/AuthApiTest.kt @@ -0,0 +1,127 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright (c) 2018-2020 VMware, Inc. or its affiliates. All rights reserved. + */ +package com.rabbitmq.examples + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.http.MediaType +import org.springframework.test.context.junit.jupiter.SpringExtension +import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post +import org.springframework.test.web.servlet.result.MockMvcResultMatchers +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status + +@ExtendWith(SpringExtension::class) +@WebMvcTest +class AuthApiTest(@Autowired val mockMvc: MockMvc) { + + // user + @Test + fun `Check authentication for external users with GET`() { + mockMvc.perform(get("/auth/user") + .param("username", "guest") + .param("password", "guest")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("allow administrator management")) + + } + + @Test + fun `Check deny for external users with GET`() { + mockMvc.perform(get("/auth/user") + .param("username", "guest") + .param("password", "wrong")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("deny")) + } + + @Test + fun `Check authentication for external users with POST`() { + mockMvc.perform(post("/auth/user").contentType(MediaType.APPLICATION_FORM_URLENCODED) + .content("username=guest&password=guest")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("allow administrator management")) + } + + // vhost + @Test + fun `Check vhost for external users with GET`() { + mockMvc.perform(get("/auth/vhost") + .param("username", "guest") + .param("vhost", "guest")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("allow")) + } + + @Test + fun `Check vhost for external users with POST`() { + mockMvc.perform(post("/auth/vhost").contentType(MediaType.APPLICATION_FORM_URLENCODED) + .content("username=guest&vhost=guest")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("allow")) + } + + // resource + @Test + fun `Check resource_path for external users with GET`() { + mockMvc.perform(get("/auth/resource") + .param("username", "guest") + .param("vhost", "guest") + .param("resource", "exchange") + .param("name", "amq.topic") + .param("permission", "write")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("allow")) + } + + @Test + fun `Check resource_path for external users with POST`() { + mockMvc.perform(post("/auth/resource").contentType(MediaType.APPLICATION_FORM_URLENCODED) + .content("username=guest&vhost=guest&resource=exchange&name=amq.topic&permission=write")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("allow")) + } + + // topic + @Test + fun `Check topic for external users with GET`() { + mockMvc.perform(get("/auth/topic") + .param("username", "guest") + .param("vhost", "guest") + .param("resource", "exchange") + .param("name", "amq.topic") + .param("routing_key", "a.b") + .param("permission", "write")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("allow")) + } + + @Test + fun `Check topic for external users with POST`() { + mockMvc.perform(post("/auth/topic").contentType(MediaType.APPLICATION_FORM_URLENCODED) + .content("username=guest&vhost=guest&resource=exchange&name=amq.topic&permission=write&routing_key=a.b")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("allow")) + } + + @Test + fun `Check deny topic for external users with GET`() { + mockMvc.perform(get("/auth/topic") + .param("username", "guest") + .param("vhost", "guest") + .param("resource", "exchange") + .param("name", "amq.topic") + .param("routing_key", "b.b") + .param("permission", "write")) + .andExpect(status().isOk) + .andExpect(MockMvcResultMatchers.content().string("deny")) + } +}
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/App_Start/WebApiConfig.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/App_Start/WebApiConfig.cs new file mode 100644 index 0000000000..bd11ca20c4 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/App_Start/WebApiConfig.cs @@ -0,0 +1,12 @@ +using System.Web.Http;
+
+namespace WebApiHttpAuthService
+{
+ public static class WebApiConfig
+ {
+ public static void Register(HttpConfiguration config)
+ {
+ config.MapHttpAttributeRoutes();
+ }
+ }
+}
diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Controllers/AuthController.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Controllers/AuthController.cs new file mode 100644 index 0000000000..8282d1407e --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Controllers/AuthController.cs @@ -0,0 +1,143 @@ +using System;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Formatting;
+using System.Text;
+using System.Web.Http;
+
+namespace WebApiHttpAuthService.Controllers
+{
+ [RoutePrefix("auth")]
+ public class AuthController : ApiController
+ {
+ // Note: the following is necessary to ensure that no
+ // BOM is part of the response
+ private static readonly UTF8Encoding encoding = new UTF8Encoding(false);
+
+ [Route("user")]
+ [HttpPost]
+ public HttpResponseMessage user(FormDataCollection form)
+ {
+ string content = "allow administrator management";
+ try
+ {
+ if (form != null)
+ {
+ string username = form.Get("username");
+ string password = form.Get("password");
+
+ if(username=="authuser") //Sample check you can put your custom logic over here
+ content = "deny";
+
+ string userlog = string.Format("user :{0}, password :{1}", username, password);
+ }
+ }
+ catch(Exception ex)
+ {
+ //check or log error
+ }
+
+ var resp = new HttpResponseMessage(HttpStatusCode.OK);
+ resp.Content = new StringContent(content, encoding, "text/plain");
+ return resp;
+ }
+
+ [Route("vhost")]
+ [HttpPost]
+ public HttpResponseMessage vhost(FormDataCollection form)
+ {
+ string content = "allow";
+ try
+ {
+ if (form != null)
+ {
+ string username = form.Get("username");
+ string ip = form.Get("ip");
+
+ if (username == "authuser") //Sample checks you can put your custom logic over here
+ content = "deny";
+
+ string userlog = string.Format("user :{0}, ip :{1}", username, ip);
+ }
+ }
+ catch (Exception ex)
+ {
+ //check or log error
+ }
+
+ var resp = new HttpResponseMessage(HttpStatusCode.OK);
+ resp.Content = new StringContent(content, encoding, "text/plain");
+ return resp;
+ }
+
+ [Route("resource")]
+ [HttpPost]
+ public HttpResponseMessage resource(FormDataCollection form)
+ {
+ string content = "allow";
+
+ try
+ {
+ if (form != null)
+ {
+ string username = form.Get("username");
+ string vhost = form.Get("vhost");
+ string resource = form.Get("resource");
+ string name = form.Get("name");
+ string permission = form.Get("permission");
+
+ if (username == "authuser") //Sample checks you can put your custom logic over here
+ content = "deny";
+
+ string userlog = string.Format("user :{0}, vhost :{1}, resource :{2}, name: {3}, permission: {4}", username, vhost, resource, name, permission);
+
+ }
+ }
+ catch (Exception ex)
+ {
+ //check or log error
+ }
+
+
+ var resp = new HttpResponseMessage(HttpStatusCode.OK);
+ resp.Content = new StringContent(content, encoding, "text/plain");
+ return resp;
+ }
+
+ [Route("topic")]
+ [HttpPost]
+ public HttpResponseMessage topic(FormDataCollection form)
+ {
+ string content = "allow";
+ try
+ {
+ if (form != null)
+ {
+ string username = form.Get("username");
+ string vhost = form.Get("vhost");
+ string resource = form.Get("resource");
+ string name = form.Get("name");
+ string permission = form.Get("permission");
+ string routing_key = form.Get("routing_key");
+
+ if (username == "authuser") //Sample checks you can put your custom logic over here
+ content = "deny";
+
+ string userlog = string.Format("user :{0}, vhost :{1}, resource :{2}, name: {3}, permission: {4}, routing_key :{5}", username, vhost, resource, name, permission, routing_key);
+
+ }
+ }
+ catch (Exception ex)
+ {
+ //check or log error
+ }
+
+ var resp = new HttpResponseMessage(HttpStatusCode.OK);
+ resp.Content = new StringContent(content, encoding, "text/plain");
+ return resp;
+ }
+
+
+
+ }
+}
diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Global.asax b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Global.asax new file mode 100644 index 0000000000..b1a51c9b48 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="WebApiHttpAuthService.WebApiApplication" Language="C#" %>
diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Global.asax.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Global.asax.cs new file mode 100644 index 0000000000..0f7abd87dc --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Global.asax.cs @@ -0,0 +1,12 @@ +using System.Web.Http;
+
+namespace WebApiHttpAuthService
+{
+ public class WebApiApplication : System.Web.HttpApplication
+ {
+ protected void Application_Start()
+ {
+ GlobalConfiguration.Configure(WebApiConfig.Register);
+ }
+ }
+}
diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Properties/AssemblyInfo.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1da9738e4d --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("WebApiHttpAuthService")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WebApiHttpAuthService")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f141c3e3-fd04-475b-b2b9-00328d0f907b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.Debug.config b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.Debug.config new file mode 100644 index 0000000000..c1a56423b0 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.Debug.config @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?>
+
+<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
+
+<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
+ <!--
+ In the example below, the "SetAttributes" transform will change the value of
+ "connectionString" to use "ReleaseSQLServer" only when the "Match" locator
+ finds an attribute "name" that has a value of "MyDB".
+
+ <connectionStrings>
+ <add name="MyDB"
+ connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
+ xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
+ </connectionStrings>
+ -->
+ <system.web>
+ <!--
+ In the example below, the "Replace" transform will replace the entire
+ <customErrors> section of your web.config file.
+ Note that because there is only one customErrors section under the
+ <system.web> node, there is no need to use the "xdt:Locator" attribute.
+
+ <customErrors defaultRedirect="GenericError.htm"
+ mode="RemoteOnly" xdt:Transform="Replace">
+ <error statusCode="500" redirect="InternalError.htm"/>
+ </customErrors>
+ -->
+ </system.web>
+</configuration>
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.Release.config b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.Release.config new file mode 100644 index 0000000000..19058ed353 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.Release.config @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?>
+
+<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
+
+<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
+ <!--
+ In the example below, the "SetAttributes" transform will change the value of
+ "connectionString" to use "ReleaseSQLServer" only when the "Match" locator
+ finds an attribute "name" that has a value of "MyDB".
+
+ <connectionStrings>
+ <add name="MyDB"
+ connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
+ xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
+ </connectionStrings>
+ -->
+ <system.web>
+ <compilation xdt:Transform="RemoveAttributes(debug)" />
+ <!--
+ In the example below, the "Replace" transform will replace the entire
+ <customErrors> section of your web.config file.
+ Note that because there is only one customErrors section under the
+ <system.web> node, there is no need to use the "xdt:Locator" attribute.
+
+ <customErrors defaultRedirect="GenericError.htm"
+ mode="RemoteOnly" xdt:Transform="Replace">
+ <error statusCode="500" redirect="InternalError.htm"/>
+ </customErrors>
+ -->
+ </system.web>
+</configuration>
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.config b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.config new file mode 100644 index 0000000000..1c190314d0 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/Web.config @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!--
+ For more information on how to configure your ASP.NET application, please visit
+ https://go.microsoft.com/fwlink/?LinkId=301879
+ -->
+<configuration>
+ <appSettings />
+ <!--
+ For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
+
+ The following attributes can be set on the <httpRuntime> tag.
+ <system.Web>
+ <httpRuntime targetFramework="4.5" />
+ </system.Web>
+ -->
+ <system.web>
+ <compilation debug="true" targetFramework="4.5" />
+ <httpRuntime targetFramework="4.5" />
+ </system.web>
+
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
+ </dependentAssembly>
+
+ </assemblyBinding>
+ </runtime>
+<system.webServer>
+ <handlers>
+ <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
+ <remove name="OPTIONSVerbHandler" />
+ <remove name="TRACEVerbHandler" />
+ <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
+ </handlers>
+ </system.webServer></configuration>
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.csproj b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.csproj new file mode 100644 index 0000000000..912a9fdc7d --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.csproj @@ -0,0 +1,136 @@ +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>
+ </ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{F141C3E3-FD04-475B-B2B9-00328D0F907B}</ProjectGuid>
+ <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>WebApiHttpAuthService</RootNamespace>
+ <AssemblyName>WebApiHttpAuthService</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <UseIISExpress>true</UseIISExpress>
+ <Use64BitIISExpress />
+ <IISExpressSSLPort />
+ <IISExpressAnonymousAuthentication />
+ <IISExpressWindowsAuthentication />
+ <IISExpressUseClassicPipelineMode />
+ <UseGlobalApplicationHostFile />
+ <NuGetPackageImportStamp>
+ </NuGetPackageImportStamp>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="Microsoft.Practices.ServiceLocation">
+ <HintPath>..\..\VEMS.Sample\Dependencies\WSF\Microsoft.Practices.ServiceLocation.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Net.Http.Formatting">
+ <HintPath>packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.DynamicData" />
+ <Reference Include="System.Web.Entity" />
+ <Reference Include="System.Web.ApplicationServices" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Web.Extensions" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Http">
+ <HintPath>packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Http.WebHost">
+ <HintPath>packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Web.Services" />
+ <Reference Include="System.EnterpriseServices" />
+ <Reference Include="System.Xml.Linq" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Global.asax" />
+ <Content Include="Web.config">
+ <SubType>Designer</SubType>
+ </Content>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="App_Start\WebApiConfig.cs" />
+ <Compile Include="Controllers\AuthController.cs" />
+ <Compile Include="Global.asax.cs">
+ <DependentUpon>Global.asax</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ <None Include="Web.Debug.config">
+ <DependentUpon>Web.config</DependentUpon>
+ </None>
+ <None Include="Web.Release.config">
+ <DependentUpon>Web.config</DependentUpon>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="App_Data\" />
+ <Folder Include="Models\" />
+ </ItemGroup>
+ <PropertyGroup>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ </PropertyGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
+ <WebProjectProperties>
+ <UseIIS>True</UseIIS>
+ <AutoAssignPort>True</AutoAssignPort>
+ <DevelopmentServerPort>62243</DevelopmentServerPort>
+ <DevelopmentServerVPath>/</DevelopmentServerVPath>
+ <IISUrl>http://localhost:62190/</IISUrl>
+ <NTLMAuthentication>False</NTLMAuthentication>
+ <UseCustomServer>False</UseCustomServer>
+ <CustomServerUrl>
+ </CustomServerUrl>
+ <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
+ </WebProjectProperties>
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.csproj.user b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.csproj.user new file mode 100644 index 0000000000..1a60d6407f --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.csproj.user @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <UseIISExpress>true</UseIISExpress>
+ <Use64BitIISExpress />
+ <IISExpressSSLPort />
+ <IISExpressAnonymousAuthentication />
+ <IISExpressWindowsAuthentication />
+ <IISExpressUseClassicPipelineMode />
+ <UseGlobalApplicationHostFile />
+ <WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth>
+ <WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
+ <WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
+ <WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
+ <WebStackScaffolding_LayoutPageFile />
+ <WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
+ </PropertyGroup>
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
+ <WebProjectProperties>
+ <StartPageUrl>
+ </StartPageUrl>
+ <StartAction>CurrentPage</StartAction>
+ <AspNetDebugging>True</AspNetDebugging>
+ <SilverlightDebugging>False</SilverlightDebugging>
+ <NativeDebugging>False</NativeDebugging>
+ <SQLDebugging>False</SQLDebugging>
+ <ExternalProgram>
+ </ExternalProgram>
+ <StartExternalURL>
+ </StartExternalURL>
+ <StartCmdLineArguments>
+ </StartCmdLineArguments>
+ <StartWorkingDirectory>
+ </StartWorkingDirectory>
+ <EnableENC>True</EnableENC>
+ <AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>
+ </WebProjectProperties>
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+</Project>
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.sln b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.sln new file mode 100644 index 0000000000..5dc14fc12c --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/WebApiHttpAuthService.sln @@ -0,0 +1,25 @@ +
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26730.8
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiHttpAuthService", "WebApiHttpAuthService.csproj", "{F141C3E3-FD04-475B-B2B9-00328D0F907B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F141C3E3-FD04-475B-B2B9-00328D0F907B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F141C3E3-FD04-475B-B2B9-00328D0F907B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F141C3E3-FD04-475B-B2B9-00328D0F907B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F141C3E3-FD04-475B-B2B9-00328D0F907B}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {2E60A79D-A68A-4486-A8F2-917C08BA2C8A}
+ EndGlobalSection
+EndGlobal
diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/packages.config b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/packages.config new file mode 100644 index 0000000000..f7de901155 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnet/packages.config @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
+ <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
+ <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
+ <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
+</packages>
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/AuthResult.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/AuthResult.cs new file mode 100644 index 0000000000..12766b122c --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/AuthResult.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Mvc; + +namespace RabbitMqAuthBackendHttp +{ + public static class AuthResult + { + public static IActionResult Allow() + { + return new OkObjectResult("allow"); + } + + public static IActionResult Allow(params string[] tags) + { + return new OkObjectResult($"allow {string.Join(" ", tags)}"); + } + + public static IActionResult Deny() + { + return new OkObjectResult("deny"); + } + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Controllers/AuthController.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Controllers/AuthController.cs new file mode 100644 index 0000000000..3f4b3fc19e --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Controllers/AuthController.cs @@ -0,0 +1,110 @@ +using System; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using RabbitMqAuthBackendHttp.Requests; + +namespace RabbitMqAuthBackendHttp.Controllers +{ + [Route("[controller]")] + [ApiController] + public class AuthController : ControllerBase + { + private readonly ILogger<AuthController> _logger; + + public AuthController(ILogger<AuthController> logger) + { + _logger = logger; + } + + [HttpGet] + public ActionResult<string> Get() + { + return "AuthController"; + } + + [Route("user")] + [HttpPost] + public IActionResult CheckUser([FromForm]UserAuthRequest request) + { + var tags = new [] {"administrator", "management"}; + + try + { + var userlog = string.Format("user : {0}, password : {1}", request.UserName, request.Password); + _logger.LogInformation(userlog); + + if (request.UserName == "authuser") //Sample check you can put your custom logic over here + return AuthResult.Deny(); + + } + catch (Exception ex) + { + //check or log error + } + + return AuthResult.Allow(tags); + } + + [Route("vhost")] + [HttpPost] + public IActionResult CheckVhost([FromForm]VhostAuthRequest request) + { + try + { + var userlog = string.Format("user : {0}, ip : {1}", request.UserName, request.Ip); + _logger.LogInformation(userlog); + + if (request.UserName == "authuser") //Sample checks you can put your custom logic over here + return AuthResult.Deny(); + } + catch (Exception ex) + { + //check or log error + } + + return AuthResult.Allow(); + } + + [Route("resource")] + [HttpPost] + public IActionResult CheckResource([FromForm]ResourceAuthRequest request) + { + try + { + var userlog = $"user : {request.UserName}, vhost : {request.Vhost}, resource : {request.Resource}, " + + $"name : {request.Name}, permission : {request.Permission}"; + _logger.LogInformation(userlog); + + if (request.UserName == "authuser") //Sample checks you can put your custom logic over here + return AuthResult.Deny(); + } + catch (Exception ex) + { + //check or log error + } + + return AuthResult.Allow(); + } + + [Route("topic")] + [HttpPost] + public IActionResult CheckTopic([FromForm]TopicAuthRequest request) + { + try + { + var userlog = $"user : {request.UserName}, vhost : {request.Vhost}, resource : {request.Resource}, " + + $"name : {request.Name}, routing key: {request.RoutingKey}, permission : {request.Permission}"; + _logger.LogInformation(userlog); + + if (request.UserName == "authuser") //Sample checks you can put your custom logic over here + return AuthResult.Deny(); + } + catch (Exception ex) + { + //check or log error + } + + return AuthResult.Allow(); + } + } +}
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Program.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Program.cs new file mode 100644 index 0000000000..c25b893205 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Program.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; + +namespace RabbitMqAuthBackendHttp +{ + public class Program + { + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup<Startup>(); + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Properties/launchSettings.json b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Properties/launchSettings.json new file mode 100644 index 0000000000..3015f0da9f --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:53729", + "sslPort": 44312 + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "RabbitMqAuthBackendHttp": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:5000" + } + } +}
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/RabbitMqAuthBackendHttp.csproj b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/RabbitMqAuthBackendHttp.csproj new file mode 100644 index 0000000000..65edaa8124 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/RabbitMqAuthBackendHttp.csproj @@ -0,0 +1,18 @@ +<Project Sdk="Microsoft.NET.Sdk.Web"> + + <PropertyGroup> + <TargetFramework>netcoreapp2.1</TargetFramework> + </PropertyGroup> + + <ItemGroup> + <Compile Remove="wwwroot\**" /> + <Content Remove="wwwroot\**" /> + <EmbeddedResource Remove="wwwroot\**" /> + <None Remove="wwwroot\**" /> + </ItemGroup> + + <ItemGroup> + <PackageReference Include="Microsoft.AspNetCore.App" /> + </ItemGroup> + +</Project> diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/RabbitMqAuthBackendHttp.sln b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/RabbitMqAuthBackendHttp.sln new file mode 100644 index 0000000000..d4392fc131 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/RabbitMqAuthBackendHttp.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RabbitMqAuthBackendHttp", "RabbitMqAuthBackendHttp.csproj", "{5CBC938E-5097-4888-A43F-2A9C190F41A6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Debug|x64.ActiveCfg = Debug|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Debug|x64.Build.0 = Debug|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Debug|x86.ActiveCfg = Debug|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Debug|x86.Build.0 = Debug|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Release|Any CPU.Build.0 = Release|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Release|x64.ActiveCfg = Release|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Release|x64.Build.0 = Release|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Release|x86.ActiveCfg = Release|Any CPU + {5CBC938E-5097-4888-A43F-2A9C190F41A6}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8B62538E-3E8E-4B80-857E-D34C9DE1CD09} + EndGlobalSection +EndGlobal diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/Resource.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/Resource.cs new file mode 100644 index 0000000000..dcab5ac3f6 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/Resource.cs @@ -0,0 +1,11 @@ +namespace RabbitMqAuthBackendHttp.Requests +{ + public enum Resource + { + Exchange, + + Queue, + + Topic + } +}
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/ResourceAuthRequest.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/ResourceAuthRequest.cs new file mode 100644 index 0000000000..1b9bc9658c --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/ResourceAuthRequest.cs @@ -0,0 +1,24 @@ +namespace RabbitMqAuthBackendHttp.Requests +{ + public class ResourceAuthRequest + { + public string UserName { get; set; } + + public string Vhost { get; set; } + + public Resource Resource { get; set; } + + public string Name { get; set; } + + public ResourcePermission Permission { get; set; } + } + + public enum ResourcePermission + { + Configure, + + Write, + + Read + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/TopicAuthRequest.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/TopicAuthRequest.cs new file mode 100644 index 0000000000..fbc9440a67 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/TopicAuthRequest.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc; + +namespace RabbitMqAuthBackendHttp.Requests +{ + public class TopicAuthRequest + { + public string UserName { get; set; } + + public string Vhost { get; set; } + + public string Name { get; set; } + + public Resource Resource { get; set; } + + public TopicPermission Permission { get; set; } + + [ModelBinder(Name = "routing_key")] + public string RoutingKey { get; set; } + } + + public enum TopicPermission + { + Write, + + Read + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/UserAuthRequest.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/UserAuthRequest.cs new file mode 100644 index 0000000000..e9b7282cee --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/UserAuthRequest.cs @@ -0,0 +1,9 @@ +namespace RabbitMqAuthBackendHttp.Requests +{ + public class UserAuthRequest + { + public string UserName { get; set; } + + public string Password { get; set; } + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/VhostAuthRequest.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/VhostAuthRequest.cs new file mode 100644 index 0000000000..5b072df9c4 --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Requests/VhostAuthRequest.cs @@ -0,0 +1,12 @@ +namespace RabbitMqAuthBackendHttp.Requests +{ + public class VhostAuthRequest + { + public string UserName { get; set; } + + public string Vhost { get; set; } + + public string Ip { get; set; } + } +} +
\ No newline at end of file diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Startup.cs b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Startup.cs new file mode 100644 index 0000000000..3dd050830d --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/Startup.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace RabbitMqAuthBackendHttp +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseMvc(); + } + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/appsettings.Development.json b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/appsettings.Development.json new file mode 100644 index 0000000000..e203e9407e --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/appsettings.json b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/appsettings.json new file mode 100644 index 0000000000..def9159a7d --- /dev/null +++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_webapi_dotnetcore/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} |