From e44934cf1b4783420f5a4c6acbdbac44488d92a9 Mon Sep 17 00:00:00 2001 From: Liam Mitchell Date: Wed, 14 Jan 2026 15:34:57 -0800 Subject: Use well-known OidcToken paths or command line arguments to determine OidcToken executable path --- src/zenutil/authutils.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/zenutil/authutils.cpp (limited to 'src/zenutil/authutils.cpp') diff --git a/src/zenutil/authutils.cpp b/src/zenutil/authutils.cpp new file mode 100644 index 000000000..1db2072cb --- /dev/null +++ b/src/zenutil/authutils.cpp @@ -0,0 +1,55 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include "zenutil/authutils.h" +#include "zenutil/commandlineoptions.h" + +#include + +namespace zen { +using namespace std::literals; + +std::string_view +GetOidcTokenPathEnvVariableName() +{ +#if ZEN_PLATFORM_WINDOWS + return "UE-OidcTokenExePath"sv; +#endif +#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC + return "UE_OidcTokenExePath"sv; +#endif +} + +std::filesystem::path +FindOidcTokenExePath(std::string_view OidcTokenAuthExecutablePath) +{ + if (OidcTokenAuthExecutablePath.empty()) + { + std::filesystem::path OidcTokenPath = GetEnvVariable(GetOidcTokenPathEnvVariableName()); + if (IsFile(OidcTokenPath)) + { + return OidcTokenPath; + } + const std::string OidcExecutableName = "OidcToken" ZEN_EXE_SUFFIX_LITERAL; + OidcTokenPath = (GetRunningExecutablePath().parent_path() / OidcExecutableName).make_preferred(); + if (IsFile(OidcTokenPath)) + { + return OidcTokenPath; + } + OidcTokenPath = (std::filesystem::current_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 {}; +}; + +} // namespace zen -- cgit v1.2.3