Merged in entitlement_logging (pull request #327)

RTM: Add entitlement logging to everyone's favorite super long md log
This commit is contained in:
Eric Harding authored and Pedro Pinto committed 2019-08-28 18:20:24 +00:00
commit 7a4cb105d8
4 files changed
+13 -10

No files matched your search

+3
View File
@@ -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());
+4 -4
View File
@@ -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;
}
+5 -5
View File
@@ -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;
};
}}}
+1 -1
View File
@@ -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;