mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-31 03:56:42 +00:00
~2076 files used "Copyright (C) YYYY-present ScyllaDB" while ~88 files used "Copyright (C) YYYY ScyllaDB". This inconsistency leads to unnecessary code review discussions and gradual spread of the less common format. Standardize all ScyllaDB copyright headers to use -present. Fixes SCYLLADB-1984 Closes scylladb/scylladb#29876
43 lines
869 B
C++
43 lines
869 B
C++
/*
|
|
* Copyright (C) 2025-present ScyllaDB
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.1
|
|
*/
|
|
|
|
#include <seastar/core/coroutine.hh>
|
|
|
|
#include "credentials.hh"
|
|
|
|
logger az_creds_logger("azure_creds");
|
|
|
|
namespace azure {
|
|
|
|
access_token::access_token(const sstring& token, const timestamp_type& expiry, const resource_type& resource_uri)
|
|
: token(token)
|
|
, expiry(expiry)
|
|
, resource_uri(resource_uri)
|
|
{}
|
|
|
|
bool access_token::empty() const {
|
|
return token.empty();
|
|
}
|
|
|
|
bool access_token::expired() const {
|
|
if (empty()) {
|
|
return true;
|
|
}
|
|
return timeout_clock::now() >= this->expiry;
|
|
}
|
|
|
|
future<access_token> credentials::get_access_token(const resource_type& resource_uri) {
|
|
if (_token.expired() || _token.resource_uri != resource_uri) {
|
|
co_await refresh(resource_uri);
|
|
}
|
|
co_return _token;
|
|
}
|
|
|
|
}
|