diff options
| author | Dan Engelbrecht <[email protected]> | 2025-04-02 20:35:53 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-04-02 20:35:53 +0200 |
| commit | f535a53cdda32b2b4950e32901dcd333bea82c23 (patch) | |
| tree | a50181e526db53cc609ac44defcea7609585fd31 /src/zen/cmds/builds_cmd.cpp | |
| parent | Merge branch 'main' of https://github.ol.epicgames.net/ue-foundation/zen (diff) | |
| download | archived-zen-f535a53cdda32b2b4950e32901dcd333bea82c23.tar.xz archived-zen-f535a53cdda32b2b4950e32901dcd333bea82c23.zip | |
use oidctoken executable to generate auth (#336)
- Feature: `zen builds` auth option `--oidctoken-exe-path` to let zen run the OidcToken executable to get and refresh authentication token
Diffstat (limited to 'src/zen/cmds/builds_cmd.cpp')
| -rw-r--r-- | src/zen/cmds/builds_cmd.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/zen/cmds/builds_cmd.cpp b/src/zen/cmds/builds_cmd.cpp index ba2564fad..f6b7299cb 100644 --- a/src/zen/cmds/builds_cmd.cpp +++ b/src/zen/cmds/builds_cmd.cpp @@ -8347,6 +8347,12 @@ BuildsCommand::BuildsCommand() "OAuth client secret", cxxopts::value<std::string>(m_OAuthClientSecret)->default_value(""), ""); + Ops.add_option("auth", + "", + "oidctoken-exe-path", + "Path to OidcToken executable", + cxxopts::value<std::string>(m_OidcTokenAuthExecutablePath)->default_value(""), + ""); }; auto AddCloudOptions = [this, &AddAuthOptions](cxxopts::Options& Ops) { @@ -8750,6 +8756,27 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return {}; }; + auto FindOidcTokenExePath = [](const std::string& OidcTokenAuthExecutablePath) -> std::filesystem::path { + if (OidcTokenAuthExecutablePath.empty()) + { + const std::string OidcExecutableName = "OidcToken" ZEN_EXE_SUFFIX_LITERAL; + std::filesystem::path OidcTokenPath = (GetRunningExecutablePath().parent_path() / OidcExecutableName).make_preferred(); + if (IsFile(OidcTokenPath)) + { + return OidcTokenPath; + } + } + else + { + std::filesystem::path OidcTokenPath = std::filesystem::absolute(StringToPath(OidcTokenAuthExecutablePath)).make_preferred(); + if (IsFile(OidcTokenPath)) + { + return OidcTokenPath; + } + } + return {}; + }; + if (!m_AccessToken.empty()) { ClientSettings.AccessTokenProvider = httpclientauth::CreateFromStaticToken(m_AccessToken); @@ -8776,15 +8803,16 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { ClientSettings.AccessTokenProvider = httpclientauth::CreateFromStaticToken(ResolvedAccessToken); } - else + else if (std::filesystem::path OidcTokenExePath = FindOidcTokenExePath(m_OidcTokenAuthExecutablePath); !OidcTokenExePath.empty()) { - CreateAuthMgr(); - ClientSettings.AccessTokenProvider = httpclientauth::CreateFromDefaultOpenIdProvider(*Auth); + const std::string& CloudHost = m_OverrideHost.empty() ? m_Host : m_OverrideHost; + ClientSettings.AccessTokenProvider = httpclientauth::CreateFromOidcTokenExecutable(OidcTokenExePath, CloudHost); } if (!ClientSettings.AccessTokenProvider) { - ZEN_CONSOLE("Warning: No auth provider given, attempting operation without credentials."); + CreateAuthMgr(); + ClientSettings.AccessTokenProvider = httpclientauth::CreateFromDefaultOpenIdProvider(*Auth); } }; |