diff options
| author | Per Larsson <[email protected]> | 2022-02-02 16:56:38 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-02-02 16:56:38 +0100 |
| commit | 5b7c068b482b563443320453064fe5fa5601d446 (patch) | |
| tree | 3309bc01ef5ab2f4d08580b5e6c1098c6b45570b /zenserver/zenserver.cpp | |
| parent | Parse expire time from OpenID refresh token and added OpenId token provider. (diff) | |
| download | zen-5b7c068b482b563443320453064fe5fa5601d446.tar.xz zen-5b7c068b482b563443320453064fe5fa5601d446.zip | |
Added upstream auth config and removed the possibility to add endpoints via REST.
Diffstat (limited to 'zenserver/zenserver.cpp')
| -rw-r--r-- | zenserver/zenserver.cpp | 80 |
1 files changed, 20 insertions, 60 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 8d408eb90..c8ee024fb 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -742,66 +742,26 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) // Jupiter upstream { - zen::CloudCacheClientOptions Options; - std::unique_ptr<CloudCacheTokenProvider> TokenProvider; - std::string EndpointName; - std::string Url; - - if (UpstreamConfig.JupiterConfig.UseProductionSettings || UpstreamConfig.JupiterConfig.UseDevelopmentSettings) - { - EndpointName = "Jupiter-Dev"; - Url = "https://jupiter.devtools-dev.epicgames.com"; - - if (UpstreamConfig.JupiterConfig.UseProductionSettings) - { - EndpointName = "Jupiter-Prod"; - Url = "https://jupiter.devtools.epicgames.com"; - } - - TokenProvider = CloudCacheTokenProvider::MakeFromOAuthClientCredentials( - {.Url = "https://epicgames.okta.com/oauth2/auso645ojjWVdRI3d0x7/v1/token"sv, - .ClientId = "0oao91lrhqPiAlaGD0x7"sv, - .ClientSecret = "-GBWjjenhCgOwhxL5yBKNJECVIoDPH0MK4RDuN7d"sv}); - - Options = - zen::CloudCacheClientOptions{.Name = EndpointName, - .ServiceUrl = Url, - .DdcNamespace = "ue.ddc"sv, - .BlobStoreNamespace = "ue.ddc"sv, - .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), - .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds), - .UseLegacyDdc = false}; - } - else - { - EndpointName = UpstreamConfig.JupiterConfig.Name.empty() ? "Jupiter"sv : UpstreamConfig.JupiterConfig.Name; - - TokenProvider = CloudCacheTokenProvider::MakeFromOAuthClientCredentials( - {.Url = "https://epicgames.okta.com/oauth2/auso645ojjWVdRI3d0x7/v1/token"sv, - .ClientId = "0oao91lrhqPiAlaGD0x7"sv, - .ClientSecret = "-GBWjjenhCgOwhxL5yBKNJECVIoDPH0MK4RDuN7d"sv}); - - Options = - zen::CloudCacheClientOptions{.Name = EndpointName, - .ServiceUrl = UpstreamConfig.JupiterConfig.Url, - .DdcNamespace = UpstreamConfig.JupiterConfig.DdcNamespace, - .BlobStoreNamespace = UpstreamConfig.JupiterConfig.Namespace, - .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), - .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds), - .UseLegacyDdc = false}; - } - - if (!Options.ServiceUrl.empty()) - { - TokenProvider = CloudCacheTokenProvider::MakeFromCallback([this]() { - AuthMgr::OpenIdAccessToken Token = m_AuthMgr->GetOpenIdAccessToken("Okta"sv); - return CloudCacheAccessToken{.Value = Token.AccessToken, .ExpireTime = Token.ExpireTime}; - }); - - std::unique_ptr<zen::UpstreamEndpoint> JupiterEndpoint = - zen::MakeJupiterUpstreamEndpoint(Options, std::move(TokenProvider), *m_AuthMgr); - m_UpstreamCache->RegisterEndpoint(std::move(JupiterEndpoint)); - } + std::string_view EndpointName = UpstreamConfig.JupiterConfig.Name.empty() ? "Jupiter"sv : UpstreamConfig.JupiterConfig.Name; + + auto Options = + zen::CloudCacheClientOptions{.Name = EndpointName, + .ServiceUrl = UpstreamConfig.JupiterConfig.Url, + .DdcNamespace = UpstreamConfig.JupiterConfig.DdcNamespace, + .BlobStoreNamespace = UpstreamConfig.JupiterConfig.Namespace, + .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds), + .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds), + .UseLegacyDdc = false}; + + auto AuthConfig = zen::UpstreamAuthConfig{.OAuthUrl = UpstreamConfig.JupiterConfig.OAuthUrl, + .OAuthClientId = UpstreamConfig.JupiterConfig.OAuthClientId, + .OAuthClientSecret = UpstreamConfig.JupiterConfig.OAuthClientSecret, + .OpenIdProvider = UpstreamConfig.JupiterConfig.OpenIdProvider, + .AccessToken = UpstreamConfig.JupiterConfig.AccessToken}; + + std::unique_ptr<zen::UpstreamEndpoint> JupiterEndpoint = zen::MakeJupiterUpstreamEndpoint(Options, AuthConfig, *m_AuthMgr); + + m_UpstreamCache->RegisterEndpoint(std::move(JupiterEndpoint)); } } |