diff --git a/CMakeLists.txt b/CMakeLists.txt index 57f27ed..3263ee9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,11 @@ cmake_minimum_required(VERSION 3.16) option (USE_SUPERBUILD "Whether or not a superbuild should be invoked" ON) if (USE_SUPERBUILD) - project(jwp-mosquitto-plugin-super) + project(j7s-mosquitto-plugin-super) include(external-deps.cmake) return() else() - project(jwp-mosquitto-plugin) + project(j7s-mosquitto-plugin) endif() find_package(jwt-cpp) @@ -16,10 +16,10 @@ find_package(OpenSSL) set(CMAKE_CXX_STANDARD 20) -add_library(jwp-plugin SHARED src/jwp-plugin.cpp src/AuthList.cpp src/Authorizer.cpp) -target_include_directories(jwp-plugin PUBLIC +add_library(j7s-plugin SHARED src/j7s-plugin.cpp src/AuthList.cpp src/Authorizer.cpp) +target_include_directories(j7s-plugin PUBLIC $ $ ${jwt-cpp_INCLUDE_DIR} ) -target_link_libraries(jwp-plugin OpenSSL::Crypto) +target_link_libraries(j7s-plugin OpenSSL::Crypto) diff --git a/README.md b/README.md index 6687b4b..d0a6824 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# j7s-jwt-mosquitto-auth +# j7s-mosquitto-plugin Authentication using JWTs for the mosquitto mqtt broker. diff --git a/external-deps.cmake b/external-deps.cmake index 90b75e5..9266bf0 100644 --- a/external-deps.cmake +++ b/external-deps.cmake @@ -16,8 +16,8 @@ list (APPEND EXTRA_CMAKE_ARGS -Djwt-cpp_DIR=${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp -Djwt-cpp_INCLUDE_DIR=${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp/include ) -ExternalProject_Add (ep_jwp-mosquitto-plugin - PREFIX ep_jwp-mosquitto-plugin +ExternalProject_Add (ep_j7s-mosquitto-plugin + PREFIX ep_j7s-mosquitto-plugin DEPENDS ${DEPENDENCIES} SOURCE_DIR "${PROJECT_SOURCE_DIR}" CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${EXTRA_CMAKE_ARGS} diff --git a/include/jwp-plugin/AuthList.hpp b/include/j7s-plugin/AuthList.hpp similarity index 100% rename from include/jwp-plugin/AuthList.hpp rename to include/j7s-plugin/AuthList.hpp diff --git a/include/jwp-plugin/Authorizer.hpp b/include/j7s-plugin/Authorizer.hpp similarity index 97% rename from include/jwp-plugin/Authorizer.hpp rename to include/j7s-plugin/Authorizer.hpp index 0e81f81..99ae445 100644 --- a/include/jwp-plugin/Authorizer.hpp +++ b/include/j7s-plugin/Authorizer.hpp @@ -13,7 +13,7 @@ // limitations under the License. #pragma once -#include +#include #include #include diff --git a/include/jwp-plugin/jwp-plugin.h b/include/j7s-plugin/j7s-plugin.h similarity index 86% rename from include/jwp-plugin/jwp-plugin.h rename to include/j7s-plugin/j7s-plugin.h index 6f1451a..f84a48f 100644 --- a/include/jwp-plugin/jwp-plugin.h +++ b/include/j7s-plugin/j7s-plugin.h @@ -28,6 +28,6 @@ extern "C" { int mosquitto_plugin_cleanup(void *userdata, struct mosquitto_opt *options, int option_count); } // My functions -int jwp_auth_basic_auth_callback(int event, void *event_data, void *userdata); -int jwp_acl_check_callback(int event, void *event_data, void *userdata); -int jwp_disconnect_callback(int event, void *event_data, void *userdata); +int j7s_auth_basic_auth_callback(int event, void *event_data, void *userdata); +int j7s_acl_check_callback(int event, void *event_data, void *userdata); +int j7s_disconnect_callback(int event, void *event_data, void *userdata); diff --git a/src/AuthList.cpp b/src/AuthList.cpp index 2c76757..bbdc935 100644 --- a/src/AuthList.cpp +++ b/src/AuthList.cpp @@ -11,7 +11,7 @@ // 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. -#include +#include #include AuthList::AuthList(): diff --git a/src/Authorizer.cpp b/src/Authorizer.cpp index 1718384..9fd2ee0 100644 --- a/src/Authorizer.cpp +++ b/src/Authorizer.cpp @@ -11,8 +11,8 @@ // 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. -#include -#include +#include +#include #include diff --git a/src/jwp-plugin.cpp b/src/j7s-plugin.cpp similarity index 89% rename from src/jwp-plugin.cpp rename to src/j7s-plugin.cpp index 90c2e89..43784fc 100644 --- a/src/jwp-plugin.cpp +++ b/src/j7s-plugin.cpp @@ -11,8 +11,8 @@ // 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. -#include -#include +#include +#include #include #include @@ -72,9 +72,9 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **userdata, st authorizer = std::make_unique(public_key, issuer); // Register the callbacks. - mosquitto_callback_register(plugin_id, MOSQ_EVT_BASIC_AUTH, jwp_auth_basic_auth_callback, NULL, NULL); - mosquitto_callback_register(plugin_id, MOSQ_EVT_ACL_CHECK, jwp_acl_check_callback, NULL, NULL); - mosquitto_callback_register(plugin_id, MOSQ_EVT_DISCONNECT, jwp_disconnect_callback, NULL, NULL); + mosquitto_callback_register(plugin_id, MOSQ_EVT_BASIC_AUTH, j7s_auth_basic_auth_callback, NULL, NULL); + mosquitto_callback_register(plugin_id, MOSQ_EVT_ACL_CHECK, j7s_acl_check_callback, NULL, NULL); + mosquitto_callback_register(plugin_id, MOSQ_EVT_DISCONNECT, j7s_disconnect_callback, NULL, NULL); // May want MOSQ_EVT_RELOAD as well. return MOSQ_ERR_SUCCESS; @@ -84,15 +84,15 @@ int mosquitto_plugin_cleanup(void *userdata, struct mosquitto_opt *options, int { if(plugin_id) { - mosquitto_callback_unregister(plugin_id, MOSQ_EVT_BASIC_AUTH, jwp_auth_basic_auth_callback, NULL); - mosquitto_callback_unregister(plugin_id, MOSQ_EVT_ACL_CHECK, jwp_acl_check_callback, NULL); - mosquitto_callback_unregister(plugin_id, MOSQ_EVT_DISCONNECT, jwp_disconnect_callback, NULL); + mosquitto_callback_unregister(plugin_id, MOSQ_EVT_BASIC_AUTH, j7s_auth_basic_auth_callback, NULL); + mosquitto_callback_unregister(plugin_id, MOSQ_EVT_ACL_CHECK, j7s_acl_check_callback, NULL); + mosquitto_callback_unregister(plugin_id, MOSQ_EVT_DISCONNECT, j7s_disconnect_callback, NULL); } return MOSQ_ERR_SUCCESS; } -int jwp_auth_basic_auth_callback(int event, void *event_data, void *userdata) +int j7s_auth_basic_auth_callback(int event, void *event_data, void *userdata) { if(not authorizer) { @@ -125,7 +125,7 @@ int jwp_auth_basic_auth_callback(int event, void *event_data, void *userdata) } } -int jwp_acl_check_callback(int event, void *event_data, void *userdata) +int j7s_acl_check_callback(int event, void *event_data, void *userdata) { if(not authorizer) { @@ -156,7 +156,7 @@ int jwp_acl_check_callback(int event, void *event_data, void *userdata) } } -int jwp_disconnect_callback(int event, void *event_data, void *userdata) +int j7s_disconnect_callback(int event, void *event_data, void *userdata) { struct mosquitto_evt_disconnect *disconnect_data = static_cast(event_data); const std::string username = std::string(mosquitto_client_username(disconnect_data->client)); diff --git a/test/mosquitto.conf b/test/mosquitto.conf index 52b09bc..34ad561 100644 --- a/test/mosquitto.conf +++ b/test/mosquitto.conf @@ -7,6 +7,6 @@ protocol mqtt log_type all allow_anonymous true -auth_plugin /home/jimmy/Develop/mosquitto-plugin/build/libjwp-plugin.so +auth_plugin /home/jimmy/Develop/mosquitto-plugin/build/libj7s-plugin.so auth_opt_issuer https://auth.jpace121.net/realms/jpace121-main auth_opt_public_key /home/jimmy/Develop/mosquitto-plugin/test/key.pem