aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/authutils.cpp
diff options
context:
space:
mode:
authorLiam Mitchell <[email protected]>2026-03-09 18:53:59 -0700
committerGitHub Enterprise <[email protected]>2026-03-09 18:53:59 -0700
commit9d4aea747240f17294d84d6cbbcc057402a0366c (patch)
tree1aa702b53f5ba84b56b5e2e730ecef9f3a20f821 /src/zenutil/authutils.cpp
parentupdated chunk–block analyser (#818) (diff)
parentUpdate changelog (diff)
downloadzen-9d4aea747240f17294d84d6cbbcc057402a0366c.tar.xz
zen-9d4aea747240f17294d84d6cbbcc057402a0366c.zip
Merge pull request #710 from ue-foundation/lm/oidctoken-exe-path
Use well-known OidcToken paths or command line arguments to determine OidcToken executable path
Diffstat (limited to 'src/zenutil/authutils.cpp')
-rw-r--r--src/zenutil/authutils.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/zenutil/authutils.cpp b/src/zenutil/authutils.cpp
new file mode 100644
index 000000000..8ee6b1417
--- /dev/null
+++ b/src/zenutil/authutils.cpp
@@ -0,0 +1,55 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "zenutil/authutils.h"
+#include "zenutil/config/commandlineoptions.h"
+
+#include <zencore/filesystem.h>
+
+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