-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Keyring - Start Store and Keyring * Keyring - Implement Store * All - Cleanup * Keyring - Make Store Thread Safe * Revert "All - Cleanup" This reverts commit 7f4292b. * Keyring - Keyring Implementation * Keyring - Better SystemCredentials API * Keyring - Fix Linux Build * Keyring - Blank KeyringDialogController + Enum Flag Macros * Update appinfo.cpp * All - Cleanup * All - Don't Use Optional Everywhere + Ensure Thread Safety * Keyring - Better Store and Keyring Handling * Keyring - Store Overload = * All - Add gtest * Keyring - Implement KeyringDialogController * Update .gitattributes * Update .gitattributes
- Loading branch information
Showing
28 changed files
with
1,011 additions
and
99 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,2 +1,9 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
* text eol=lf | ||
*.c eol=crlf | ||
*.json eol=crlf | ||
*.png binary | ||
*.jpg binary | ||
*.ico binary | ||
*.pdf binary | ||
*.exe binary |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ maddy/1.3.0 | |
sqlcipher/4.5.1 | ||
sqlitecpp/3.3.1 | ||
libsecret/0.20.5 | ||
gtest/1.14.0 | ||
|
||
[generators] | ||
CMakeDeps | ||
|
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ libcurl/8.4.0 | |
maddy/1.3.0 | ||
sqlcipher/4.5.1 | ||
sqlitecpp/3.3.1 | ||
gtest/1.14.0 | ||
|
||
[generators] | ||
CMakeDeps | ||
|
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef ENUMFLAGS_H | ||
#define ENUMFLAGS_H | ||
|
||
#define DEFINE_ENUM_FLAG_OPERATORS(T) \ | ||
inline T operator~(T a) \ | ||
{ \ | ||
return (T)~(int)a; \ | ||
} \ | ||
inline T operator|(T a, T b) \ | ||
{ \ | ||
return (T)((int)a | (int)b); \ | ||
} \ | ||
inline T operator&(T a, T b) \ | ||
{ \ | ||
return (T)((int)a & (int)b); \ | ||
} \ | ||
inline T operator^(T a, T b) \ | ||
{ \ | ||
return (T)((int)a ^ (int)b); \ | ||
} \ | ||
inline T& operator|=(T& a, T b) \ | ||
{ \ | ||
return (T&)((int&)a |= (int)b); \ | ||
} \ | ||
inline T& operator&=(T& a, T b) \ | ||
{ \ | ||
return (T&)((int&)a &= (int)b); \ | ||
} \ | ||
inline T& operator^=(T& a, T b) \ | ||
{ \ | ||
return (T&)((int&)a ^= (int)b); \ | ||
} \ | ||
|
||
#endif //ENUMFLAGS_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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef CREDENTIALCHECKSTATUS_H | ||
#define CREDENTIALCHECKSTATUS_H | ||
|
||
#include "enumflags.h" | ||
|
||
namespace Nickvision::Aura::Keyring | ||
{ | ||
/** | ||
* @brief Flags to describe the status of a validated credential | ||
*/ | ||
enum class CredentialCheckStatus | ||
{ | ||
Valid = 1, | ||
EmptyName = 2, | ||
EmptyUsernamePassword = 4, | ||
InvalidUri = 8 | ||
}; | ||
|
||
DEFINE_ENUM_FLAG_OPERATORS(CredentialCheckStatus); | ||
} | ||
|
||
#endif //CREDENTIALCHECKSTATUS_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#ifndef KEYRING_H | ||
#define KEYRING_H | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <vector> | ||
#include "credential.h" | ||
#include "store.h" | ||
|
||
namespace Nickvision::Aura::Keyring | ||
{ | ||
/** | ||
* @brief A model of a keyring object for managing credentials. | ||
*/ | ||
class Keyring | ||
{ | ||
public: | ||
/** | ||
* @brief Gets the name of the keyring. | ||
* @return The name of the keyring | ||
*/ | ||
const std::string& getName() const; | ||
/** | ||
* @brief Gets all credentials in the keyring. | ||
* @return The list of all credentials | ||
*/ | ||
std::vector<Credential> getAllCredentials() const; | ||
/** | ||
* @brief Gets the credential matching the provided id. | ||
* @param id The id of the credential | ||
* @return The credential matching the id, std::nullopt if no matching credential | ||
*/ | ||
std::optional<Credential> getCredential(int id) const; | ||
/** | ||
* @brief Gets the credentials containing the provided name. | ||
* @param name The name | ||
* @return The list of credentials matching the name | ||
*/ | ||
std::vector<Credential> getCredentials(const std::string& name) const; | ||
/** | ||
* @brief Adds a credential to the keyring. | ||
* @param credential The Credential to add | ||
* @return True if successful, else false | ||
*/ | ||
bool addCredential(const Credential& credential); | ||
/** | ||
* @brief Updates a credential in the keyring. | ||
* @param credential The Credential to update | ||
* @return True if successful, else false | ||
*/ | ||
bool updateCredential(const Credential& credential); | ||
/** | ||
* @brief Deletes a credential from the keyring. | ||
* @param id The id of the credential to delete | ||
* @return True if successful, else false | ||
*/ | ||
bool deleteCredential(int id); | ||
/** | ||
* @brief Destroys the keyring and all of its data from disk. Once this method is called, the object should no longer be referenced, with or without success. | ||
* @return True if successful, else false | ||
*/ | ||
bool destroy(); | ||
|
||
private: | ||
Keyring(const Store& store); | ||
Store m_store; | ||
|
||
public: | ||
/** | ||
* @brief Accesses a Keyring. The Keyring will first attempt to load the Store. If the Store doesn't exist, it will create a new Store. | ||
* @param name The name of the store | ||
* @param password The password to use for the store. If empty, the password will be fetched/created from the system's credential store | ||
* @return The newly accessed keyring, std::nullopt if accessing failed | ||
*/ | ||
static std::optional<Keyring> access(const std::string& name, std::string password = ""); | ||
/** | ||
* @brief Gets whether or not a keyring exists with the provided name. | ||
* @param name The name of the keyring to check | ||
* @return True if a keyring with the provied name exists, else false | ||
*/ | ||
static bool exists(const std::string& name); | ||
/** | ||
* @brief Destroys a keyring and all of its data from disk. | ||
* @param The name of the keyring to destroy | ||
* @return True if successful, else false | ||
*/ | ||
static bool destroy(const std::string& name); | ||
|
||
private: | ||
|
||
}; | ||
} | ||
|
||
#endif //KEYRING_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#ifndef KEYRINGDIALOGCONTROLLER_H | ||
#define KEYRINGDIALOGCONTROLLER_H | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <vector> | ||
#include "credential.h" | ||
#include "credentialcheckstatus.h" | ||
#include "keyring.h" | ||
|
||
namespace Nickvision::Aura::Keyring | ||
{ | ||
class KeyringDialogController | ||
{ | ||
public: | ||
/** | ||
* @brief Constructs a KeyringDialogController. | ||
* @param name The name of the controller | ||
* @param keyring The keyring managed by the controller, if available | ||
*/ | ||
KeyringDialogController(const std::string& name, const std::optional<Keyring>& keyring); | ||
/** | ||
* @brief Gets the keyring managed by the controller, if available. | ||
* @return The keyring if available, else std::nullopt | ||
*/ | ||
const std::optional<Keyring>& getKeyring(); | ||
/** | ||
* @brief Gets whether or not the keyring is enabled (unlocked). | ||
* @retrun True if enabled, else false | ||
*/ | ||
bool isEnabled() const; | ||
/** | ||
* @brief Gets whether or not the keyring state is valid. | ||
* @return True if valid, else false | ||
*/ | ||
bool isValid() const; | ||
/** | ||
* @brief Enables the keyring. | ||
* @param password The password of the keyring | ||
* @return True if successful, else false | ||
*/ | ||
bool enableKeyring(const std::string& password = ""); | ||
/** | ||
* @brief Disables the keyring and destroys its data. | ||
* @return True if successful, else false | ||
*/ | ||
bool disableKeyring(); | ||
/** | ||
* @brief Resets the keyring and destroys its data. To be used only if the keyring is locked. If unlocked, use disableKeyring() . | ||
* @return True if successful, else false | ||
*/ | ||
bool resetKeyring(); | ||
/** | ||
* @brief Validates a Credential object. | ||
* @param credential The credential to validate | ||
* @return CredentialCheckStatus | ||
*/ | ||
CredentialCheckStatus validateCredential(const Credential& credential) const; | ||
/** | ||
* @brief Gets all credentials in the keyring. | ||
* @return The list of all credentials | ||
*/ | ||
std::vector<Credential> getAllCredentials() const; | ||
/** | ||
* @brief Adds a credential to the keyring. | ||
* @param credential The Credential to add | ||
* @return True if successful, else false | ||
*/ | ||
bool addCredential(const Credential& credential); | ||
/** | ||
* @brief Updates a credential in the keyring. | ||
* @param credential The Credential to update | ||
* @return True if successful, else false | ||
*/ | ||
bool updateCredential(const Credential& credential); | ||
/** | ||
* @brief Deletes a credential from the keyring. | ||
* @param id The id of the credential to delete | ||
* @return True if successful, else false | ||
*/ | ||
bool deleteCredential(int id); | ||
|
||
private: | ||
std::string m_name; | ||
std::optional<Keyring> m_keyring; | ||
}; | ||
} | ||
|
||
#endif //KEYRINGDIALOGCONTROLLER_H |
Oops, something went wrong.