Rename package.
This commit is contained in:
parent
b18ed96444
commit
bfb110d061
|
|
@ -4,11 +4,11 @@ cmake_minimum_required(VERSION 3.16)
|
||||||
option (USE_SUPERBUILD "Whether or not a superbuild should be invoked" ON)
|
option (USE_SUPERBUILD "Whether or not a superbuild should be invoked" ON)
|
||||||
|
|
||||||
if (USE_SUPERBUILD)
|
if (USE_SUPERBUILD)
|
||||||
project(jwp-mosquitto-plugin-super)
|
project(j7s-mosquitto-plugin-super)
|
||||||
include(external-deps.cmake)
|
include(external-deps.cmake)
|
||||||
return()
|
return()
|
||||||
else()
|
else()
|
||||||
project(jwp-mosquitto-plugin)
|
project(j7s-mosquitto-plugin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(jwt-cpp)
|
find_package(jwt-cpp)
|
||||||
|
|
@ -16,10 +16,10 @@ find_package(OpenSSL)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
add_library(jwp-plugin SHARED src/jwp-plugin.cpp src/AuthList.cpp src/Authorizer.cpp)
|
add_library(j7s-plugin SHARED src/j7s-plugin.cpp src/AuthList.cpp src/Authorizer.cpp)
|
||||||
target_include_directories(jwp-plugin PUBLIC
|
target_include_directories(j7s-plugin PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
${jwt-cpp_INCLUDE_DIR}
|
${jwt-cpp_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
target_link_libraries(jwp-plugin OpenSSL::Crypto)
|
target_link_libraries(j7s-plugin OpenSSL::Crypto)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# j7s-jwt-mosquitto-auth
|
# j7s-mosquitto-plugin
|
||||||
|
|
||||||
Authentication using JWTs for the mosquitto mqtt broker.
|
Authentication using JWTs for the mosquitto mqtt broker.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
-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
|
ExternalProject_Add (ep_j7s-mosquitto-plugin
|
||||||
PREFIX ep_jwp-mosquitto-plugin
|
PREFIX ep_j7s-mosquitto-plugin
|
||||||
DEPENDS ${DEPENDENCIES}
|
DEPENDS ${DEPENDENCIES}
|
||||||
SOURCE_DIR "${PROJECT_SOURCE_DIR}"
|
SOURCE_DIR "${PROJECT_SOURCE_DIR}"
|
||||||
CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${EXTRA_CMAKE_ARGS}
|
CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${EXTRA_CMAKE_ARGS}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <jwp-plugin/AuthList.hpp>
|
#include <j7s-plugin/AuthList.hpp>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -28,6 +28,6 @@ extern "C" {
|
||||||
int mosquitto_plugin_cleanup(void *userdata, struct mosquitto_opt *options, int option_count);
|
int mosquitto_plugin_cleanup(void *userdata, struct mosquitto_opt *options, int option_count);
|
||||||
}
|
}
|
||||||
// My functions
|
// My functions
|
||||||
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);
|
||||||
int jwp_acl_check_callback(int event, void *event_data, void *userdata);
|
int j7s_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);
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include <jwp-plugin/AuthList.hpp>
|
#include <j7s-plugin/AuthList.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
AuthList::AuthList():
|
AuthList::AuthList():
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include <jwp-plugin/Authorizer.hpp>
|
#include <j7s-plugin/Authorizer.hpp>
|
||||||
#include <jwp-plugin/AuthList.hpp>
|
#include <j7s-plugin/AuthList.hpp>
|
||||||
|
|
||||||
#include <jwt-cpp/jwt.h>
|
#include <jwt-cpp/jwt.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include <jwp-plugin/jwp-plugin.h>
|
#include <j7s-plugin/j7s-plugin.h>
|
||||||
#include <jwp-plugin/Authorizer.hpp>
|
#include <j7s-plugin/Authorizer.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
@ -72,9 +72,9 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **userdata, st
|
||||||
authorizer = std::make_unique<Authorizer>(public_key, issuer);
|
authorizer = std::make_unique<Authorizer>(public_key, issuer);
|
||||||
|
|
||||||
// Register the callbacks.
|
// 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_BASIC_AUTH, j7s_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_ACL_CHECK, j7s_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_DISCONNECT, j7s_disconnect_callback, NULL, NULL);
|
||||||
// May want MOSQ_EVT_RELOAD as well.
|
// May want MOSQ_EVT_RELOAD as well.
|
||||||
|
|
||||||
return MOSQ_ERR_SUCCESS;
|
return MOSQ_ERR_SUCCESS;
|
||||||
|
|
@ -84,15 +84,15 @@ int mosquitto_plugin_cleanup(void *userdata, struct mosquitto_opt *options, int
|
||||||
{
|
{
|
||||||
if(plugin_id)
|
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_BASIC_AUTH, j7s_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_ACL_CHECK, j7s_acl_check_callback, NULL);
|
||||||
mosquitto_callback_unregister(plugin_id, MOSQ_EVT_DISCONNECT, jwp_disconnect_callback, NULL);
|
mosquitto_callback_unregister(plugin_id, MOSQ_EVT_DISCONNECT, j7s_disconnect_callback, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return MOSQ_ERR_SUCCESS;
|
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)
|
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)
|
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<struct mosquitto_evt_disconnect*>(event_data);
|
struct mosquitto_evt_disconnect *disconnect_data = static_cast<struct mosquitto_evt_disconnect*>(event_data);
|
||||||
const std::string username = std::string(mosquitto_client_username(disconnect_data->client));
|
const std::string username = std::string(mosquitto_client_username(disconnect_data->client));
|
||||||
|
|
@ -7,6 +7,6 @@ protocol mqtt
|
||||||
log_type all
|
log_type all
|
||||||
allow_anonymous true
|
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_issuer https://auth.jpace121.net/realms/jpace121-main
|
||||||
auth_opt_public_key /home/jimmy/Develop/mosquitto-plugin/test/key.pem
|
auth_opt_public_key /home/jimmy/Develop/mosquitto-plugin/test/key.pem
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue