From aacc5d8d270b1cc9fe455d1b058304ab62335c3b Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Fri, 23 Aug 2019 11:50:59 -0400 Subject: [PATCH 1/2] add entitlement logging to everyone's favorite super long md log --- src/lib/md/relay/RelayClient.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/md/relay/RelayClient.cpp b/src/lib/md/relay/RelayClient.cpp index 341ff53fd..b7d4da066 100644 --- a/src/lib/md/relay/RelayClient.cpp +++ b/src/lib/md/relay/RelayClient.cpp @@ -240,6 +240,9 @@ public: log << Venue_Name(ch.exchange()).substr(sizeof("venue")); log << " " << (uint32_t)ch.time(); log << " " << (uint16_t)ch.segment_id(); + if (!ch.entitled()) { + log << " " << "Ent=0"; + } } log << "\n}"; auto encoded = websocketpp::base64_encode(log.str()); From af83516e38fb2f5e4a16f66a665a55d7d6b3aaf1 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Mon, 26 Aug 2019 10:22:48 -0400 Subject: [PATCH 2/2] Add user to KEYCODE logging --- src/lib/utils/AuthSessionManager.cpp | 8 ++++---- src/lib/utils/AuthSessionManager.h | 10 +++++----- src/lib/utils/AuthToken.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/utils/AuthSessionManager.cpp b/src/lib/utils/AuthSessionManager.cpp index dddb415fd..8b1b74438 100644 --- a/src/lib/utils/AuthSessionManager.cpp +++ b/src/lib/utils/AuthSessionManager.cpp @@ -80,7 +80,7 @@ bool AuthSessionManager::validate_ip_port(const bts::config::KeyCode& kc) return portgood && ipgood; } -bool AuthSessionManager::add_or_replace_session(const api::user::TokenPayload& tok, std::string* msg) +bool AuthSessionManager::add_or_replace_session(const api::user::TokenPayload& tok, const admin::BTSUser& user, std::string* msg) { if(tok.wheel()) return true; @@ -105,18 +105,18 @@ bool AuthSessionManager::add_or_replace_session(const api::user::TokenPayload& t if(it != _map.end()) { _map[tok.id()] = Session{tok}; - LOG(User, Warn, "KEYCODE: Replacing session {} ", tok.id()); + LOG(User, Warn, "KEYCODE: Replacing session {} user:{}:{} ", tok.id(), user.id(), user.name()); return true; } else if(_map.size() < _nusers) { _map[tok.id()] = Session{tok}; - LOG(User, Warn, "KEYCODE: Creating session {} ", tok.id()); + LOG(User, Warn, "KEYCODE: Creating session {} user:{}:{}", tok.id(), user.id(), user.name()); return true; } if(msg) *msg = "KEYCODES: Not Enough Logins available for session"; - LOG(User, Error, "KEYCODES: Not Enough Logins available for session {}", tok.id()); + LOG(User, Error, "KEYCODES: Not Enough Logins available for session {} user:{}:{}", tok.id(), user.id(), user.name()); return false; } diff --git a/src/lib/utils/AuthSessionManager.h b/src/lib/utils/AuthSessionManager.h index 08e9d03cd..fa68d097e 100644 --- a/src/lib/utils/AuthSessionManager.h +++ b/src/lib/utils/AuthSessionManager.h @@ -8,7 +8,7 @@ namespace bts { namespace config { class KeyCode; } namespace api { namespace auth { - + struct Session { api::user::TokenPayload token; @@ -18,8 +18,8 @@ class AuthSessionManager { public: AuthSessionManager(); - - bool add_or_replace_session(const api::user::TokenPayload& tok, std::string* msg = nullptr); + + bool add_or_replace_session(const api::user::TokenPayload& tok, const admin::BTSUser& user, std::string* msg = nullptr); bool check_session(const api::user::TokenPayload& tok); private: @@ -33,6 +33,6 @@ private: bool _concurrent; }; - - + + }}} \ No newline at end of file diff --git a/src/lib/utils/AuthToken.cpp b/src/lib/utils/AuthToken.cpp index 2423638a8..9c062c592 100644 --- a/src/lib/utils/AuthToken.cpp +++ b/src/lib/utils/AuthToken.cpp @@ -89,7 +89,7 @@ AuthToken generate_token(const admin::BTSUser& user, std::string* msg) payload.set_wheel(true); if(requires_auth_session(user)) - session_manager().add_or_replace_session(payload, msg); + session_manager().add_or_replace_session(payload, user, msg); auto token = encrypt(payload.SerializeAsString()); bts_assert_d(token.size() < 255-8); AuthToken result;