Add HAVE_BAUTH conditional compilation for basic auth#367
Merged
Conversation
Add HAVE_BAUTH conditional compilation for basic authentication, mirroring the existing HAVE_DAUTH pattern. This allows libhttpserver to build against libmicrohttpd installations that lack basic auth support. Changes: - configure.ac: Auto-detect MHD_queue_basic_auth_fail_response, define HAVE_BAUTH flag and AM_CONDITIONAL, add to summary output - src/httpserver/basic_auth_fail_response.hpp: Guard with #ifdef HAVE_BAUTH - src/basic_auth_fail_response.cpp: Guard with #ifdef HAVE_BAUTH - src/httpserver.hpp: Conditionally include basic_auth_fail_response.hpp - src/httpserver/http_request.hpp: Guard get_user(), get_pass(), fetch_user_pass() declarations and username/password cache fields - src/http_request.cpp: Guard fetch_user_pass(), get_user(), get_pass() implementations and basic auth output in operator<< - src/httpserver/create_webserver.hpp: Guard basic_auth()/no_basic_auth() methods and _basic_auth_enabled member - src/httpserver/webserver.hpp: Guard basic_auth_enabled member - src/webserver.cpp: Guard basic_auth_enabled initialization - src/Makefile.am: Make basic_auth_fail_response conditional on HAVE_BAUTH - examples/Makefile.am: Guard basic_authentication and centralized_authentication examples behind HAVE_BAUTH - test/integ/authentication.cpp: Guard basic auth tests with HAVE_BAUTH - test/unit/create_webserver_test.cpp: Guard basic_auth builder test
Guard basic auth references in ws_start_stop.cpp, basic.cpp, create_test_request_test.cpp, create_test_request.hpp, and create_test_request.cpp that would fail to compile when libmicrohttpd lacks basic auth support.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #367 +/- ##
==========================================
+ Coverage 67.93% 67.97% +0.03%
==========================================
Files 28 28
Lines 1634 1636 +2
Branches 672 672
==========================================
+ Hits 1110 1112 +2
Misses 64 64
Partials 460 460
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Add Version 0.20.0 header with bauth conditional compilation and security fix entries. Bump version in configure.ac to match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AC_CHECK_LIBforMHD_queue_basic_auth_fail_response#ifdef HAVE_BAUTH/#endif, mirroring the existingHAVE_DAUTHpatternBasic Auth : yes/noto the./configuresummary outputAddresses item 6 from #61: conditional compilation for libmicrohttpd features (basic auth).
Changes
Build system (
configure.ac,src/Makefile.am,examples/Makefile.am):MHD_queue_basic_auth_fail_responseand setHAVE_BAUTHdefine + automake conditionalbasic_auth_fail_response.cppand install its headerbasic_authenticationandcentralized_authenticationexamplesLibrary sources (18 files, +85/-6 lines):
basic_auth_fail_response.hpp/.cpp— wrap class/impl in#ifdef HAVE_BAUTHhttp_request.hpp/.cpp— guardget_user(),get_pass(),fetch_user_pass(), cache fieldscreate_webserver.hpp— guardbasic_auth()/no_basic_auth()builder methodswebserver.hpp/.cpp— guardbasic_auth_enabledmemberhttpserver.hpp— conditionally includebasic_auth_fail_response.hppcreate_test_request.hpp/.cpp— guard.user()/.pass()builder and cache accessTests:
authentication.cpp,basic.cpp,ws_start_stop.cpp,create_webserver_test.cpp,create_test_request_test.cpp— guard basic auth test casesTest plan
HAVE_BAUTHdefined (standard libmicrohttpd)HAVE_BAUTH(verified via direct compilation)