Commit Graph
28 Commits
Author SHA1 Message Date
andrey 6bf50344fd fix: harden PIHTTPServerSessionAuth session table
- cleanupExpired() drops sessions expired by tokenTtl or sessionIdleTimeout and is
  called opportunistically on issuing a token, bounding the session table; it is
  protected and self-locking so subclasses can run it periodically
- issueToken() refuses a token already used by an active session instead of
  silently merging two sessions (login replies 500 on a generator collision)
- document that the token generator must be collision-resistant
- tests: SessionCleanupOnLogin, ManualCleanup, TokenCollisionRejected
2026-09-23 08:49:10 +03:00
andrey e1a24a98f7 fix: accept case-insensitive Basic scheme and guard HTTP test target
- parse the Basic auth-scheme case-insensitively (RFC 7235), matching Bearer
- register the http_server test only when pip_http_server and pip_http_client
  targets exist, so TESTS=ON without the HTTP modules does not fail to link
- add a Basic_LowercaseScheme test
2026-09-23 08:49:04 +03:00
andrey 994cf64838 feat: add optional sliding idle timeout to PIHTTPServerSessionAuth
The idle timeout is opt-in: when set with setSessionIdleTimeout(), a session
expires after that period without a successful request and every successful
request extends it. When unset (the default), sessions are not touched and keep
the previous behavior: the absolute tokenTtl applied to created, or living until
logout. Both deadlines can be combined and the earlier one wins.

- SessionRec: add last_used, drop the unused refresh_token field
- checkToken(): update last_used only while the idle timeout is enabled
- tests: IdleTimeout, IdleActivityExtendsSession, IdleDisabledKeepsSession,
  HasSessionIdleTimeout
2026-09-23 00:10:07 +03:00
andrey 2f63a49c69 refactor: make PIHTTPServerSessionAuth own sessions only, delegate credentials
The server no longer stores user accounts. PIHTTPServerMultiUser is renamed to
PIHTTPServerSessionAuth and keeps only the in-memory session table: credential
verification is delegated to the pure virtual checkCredentials(), implemented by
a client subclass that owns the user storage.

- remove UserRec, addUser/removeUser/userExists/userCount and the password
  check callback; add protected revokeToken()/revokeUserTokens() helpers
- add configurable login/logout route paths (default /api/login, /api/logout)
- call checkCredentials() without holding the internal lock and report 500 when
  the token generator yields no data
- rewrite tests around a client subclass with its own user table
2026-09-22 23:33:25 +03:00
andrey 78fbebe6b0 fix: accept case-insensitive Bearer scheme in HTTP server 2026-09-22 23:33:10 +03:00
andrey 1adb8b528e Merge branch 'master' into http_auth 2026-09-06 13:54:25 +03:00
andrey 9b459330df fixes 2026-09-06 13:52:47 +03:00
andrey 1025b978aa Add HTTP Bearer auth server class with token validator 2026-09-05 23:01:14 +03:00
andrey 6327720e73 Add multi-user Basic auth support via AuthInfo 2026-09-05 22:51:50 +03:00
andrey 4e1ab26124 Add HTTP Basic Auth and protected server modules
- PIHTTPServerBasicAuth: parse Authorization: Basic header, validate credentials via callback
- PIHTTPServerProtected: wrap any handler with auth check (basic or custom token)
- Integration tests for both modules (12 test cases)
2026-09-05 21:59:42 +03:00
andrey 2605446573 refactor: rename __PIP_TYPENAME_DECLARE to PIP_REGISTER_TYPENAME, add PIP_DECLARE_TYPENAME macro
- Rename __PIP_TYPENAME_DECLARE to PIP_REGISTER_TYPENAME across all headers
- Add PIP_DECLARE_TYPENAME(name) macro for in-class type name declaration
- Replace all static const char * __pip_typename__() member functions with PIP_DECLARE_TYPENAME
2026-08-24 19:31:41 +03:00
andrey 86a1084ec1 feat: enforce no-RTTI type name registration with static_assert 2026-08-23 08:20:51 +03:00
andrey f6075307b6 style: run clang-format over all files 2026-08-22 15:52:58 +03:00
peri4 34b55de561 revert RequestFunction 2026-05-26 21:37:21 +03:00
peri4 a2093e24a6 detach PIHTTPServer::Endpoint to base struct PIHTTP::ServerEndpoint (private header), no functionality changes in HTTP server
Ready to implement this private base struct to MQTT client
2026-05-26 21:31:58 +03:00
andrey 96c22e1184 move std function 2026-03-20 16:31:30 +03:00
peri4 5db97ca959 version 5.4.0
remove CORS default header from PIHTTPServer
fix several docs
fix PIMathVector::dot return type
add units directory with PIUnits facility
2025-09-26 21:33:45 +03:00
peri4 ef8b785ac6 version 5.1.0
PIHTTPServer now can handle path with partially *, ** and {} path arguments
PIHTTP::MessageConst add queryArguments() and pathArguments(). arguments() now union of these args
2025-08-28 19:48:19 +03:00
peri4 15548de79c version 4.5.0
PIThread::stopAndWait now returns bool
PIKbdListener on Linux now use piwaitevent_p and can immediately stop
new base method piZeroMemory, also migrate all "memset 0" to piZeroMemory
2024-12-29 11:48:24 +03:00
peri4 58b3fa64bc http server fix 2024-11-25 15:00:42 +03:00
peri4 1acaf24df9 PIHTTPServer basic auth works 2024-11-24 23:23:08 +03:00
peri4 dff4f2b3a0 add http_client library, using libcurl
take out common http entities to http_common dir
2024-11-23 17:54:22 +03:00
peri4 24112498ce new method PILog::readAllLogs 2024-11-18 22:47:02 +03:00
peri4 c9a5ddd89f PIProtectedVariable - user now can`t mistake
PIHTTPServer improvements
2024-11-18 11:11:19 +03:00
peri4 c67f7a2b64 log fix 2024-11-15 16:23:48 +03:00
peri4 047d38ea59 http includes 2024-11-15 15:47:56 +03:00
peri4 ee137b2820 http server options, remove old 2024-11-15 14:18:49 +03:00
peri4 cdde340efe add microhttpd server 2024-11-14 18:15:27 +03:00