Read public key from config (for login/auth)

This commit is contained in:
John Colvin committed 2022-05-02 12:29:02 -04:00
1 parent bd108dfe35
commit ca3bc5059e
6 files changed
+32 -14

No files matched your search

+3 -12
View File
@@ -6,6 +6,7 @@
#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"
@@ -29,21 +30,11 @@ namespace bts {
namespace api {
namespace auth {
const std::string AuthSessionManager::PUBLIC_KEY =
"-----BEGIN PUBLIC KEY-----\n"
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAseguRgLD88QdhK0agy8f"
"gz3SXp/hmp377+Q+z3OQqGG5kWyKnQfkAQDFeSv8o1iwSQupN0D1QOXyDnV1jmue"
"rqTitasGeq4AwKLhY89O/VuXc+URAO+HZ7EqVWfb3Nv4EOZRiiVsxmVBkld73Rcy"
"UAS4OXh4jDtE8IzOoXB7HhlMPBIAkueqdyy/v9zamzKrxPzWd+IW/IYEdCrUS8ES"
"mxOkeadSHVeH2nlHVREdktE3wKRd3fZ3OkyGaHnUPxBoUW1Ex57BpwdMGUqLZ3W2"
"92yQa/32dsLocoTri4iiImvQ/0JvfhnY9MDTZnmIgb8bPWSvPblQN0RR9OkRDFT9"
"3QIDAQAB"
"\n-----END PUBLIC KEY-----\n";
AuthSessionManager::AuthSessionManager()
: _map(), _nusers(), _expiration(), _concurrent(false) {
const auto &ekc = config::get<config::EncryptedKeyCode>();
auto pub = bts::crypto::PublicKey::read_string(PUBLIC_KEY);
auto pub = bts::crypto::PublicKey::read(config::get<config::PublicKey>());
bts::config::KeyCode kc;
auto valid = bts::crypto::decrypt_keycode(*pub, ekc, &kc);
bts_assert_msg(valid, "Your BTS Keycode is invalid");