Skip to content

Authentication support and improved build process #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2a69106
Update README
hugorosario Sep 8, 2016
fbf7a39
Update README
hugorosario Sep 8, 2016
5c0eba8
Rename README to README.md
hugorosario Sep 8, 2016
b5551d5
Update README.md
hugorosario Sep 8, 2016
1b47e0d
Update README.md
hugorosario Sep 8, 2016
0bd3c8e
Update README.md
hugorosario Sep 8, 2016
cbb8313
Update README.md
hugorosario Sep 8, 2016
f8f249f
Update README.md
hugorosario Sep 8, 2016
81ee805
Update README.md
hugorosario Sep 8, 2016
c400ba7
Update compilation process
Sep 8, 2016
ca8e046
Removed compile instructions from header
Sep 8, 2016
9af94f1
Update with function usage examples
hugorosario Sep 8, 2016
4971390
Update README.md
hugorosario Sep 9, 2016
ccf4596
Changed stompsend2 to send headers on the CONNECT frame, this will al…
Sep 9, 2016
e4523af
Update README.md
hugorosario Sep 9, 2016
e2ab73b
Merge branch 'master' of https://github.com/hugorosario/lib_mysqludf_…
Sep 9, 2016
9efb045
Update disclamer
Sep 9, 2016
b67d598
Authentication validation
hugorosario Sep 9, 2016
859e911
Update README.md
hugorosario Sep 9, 2016
5d2b8df
Improved authentication validation.
hugorosario Sep 10, 2016
b237543
Reverted Makefile to use /usr/lib/x86_64-linux-gnu
hugorosario Sep 10, 2016
98d2a2e
Removed warning
hugorosario Sep 10, 2016
3ce2e18
Add gcc on dependency package installation
hugorosario Sep 13, 2016
a7bc881
Disabled Timeouts
hugorosario Sep 15, 2016
c9e91ad
Implemented the stomp_read code from libstomp sources and replaced th…
hugorosario Sep 16, 2016
2dff5a2
Update info about the response of failed authentications.
hugorosario Sep 16, 2016
af6a3e6
Removed authentication validation
hugorosario Nov 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MYSQL_DEV_DIR=/usr/include/mysql
APR_DEV_DIR=/usr/include/apr-1.0/
MYSQL_LIB_DIR=/usr/lib/mysql/plugin
APR_LIB_DIR=/usr/lib/x86_64-linux-gnu
#APR_LIB_DIR=/usr/lib/i386-linux-gnu

install:
gcc -Wall -O2 -I$(APR_DEV_DIR) -I$(MYSQL_DEV_DIR) lib_mysqludf_stomp.c $(APR_LIB_DIR)/libapr-1.so -shared -o $(MYSQL_LIB_DIR)/lib_mysqludf_stomp.so -fPIC

33 changes: 0 additions & 33 deletions README

This file was deleted.

82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
## lib_mysqludf_stomp

A MySQL UDF library to send STOMP messages to a message broker.
Supports authentication using the stompsend2 function (see details below).

## Instructions for Ubuntu

### Install Dependencies
In order do compile the plugin, you need to install Apache Portable Runtime (APR) and MySQL client development packages.

`sudo apt-get install gcc libapr1 libapr1-dev libmysqlclient-dev`

### Compile & Install
To install the UDF, just run the provided install script which will compile and install the library.
The MySQL root password will be requested for installing.

`sudo ./install.sh`

#### If you get errors of missing libraries, edit the Makefile and make sure the paths are correct for your system.

### Using the functions

The plugin will provide you with 3 new functions you can use in your queries.
All of them take the same first 3 parameters (Hostname, Topic, Message) and the others are headers.
For authentication you must use `stompsend2`.
All parameters are strings :

- stompsend(Hostname, Topic, Message);
- stompsend1(Hostname, Topic, Message, HeaderName, HeaderValue);
- stompsend2(Hostname, Topic, Message, Header1Name, Header1Value, Header2Name, Header2Value);

### Example
To send the message "Hello broker" to the "Welcome" topic on server "127.0.0.1", just use :

`SELECT stompsend("127.0.0.1","Welcome", "Hello broker");`

If everything went well, you should get and "OK" response, else you will get a NULL:

```
+--------------------------------------------------+
| stompsend("127.0.0.1","Welcome", "Hello broker") |
+--------------------------------------------------+
| OK |
+--------------------------------------------------+
1 row in set (0.00 sec)
```

If you need to authenticate, you can use the `stompsend2` function with the "login" and "passcode" as headers.
This function was modified in this fork to allow authentication by sending the headers on the CONNECT frame.

`SELECT stompsend2("127.0.0.1","Welcome", "Hello broker", "login","guest","passcode","mypass");`

If the credentials are invalid, you should receive the body of the message sent by the broker (ex: "Access refused for client 'guest'.").

## Credits

Copyright 2005 LogicBlaze Inc.

Copyright (C) 2011 Dmitry Demianov aka barlone

this library use part of libstomp code

web of STOMP project: http://stomp.codehaus.org

email: [email protected]

Authentication support on stompsend2 added by hugorosario

## Licence

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.
24 changes: 24 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

echo "Compiling the MySQL UDF"
make

if test $? -ne 0; then
echo "ERROR: You need libmysqlclient and Apache Portable Runtime development software installed "
echo "to be able to compile this UDF, on Debian/Ubuntu just run:"
echo "apt-get install libapr1 libapr1-dev libmysqlclient-dev"
exit 1
else
echo "MySQL UDF compiled successfully"
fi

echo -e "\nPlease provide your MySQL root password to install the UDF..."

mysql -u root -p mysql < lib_mysqludf_stomp.sql

if test $? -ne 0; then
echo "ERROR: unable to install the UDF"
exit 1
else
echo "MySQL UDF installed successfully"
fi
Loading