Ports the fewo-webapp AuthInterceptor + requireAdmin onto three abstract
interfaces so consumer apps plug in their own user store, public paths,
and runtime config without forking:
auth/AuthPrincipal.hpp library-owned {id, username, role} value
auth/IAuthBackend.hpp resolveBy{Session,ApiKey,Cert}, hasActiveUsers,
deleteExpiredSessions
auth/IAuthPolicy.hpp isPublicPath, adminRoles, readonlyRoles,
setupModeActive (defaults: admin/readonly,
no public paths, setup off)
auth/IRuntimeConfig.hpp bindAddress, isLoopback
auth/AuthInterceptor.hpp intercept() running the same 6-step ladder as
fewo's original (public → setup → cert DN →
session/API key → CSRF → readonly)
auth/RequireRole.hpp requireUser + requireAdmin helpers reading
bundle data (config-driven role sets, not
hard-coded 'admin')
TokenHasher is passed in so the library doesn't prescribe SHA-256 vs.
whatever. Bundle keys match fewo's existing controllers so the consumer
migration in #418 is a straightforward adapter swap.
Smoke-compiled against oatpp 1.3.0 headers.
Closes fewo-webapp#413
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
1.6 KiB
CMake
46 lines
1.6 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
project(oatpp-authkit VERSION 0.2.0 LANGUAGES CXX)
|
|
|
|
# Header-only interface library — no compilation, just an include path and
|
|
# a CMake config package so consumers do:
|
|
# find_package(oatpp-authkit REQUIRED)
|
|
# target_link_libraries(app PRIVATE oatpp::authkit)
|
|
#
|
|
# Or FetchContent:
|
|
# FetchContent_Declare(oatpp-authkit GIT_REPOSITORY ... GIT_TAG v0.1.0)
|
|
# FetchContent_MakeAvailable(oatpp-authkit)
|
|
|
|
add_library(oatpp-authkit INTERFACE)
|
|
add_library(oatpp::authkit ALIAS oatpp-authkit)
|
|
|
|
target_include_directories(oatpp-authkit INTERFACE
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
)
|
|
target_compile_features(oatpp-authkit INTERFACE cxx_std_17)
|
|
|
|
# Installation
|
|
include(GNUInstallDirs)
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
install(TARGETS oatpp-authkit EXPORT oatpp-authkit-targets)
|
|
install(EXPORT oatpp-authkit-targets
|
|
FILE oatpp-authkit-targets.cmake
|
|
NAMESPACE oatpp::
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/oatpp-authkit)
|
|
|
|
write_basic_package_version_file(
|
|
"${CMAKE_CURRENT_BINARY_DIR}/oatpp-authkit-config-version.cmake"
|
|
VERSION ${PROJECT_VERSION}
|
|
COMPATIBILITY SameMajorVersion)
|
|
|
|
configure_package_config_file(
|
|
cmake/oatpp-authkit-config.cmake.in
|
|
"${CMAKE_CURRENT_BINARY_DIR}/oatpp-authkit-config.cmake"
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/oatpp-authkit)
|
|
|
|
install(FILES
|
|
"${CMAKE_CURRENT_BINARY_DIR}/oatpp-authkit-config.cmake"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/oatpp-authkit-config-version.cmake"
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/oatpp-authkit)
|