diff options
| author | Stefan Boberg <[email protected]> | 2026-03-18 22:41:38 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-03-18 22:41:38 +0100 |
| commit | d48a83be4e75d5726cbd37274705b1c5ce7e625d (patch) | |
| tree | 208811d25ecabff8a8695544bc93ffd1d0a12fbf /src/zenhttp/httpclientauth.cpp | |
| parent | Remove IgnoreChildSignals() from zenserver main (diff) | |
| parent | improve auth token refresh (#863) (diff) | |
| download | zen-sb/pipes.tar.xz zen-sb/pipes.zip | |
Merge branch 'main' into sb/pipessb/pipes
Diffstat (limited to 'src/zenhttp/httpclientauth.cpp')
| -rw-r--r-- | src/zenhttp/httpclientauth.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/zenhttp/httpclientauth.cpp b/src/zenhttp/httpclientauth.cpp index 02e1b57e2..6a3f18b7a 100644 --- a/src/zenhttp/httpclientauth.cpp +++ b/src/zenhttp/httpclientauth.cpp @@ -33,8 +33,7 @@ namespace zen { namespace httpclientauth { std::function<HttpClientAccessToken()> CreateFromStaticToken(std::string_view Token) { - return CreateFromStaticToken( - HttpClientAccessToken{.Value = fmt::format("Bearer {}"sv, Token), .ExpireTime = HttpClientAccessToken::TimePoint::max()}); + return CreateFromStaticToken(HttpClientAccessToken(fmt::format("Bearer {}"sv, Token), HttpClientAccessToken::TimePoint::max())); } std::function<HttpClientAccessToken()> CreateFromOAuthClientCredentials(const OAuthClientCredentialsParams& Params) @@ -74,7 +73,7 @@ namespace zen { namespace httpclientauth { int64_t ExpiresInSeconds = static_cast<int64_t>(Json["expires_in"].int_value()); HttpClientAccessToken::TimePoint ExpireTime = HttpClientAccessToken::Clock::now() + seconds(ExpiresInSeconds); - return HttpClientAccessToken{.Value = fmt::format("Bearer {}"sv, Token), .ExpireTime = ExpireTime}; + return HttpClientAccessToken(fmt::format("Bearer {}"sv, Token), ExpireTime); }; } @@ -82,7 +81,7 @@ namespace zen { namespace httpclientauth { { return [&AuthManager = AuthManager, OpenIdProvider = std::string(OpenIdProvider)]() { AuthMgr::OpenIdAccessToken Token = AuthManager.GetOpenIdAccessToken(OpenIdProvider); - return HttpClientAccessToken{.Value = Token.AccessToken, .ExpireTime = Token.ExpireTime}; + return HttpClientAccessToken(Token.AccessToken, Token.ExpireTime); }; } @@ -172,7 +171,7 @@ namespace zen { namespace httpclientauth { HttpClientAccessToken::TimePoint ExpireTime = std::chrono::system_clock::from_time_t(UTCTime); ExpireTime += std::chrono::milliseconds(Millisecond); - return HttpClientAccessToken{.Value = fmt::format("Bearer {}"sv, Token), .ExpireTime = ExpireTime}; + return HttpClientAccessToken(fmt::format("Bearer {}"sv, Token), ExpireTime); } else { @@ -192,16 +191,15 @@ namespace zen { namespace httpclientauth { { return [OidcExecutablePath = std::filesystem::path(OidcExecutablePath), CloudHost = std::string(CloudHost), + Token = InitialToken, Quiet, - Hidden, - InitialToken]() mutable { - if (InitialToken.IsValid()) + Unattended, + Hidden]() mutable { + if (!Token.NeedsRefresh()) { - HttpClientAccessToken Result = InitialToken; - InitialToken = {}; - return Result; + return std::move(Token); } - return GetOidcTokenFromExe(OidcExecutablePath, CloudHost, /* Unattended */ true, Quiet, Hidden); + return GetOidcTokenFromExe(OidcExecutablePath, CloudHost, Unattended, Quiet, Hidden); }; } return {}; |