Merged in SPARK-2524-keycode_fixes (pull request #290)
RTM fixed SPARK-2524, allowing admin logins to not require a keycode session Approved-by: Eric Harding <eric.harding@bluetradesys.com> Approved-by: Pedro Pinto <pedro.pinto+atlassian@bluetradesys.com>
This commit is contained in:
commit
085d6402f4
5 files changed
+57
-4
No files matched your search
@@ -9,6 +9,9 @@ insert_anchor_links = "right"
|
||||
- In the ladder made last trade more distinctive when overlayed on the volumn column
|
||||
- In the ladder, corrected display of volume tool tip
|
||||
- In the ladder, changed the consolidation of last trade to consider only the price ignoring aggressor changes
|
||||
### Internal Changes
|
||||
- Ensure that admin logins are always allowed to login, regardless of keycode status.
|
||||
|
||||
## 2.5.0
|
||||
### User Visible Changes
|
||||
- Added loss limit risk check
|
||||
|
||||
@@ -86,7 +86,7 @@ bool AuthSessionManager::add_or_replace_session(const api::user::TokenPayload& t
|
||||
return true;
|
||||
if(datetime::ll_diff_in_us(datetime::ll_now(), _expiration) < 0)
|
||||
{
|
||||
LOG(Gen,Error, "Your BTS Keycode is expired!");
|
||||
LOG(User,Error, "Your BTS Keycode is expired!");
|
||||
if(msg)
|
||||
*msg = "Your BTS Keycode is EXPIRED! Please contact sales@bluetradesys.com";
|
||||
return false;
|
||||
@@ -105,13 +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());
|
||||
return true;
|
||||
}
|
||||
else if(_map.size() < _nusers)
|
||||
{
|
||||
_map[tok.id()] = Session{tok};
|
||||
LOG(User, Warn, "KEYCODE: Creating session {} ", tok.id());
|
||||
return true;
|
||||
}
|
||||
if(msg)
|
||||
*msg = "KEYCODES: Not Enough Logins available for session";
|
||||
LOG(User, Error, "KEYCODES: Not Enough Logins available for session {}", tok.id());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,35 @@ AuthSessionManager& session_manager()
|
||||
return mgr;
|
||||
}
|
||||
|
||||
bool requires_auth_session(const admin::BTSUser& user)
|
||||
{
|
||||
//if the user can trade in any account or see market data, it needs a session
|
||||
if(user.has_user_data() &&
|
||||
user.user_data().has_account_permissions() &&
|
||||
user.user_data().account_permissions().account_permissions_size())
|
||||
{
|
||||
for(const auto& i: user.user_data().account_permissions().account_permissions())
|
||||
{
|
||||
if(i.second.has_trading_permission() && i.second.trading_permission().has_permissions())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(user.has_user_data() &&
|
||||
user.user_data().has_exchange_user_data())
|
||||
{
|
||||
if(user.user_data().exchange_user_data().has_cme_data())
|
||||
{
|
||||
for(const auto& i: user.user_data().exchange_user_data().cme_data().md_permissions())
|
||||
{
|
||||
if(i.enabled())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
AuthToken generate_token(const admin::BTSUser& user, std::string* msg)
|
||||
{
|
||||
api::user::TokenPayload payload;
|
||||
@@ -58,7 +87,9 @@ AuthToken generate_token(const admin::BTSUser& user, std::string* msg)
|
||||
payload.set_id(user.id());
|
||||
if(user.name() == "bts")
|
||||
payload.set_wheel(true);
|
||||
session_manager().add_or_replace_session(payload, msg);
|
||||
|
||||
if(requires_auth_session(user))
|
||||
session_manager().add_or_replace_session(payload, msg);
|
||||
auto token = encrypt(payload.SerializeAsString());
|
||||
bts_assert_d(token.size() < 255-8);
|
||||
AuthToken result;
|
||||
|
||||
@@ -155,7 +155,7 @@ void AdminServiceServer::get_filtered_admin_data(
|
||||
const api::Response<AdminData>& reply)
|
||||
{
|
||||
bts::api::user::TokenPayload toke;
|
||||
if(bts::api::auth::decode_token(token, &toke))
|
||||
bts::api::auth::decode_token(token, &toke);
|
||||
{
|
||||
if(toke.wheel())
|
||||
reply(_state);
|
||||
|
||||
@@ -15,7 +15,7 @@ This will test our ability to generate and enforce keycodes.
|
||||
|
||||
You should see keycode details printed to screen
|
||||
|
||||
4) Now test concurrent logins. Start a sparkd.
|
||||
4) Now test concurrent logins. Start a sparkd. Make sure bts_2 and bts_3 have market data permission
|
||||
a) Start a spark -multiple login as bts and go to where you would see some market data
|
||||
b) Start another spark -multiple but log in as bts_2 and display some data
|
||||
c) Start a third spark -multiple, log in as bts_2 and display some data.
|
||||
@@ -37,5 +37,19 @@ You should see keycode details printed to screen
|
||||
d) remove the expired keycode you just generated by:
|
||||
rm ~/sparkdata/conf/keycode.conf
|
||||
e) restart sparkd, you should see data as normal in bts_2
|
||||
|
||||
6) Test admin vs trading logins
|
||||
Note that an admin login is one that does not have trading permission in any account
|
||||
AND does not have the ability to see any market data
|
||||
|
||||
a) start sparkd again. make sure bts_2 and bts_3 have market data and trading permissions in webui
|
||||
b) Start a spark -multiple login as bts_2 and go to where you would see some market data. You should see data
|
||||
c) Start a webui and log in as bts_3, you should see data
|
||||
d) close your shell and log out of web ui, now log in bts_3 into the webui and log in bts_2 in a shell (
|
||||
this is the reverse of the previous order), you should see a message in the shell about keycodes, but it will let you log in, just not see market data
|
||||
e) from the webui, de-permission bts_3 from trading AND market data,
|
||||
f) exit shell, log out of webui and kill sparkd, restart sparkd
|
||||
|
||||
g)now try d again-- you should not get the same shell error
|
||||
|
||||
|
||||
Reference in new issue
Block a user