aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpclientauth.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenhttp/httpclientauth.cpp')
-rw-r--r--src/zenhttp/httpclientauth.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/zenhttp/httpclientauth.cpp b/src/zenhttp/httpclientauth.cpp
index 39efe1d0c..62e1b77bc 100644
--- a/src/zenhttp/httpclientauth.cpp
+++ b/src/zenhttp/httpclientauth.cpp
@@ -89,14 +89,25 @@ namespace zen { namespace httpclientauth {
static HttpClientAccessToken GetOidcTokenFromExe(const std::filesystem::path& OidcExecutablePath,
std::string_view CloudHost,
- bool Unattended)
+ bool Unattended,
+ bool Quiet)
{
Stopwatch Timer;
CreateProcOptions ProcOptions;
+ if (Quiet)
+ {
+ ProcOptions.StdoutFile = std::filesystem::temp_directory_path() / fmt::format(".zen-auth-output-{}", Oid::NewOid());
+ }
const std::filesystem::path AuthTokenPath(std::filesystem::temp_directory_path() / fmt::format(".zen-auth-{}", Oid::NewOid()));
- auto _ = MakeGuard([AuthTokenPath]() { RemoveFile(AuthTokenPath); });
+ auto _ = MakeGuard([AuthTokenPath, &ProcOptions]() {
+ RemoveFile(AuthTokenPath);
+ if (!ProcOptions.StdoutFile.empty())
+ {
+ RemoveFile(ProcOptions.StdoutFile);
+ }
+ });
const std::string ProcArgs = fmt::format("{} --AuthConfigUrl {} --OutFile {} --Unattended={}",
OidcExecutablePath,
@@ -164,13 +175,15 @@ namespace zen { namespace httpclientauth {
}
std::optional<std::function<HttpClientAccessToken()>> CreateFromOidcTokenExecutable(const std::filesystem::path& OidcExecutablePath,
- std::string_view CloudHost)
+ std::string_view CloudHost,
+ bool Quiet)
{
- HttpClientAccessToken InitialToken = GetOidcTokenFromExe(OidcExecutablePath, CloudHost, false);
+ HttpClientAccessToken InitialToken = GetOidcTokenFromExe(OidcExecutablePath, CloudHost, /* Unattended */ false, Quiet);
if (InitialToken.IsValid())
{
return [OidcExecutablePath = std::filesystem::path(OidcExecutablePath),
CloudHost = std::string(CloudHost),
+ Quiet,
InitialToken]() mutable {
if (InitialToken.IsValid())
{
@@ -178,7 +191,7 @@ namespace zen { namespace httpclientauth {
InitialToken = {};
return Result;
}
- return GetOidcTokenFromExe(OidcExecutablePath, CloudHost, true);
+ return GetOidcTokenFromExe(OidcExecutablePath, CloudHost, /* Unattended */ true, Quiet);
};
}
return {};