CME Template 8
This commit is contained in:
1 parent
51c89fb8cc
commit
cfdca08cfe
125 files changed
+124104
-108912
No files matched your search
@@ -1,20 +1,22 @@
|
||||
#ifndef _WIN32
|
||||
#include "AuthSessionManager.h"
|
||||
|
||||
#include "lib/utils/FileUtils.h"
|
||||
#include "lib/utils/crypto/CryptoInit.h"
|
||||
#include "lib/utils/crypto/KeyCodeHelper.h"
|
||||
#include "lib/utils/crypto/PrivateKey.h"
|
||||
#include "lib/utils/crypto/PublicKey.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/utils/FileUtils.h"
|
||||
|
||||
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/ports.pb.h"
|
||||
#include "lib/config/protos/keycode.pb.h"
|
||||
#include "lib/config/protos/ports.pb.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/utils/helper_macros.h"
|
||||
|
||||
|
||||
#include <google/protobuf/text_format.h>
|
||||
#include <google/protobuf/util/message_differencer.h>
|
||||
#include <sstream>
|
||||
@@ -32,6 +34,9 @@ namespace auth {
|
||||
|
||||
AuthSessionManager::AuthSessionManager()
|
||||
: _map(), _nusers(), _expiration(), _concurrent(false) {
|
||||
LOG(Gen, Info,
|
||||
"AuthSessionManager::cons _nusers: {} _expiration: {} _concurrent: {}",
|
||||
_nusers, _expiration, _concurrent);
|
||||
// const auto &ekc = config::get<config::EncryptedKeyCode>();
|
||||
// auto pub = bts::crypto::PublicKey::read(config::get<config::PublicKey>());
|
||||
|
||||
@@ -45,7 +50,7 @@ AuthSessionManager::AuthSessionManager()
|
||||
// bts_assert_msg(validate_ip_port(kc), "invalid ip or port in keycode");
|
||||
}
|
||||
|
||||
bool AuthSessionManager::validate_ip_port(const bts::config::KeyCode &/*kc*/) {
|
||||
bool AuthSessionManager::validate_ip_port(const bts::config::KeyCode & /*kc*/) {
|
||||
// bool portgood = true;
|
||||
// if (kc.has_port() && kc.port() != "") {
|
||||
// const auto &ports = config::get<config::Ports>();
|
||||
@@ -67,9 +72,9 @@ bool AuthSessionManager::validate_ip_port(const bts::config::KeyCode &/*kc*/) {
|
||||
}
|
||||
|
||||
bool AuthSessionManager::add_or_replace_session(
|
||||
const api::user::TokenPayload &/*tok*/,
|
||||
const std::string &/*username*/,
|
||||
std::string */*msg*/) {
|
||||
const api::user::TokenPayload & /*tok*/,
|
||||
const std::string & /*username*/,
|
||||
std::string * /*msg*/) {
|
||||
// if (tok.wheel())
|
||||
// return true;
|
||||
// if (datetime::ll_diff_in_us(datetime::ll_now(), _expiration) < 0) {
|
||||
@@ -80,15 +85,20 @@ bool AuthSessionManager::add_or_replace_session(
|
||||
// return false;
|
||||
// }
|
||||
// if (msg) {
|
||||
// if (datetime::ll_diff_in_seconds(tok.date(), _expiration) < 86400) // 1d
|
||||
// *msg = "*** YOUR BTS KEYCODE WILL EXPIRE TOMORROW!!, PLEASE CONTACT "
|
||||
// if (datetime::ll_diff_in_seconds(tok.date(), _expiration) < 86400) //
|
||||
// 1d
|
||||
// *msg = "*** YOUR BTS KEYCODE WILL EXPIRE TOMORROW!!, PLEASE CONTACT
|
||||
// "
|
||||
// "sales@bluetradesys.com ***";
|
||||
// else if (
|
||||
// datetime::ll_diff_in_seconds(tok.date(), _expiration) < 259200) // 3d
|
||||
// *msg = "Your BTS Keycode EXPIRES IN LESS THAN 3 DAYS, please contact "
|
||||
// datetime::ll_diff_in_seconds(tok.date(), _expiration) < 259200) //
|
||||
// 3d
|
||||
// *msg = "Your BTS Keycode EXPIRES IN LESS THAN 3 DAYS, please contact
|
||||
// "
|
||||
// "sales@bluetradesys.com";
|
||||
// else if (
|
||||
// datetime::ll_diff_in_seconds(tok.date(), _expiration) < 432000) // 5d
|
||||
// datetime::ll_diff_in_seconds(tok.date(), _expiration) < 432000) //
|
||||
// 5d
|
||||
// *msg = "Your BTS Keycode expires in less than one week, please "
|
||||
// "contact sales@bluetradesys.com";
|
||||
// }
|
||||
@@ -108,19 +118,21 @@ bool AuthSessionManager::add_or_replace_session(
|
||||
// if (msg)
|
||||
// *msg = "KEYCODES: Not Enough Logins available for session";
|
||||
// LOG(User, Error,
|
||||
// "KEYCODES: Not Enough Logins available for session {} user:{}", tok.id(),
|
||||
// username);
|
||||
// "KEYCODES: Not Enough Logins available for session {} user:{}",
|
||||
// tok.id(), username);
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AuthSessionManager::check_session(const api::user::TokenPayload &/*tok*/) {
|
||||
bool AuthSessionManager::check_session(
|
||||
const api::user::TokenPayload & /*tok*/) {
|
||||
// if (tok.wheel())
|
||||
// return true;
|
||||
// if (datetime::ll_diff_in_us(datetime::ll_now(), _expiration) > 0) {
|
||||
// auto it = _map.find(tok.id());
|
||||
// if (it != _map.end()) {
|
||||
// // return google::protobuf::util::MessageDifferencer::Equivalent(tok,
|
||||
// // return
|
||||
// google::protobuf::util::MessageDifferencer::Equivalent(tok,
|
||||
// // it->second.token) //this is probably slow
|
||||
// bool not_expired =
|
||||
// datetime::ll_diff_in_us(tok.date(), _expiration) > 0;
|
||||
|
||||
Reference in new issue
Block a user