diff options
| author | Per Larsson <[email protected]> | 2022-02-07 15:46:51 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-02-07 15:46:51 +0100 |
| commit | 4b3d9873def5e974fd47a5360a3eff4095aab88b (patch) | |
| tree | 23196dba05475cbec6bb6141e08390fcd44d6961 /zenserver/zenserver.cpp | |
| parent | Replaced crypto transform abstraction with a concrete API. (diff) | |
| download | zen-4b3d9873def5e974fd47a5360a3eff4095aab88b.tar.xz zen-4b3d9873def5e974fd47a5360a3eff4095aab88b.zip | |
Refactored auth manager to use simplified encryption API.
Diffstat (limited to 'zenserver/zenserver.cpp')
| -rw-r--r-- | zenserver/zenserver.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index c1a5fe507..fca567f28 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -204,21 +204,38 @@ public: m_Http = zen::CreateHttpServer(ServerOptions.HttpServerClass); int EffectiveBasePort = m_Http->Initialize(ServerOptions.BasePort); - AuthEncryptionKey EncryptionKey; - - if (ServerOptions.EncryptionKey.empty() == false && ServerOptions.EncryptionIV.empty() == false) + // Setup authentication manager { - EncryptionKey = AuthEncryptionKey{.Key = IoBufferBuilder::MakeCloneFromMemory(MakeMemoryView(ServerOptions.EncryptionKey)), - .IV = IoBufferBuilder::MakeCloneFromMemory(MakeMemoryView(ServerOptions.EncryptionIV))}; - }; + std::string EncryptionKey = ServerOptions.EncryptionKey; + + if (EncryptionKey.empty()) + { + EncryptionKey = "abcdefghijklmnopqrstuvxyz0123456"; + + ZEN_WARN("using default encryption key"); + } + + std::string EncryptionIV = ServerOptions.EncryptionIV; + + if (EncryptionIV.empty()) + { + EncryptionIV = "0123456789abcdef"; + + ZEN_WARN("using default encryption initialization vector"); + } + + m_AuthMgr = AuthMgr::Create({.RootDirectory = m_DataRoot / "auth", + .EncryptionKey = AesKey256Bit::FromString(EncryptionKey), + .EncryptionIV = AesIV128Bit::FromString(EncryptionIV)}); + + m_AuthMgr->AddOpenIdProvider({.Name = "Okta"sv, + .Url = "https://epicgames.okta.com/oauth2/auso645ojjWVdRI3d0x7"sv, + .ClientId = "0oapq1knoglGFqQvr0x7"sv}); + } - m_AuthMgr = AuthMgr::Create({.RootDirectory = m_DataRoot / "auth", .EncryptionKey = EncryptionKey}); m_AuthService = std::make_unique<zen::HttpAuthService>(*m_AuthMgr); m_Http->RegisterService(*m_AuthService); - m_AuthMgr->AddOpenIdProvider( - {.Name = "Okta"sv, .Url = "https://epicgames.okta.com/oauth2/auso645ojjWVdRI3d0x7"sv, .ClientId = "0oapq1knoglGFqQvr0x7"sv}); - m_Http->RegisterService(m_HealthService); m_Http->RegisterService(m_StatsService); m_Http->RegisterService(m_StatusService); |