-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove grpc dependency leak through iam headers
- Loading branch information
1 parent
07e05c9
commit 982180d
Showing
12 changed files
with
191 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
#pragma once | ||
|
||
#include "common/iam.h" | ||
#include "types.h" | ||
namespace NYdb { | ||
|
||
/// Acquire an IAM token using a local metadata service on a virtual machine. | ||
TCredentialsProviderFactoryPtr CreateIamCredentialsProviderFactory(const TIamHost& params = {}); | ||
|
||
/// Acquire an IAM token using a JSON Web Token (JWT) file name. | ||
TCredentialsProviderFactoryPtr CreateIamJwtFileCredentialsProviderFactory(const TIamJwtFilename& params); | ||
|
||
/// Acquire an IAM token using JSON Web Token (JWT) contents. | ||
TCredentialsProviderFactoryPtr CreateIamJwtParamsCredentialsProviderFactory(const TIamJwtContent& param); | ||
|
||
// Acquire an IAM token using a user OAuth token. | ||
TCredentialsProviderFactoryPtr CreateIamOAuthCredentialsProviderFactory(const TIamOAuth& params); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <ydb-cpp-sdk/client/types/credentials/credentials.h> | ||
#include <ydb-cpp-sdk/library/jwt/jwt.h> | ||
|
||
#include <util/datetime/base.h> | ||
|
||
#include <fstream> | ||
#include <string> | ||
|
||
namespace NYdb { | ||
|
||
namespace NIam { | ||
|
||
constexpr std::string_view DEFAULT_ENDPOINT = "iam.api.cloud.yandex.net"; | ||
constexpr bool DEFAULT_ENABLE_SSL = true; | ||
|
||
constexpr std::string_view DEFAULT_HOST = "169.254.169.254"; | ||
constexpr uint32_t DEFAULT_PORT = 80; | ||
|
||
constexpr TDuration DEFAULT_REFRESH_PERIOD = TDuration::Hours(1); | ||
constexpr TDuration DEFAULT_REQUEST_TIMEOUT = TDuration::Seconds(10); | ||
|
||
} | ||
|
||
struct TIamHost { | ||
std::string Host = std::string(NIam::DEFAULT_HOST); | ||
uint32_t Port = NIam::DEFAULT_PORT; | ||
TDuration RefreshPeriod = NIam::DEFAULT_REFRESH_PERIOD; | ||
}; | ||
|
||
struct TIamEndpoint { | ||
std::string Endpoint = std::string(NIam::DEFAULT_ENDPOINT); | ||
TDuration RefreshPeriod = NIam::DEFAULT_REFRESH_PERIOD; | ||
TDuration RequestTimeout = NIam::DEFAULT_REQUEST_TIMEOUT; | ||
bool EnableSsl = NIam::DEFAULT_ENABLE_SSL; | ||
}; | ||
|
||
struct TIamJwtFilename : TIamEndpoint { std::string JwtFilename; }; | ||
|
||
struct TIamJwtContent : TIamEndpoint { std::string JwtContent; }; | ||
|
||
struct TIamJwtParams : TIamEndpoint { TJwtParams JwtParams; }; | ||
|
||
struct TIamOAuth : TIamEndpoint { std::string OAuthToken; }; | ||
|
||
|
||
inline TJwtParams ReadJwtKeyFile(const std::string& filename) { | ||
std::ifstream input(filename, std::ios::in); | ||
return ParseJwtParams({std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>()}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
_ydb_sdk_add_library(client-iam-common) | ||
_ydb_sdk_add_library(client-iam-common INTERFACE) | ||
|
||
target_link_libraries(client-iam-common PUBLIC | ||
yutil | ||
grpc-client | ||
http-simple | ||
json | ||
library-jwt | ||
client-ydb_types-credentials | ||
api-client-yc_public | ||
target_link_libraries(client-iam-common | ||
INTERFACE | ||
client-ydb_types-credentials | ||
grpc-client | ||
library-jwt | ||
threading-future | ||
yutil | ||
) | ||
|
||
target_sources(client-iam-common PRIVATE | ||
iam.cpp | ||
) | ||
|
||
_ydb_sdk_make_client_component(Iam client-iam-common) | ||
_ydb_sdk_install_targets(client-iam-common) |
This file was deleted.
Oops, something went wrong.
59 changes: 3 additions & 56 deletions
59
include/ydb-cpp-sdk/client/iam/common/iam.h → src/client/iam/common/iam.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.