Skip to content

Commit

Permalink
Complete Database implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
abedra committed May 25, 2020
1 parent ac50f00 commit 4024f3a
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.9)
project(vault VERSION 0.15.0 DESCRIPTION "Vault library for C++")
project(vault VERSION 0.16.0 DESCRIPTION "Vault library for C++")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img src="https://img.shields.io/lgtm/alerts/g/abedra/libvault" alt="Total alerts"/>
</a>
![LGTM Grade](https://img.shields.io/lgtm/grade/cpp/github/abedra/libvault)
[![Version](https://img.shields.io/badge/version-0.15.0-4a8fff)](https://img.shields.io/badge/version-0.15.0-4a8fff)
[![Version](https://img.shields.io/badge/version-0.16.0-4a8fff)](https://img.shields.io/badge/version-0.16.0-4a8fff)

A C++ library for [Hashicorp Vault](https://www.vaultproject.io/)

Expand Down Expand Up @@ -77,14 +77,14 @@ The following tables show support for each of the secret backends, auth methods,
| RabbitMQ | Yes | Partial |
| Transit | Yes | Partial |
| PKI | Yes | Partial |
| PostgreSQL | Partial | Partial |
| Cassandra | Partial | No |
| Elasticsearch | Partial | No |
| Influxdb | Partial | No |
| HanaDB | Partial | No |
| MSSQL | Partial | No |
| MySQL/MariaDB | Partial | No |
| Oracle | Partial | No |
| PostgreSQL | Yes | Partial |
| Cassandra | Yes | No |
| Elasticsearch | Yes | No |
| Influxdb | Yes | No |
| HanaDB | Yes | No |
| MSSQL | Yes | No |
| MySQL/MariaDB | Yes | No |
| Oracle | Yes | No |
| Active Directory | No | No |
| Ali Cloud | No | No |
| AWS | No | No |
Expand Down
13 changes: 13 additions & 0 deletions include/VaultClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,22 @@ namespace Vault {
explicit Database(const Client &client) : client_(client) {}

std::optional<std::string> configureConnection(const Path &path, const Parameters &parameters);
std::optional<std::string> readConnection(const Path &path);
std::optional<std::string> listConnections();
std::optional<std::string> deleteConnection(const Path &path);
std::optional<std::string> resetConnection(const Path &path);
std::optional<std::string> rotateRootCredentials(const Path &path);
std::optional<std::string> createRole(const Path &path, const Parameters &parameters);
std::optional<std::string> readRole(const Path &path);
std::optional<std::string> listRoles();
std::optional<std::string> deleteRole(const Path &path);
std::optional<std::string> generateCredentials(const Path &path);
std::optional<std::string> createStaticRole(const Path &path, const Parameters &parameters);
std::optional<std::string> readStaticRole(const Path &path);
std::optional<std::string> listStaticRoles();
std::optional<std::string> deleteStaticRole(const Path &path);
std::optional<std::string> getStaticCredentials(const Path &path);
std::optional<std::string> rotateStaticCredentials(const Path &path);

private:
Url getUrl(const Path &path);
Expand Down
60 changes: 56 additions & 4 deletions src/engines/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,70 @@ std::optional<std::string> Vault::Database::configureConnection(const Path &path
return HttpConsumer::post(client_, getUrl(Vault::Path{"config/" + path}), parameters);
}

std::optional<std::string> Vault::Database::readConnection(const Path &path) {
return HttpConsumer::get(client_, getUrl(Path{"config/" + path}));
}

std::optional<std::string> Vault::Database::listConnections() {
return HttpConsumer::list(client_, getUrl(Path{"config"}));
}

std::optional<std::string> Vault::Database::deleteConnection(const Path &path) {
return HttpConsumer::del(client_, getUrl(Path{"config/" + path}));
}

std::optional<std::string> Vault::Database::resetConnection(const Path &path) {
return HttpConsumer::post(client_, getUrl(Path{"reset/" + path}), Parameters{});
}

std::optional<std::string> Vault::Database::rotateRootCredentials(const Path &path) {
return HttpConsumer::post(client_, getUrl(Path{"rotate-root/" + path}), Parameters{});
}

std::optional<std::string> Vault::Database::createRole(const Path &path, const Parameters &parameters) {
return HttpConsumer::post(client_, getUrl(Vault::Path{"roles/" + path}), parameters);
return HttpConsumer::post(client_, getUrl(Vault::Path{"roles/" + path}), parameters);
}

std::optional<std::string> Vault::Database::readRole(const Path &path) {
return HttpConsumer::get(client_, getUrl(Path{"roles/" + path}));
}

std::optional<std::string> Vault::Database::listRoles() {
return HttpConsumer::list(client_, getUrl(Path{"roles"}));
}

std::optional<std::string> Vault::Database::deleteRole(const Path &path) {
return HttpConsumer::del(client_, getUrl(Vault::Path{"roles/" + path}));
return HttpConsumer::del(client_, getUrl(Vault::Path{"roles/" + path}));
}

std::optional<std::string> Vault::Database::generateCredentials(const Path &path) {
return HttpConsumer::get(client_, getUrl(Vault::Path{"creds/" + path}));
return HttpConsumer::get(client_, getUrl(Vault::Path{"creds/" + path}));
}

std::optional<std::string> Vault::Database::createStaticRole(const Path &path, const Parameters &parameters) {
return HttpConsumer::post(client_, getUrl(Path{"static-roles/" + path}), parameters);
}

std::optional<std::string> Vault::Database::readStaticRole(const Path &path) {
return HttpConsumer::get(client_, getUrl(Path{"static-roles/" + path}));
}

std::optional<std::string> Vault::Database::listStaticRoles() {
return HttpConsumer::list(client_, getUrl(Path{"static-roles"}));
}

std::optional<std::string> Vault::Database::deleteStaticRole(const Path &path) {
return HttpConsumer::del(client_, getUrl(Path{"static-roles/" + path}));
}

std::optional<std::string> Vault::Database::getStaticCredentials(const Path &path) {
return HttpConsumer::get(client_, getUrl(Path{"static-creds/" + path}));
}

std::optional<std::string> Vault::Database::rotateStaticCredentials(const Path &path) {
return HttpConsumer::post(client_, getUrl(Path{"rotate-role/" + path}), Parameters{});
}

Vault::Url Vault::Database::getUrl(const Path &path) {
return client_.getUrl("/v1/database/", path);
return client_.getUrl("/v1/database/", path);
}

0 comments on commit 4024f3a

Please sign in to comment.