Passwords are now saved in a password manager.

The password manager uses strong encryption using a key derived from the passphrase using
scrypt key strengthening algorithm. This ensures encryption is performed using a strong key
and that brute forcing the passphrase is time consuming.

If the user loses his passphrase no recovery is possible.
This commit is contained in:
eelke 2018-11-08 21:50:49 +01:00
parent 2230a4bd61
commit e36924c087
27 changed files with 605 additions and 346 deletions

View file

@ -258,6 +258,19 @@ const char * const * ConnectionConfig::getValues() const
return m_values.data();
}
PasswordState ConnectionConfig::passwordState() const
{
return m_passwordState;
}
void ConnectionConfig::setPasswordState(PasswordState password_state)
{
if (m_passwordState != password_state) {
m_dirty = true;
m_passwordState = password_state;
}
}
bool ConnectionConfig::isSameDatabase(const ConnectionConfig &rhs) const
{
return m_host == rhs.m_host

View file

@ -15,10 +15,10 @@ enum class SslMode {
verify_full=5
};
enum class PasswordMode {
Unsave,
Encrypted,
DontSave
enum class PasswordState {
NotNeeded, ///< the Connection doesn't require a password
NotStored, ///< password needed but we do not know it
SavedPasswordManager, ///< Saved in the password manager
};
class QProcessEnvironment;
@ -70,6 +70,9 @@ public:
const char * const * getKeywords() const;
const char * const * getValues() const;
PasswordState passwordState() const;
void setPasswordState(PasswordState password_state);
bool isSameDatabase(const ConnectionConfig &rhs) const;
void writeToEnvironment(QProcessEnvironment &env) const;
@ -84,7 +87,7 @@ private:
std::string m_port = "5432";
std::string m_user;
std::string m_password;
std::string m_password; ///< TODO do we want to keep this here or should we remember it seperatly?
std::string m_dbname;
std::string m_sslMode;
@ -94,9 +97,11 @@ private:
std::string m_sslCrl;
std::string m_applicationName;
PasswordState m_passwordState = PasswordState::NotStored;
bool m_dirty = false;
static void strToEnv(QProcessEnvironment &env, const QString &var, const std::string &val);
static std::vector<const char*> s_keywords;

View file

@ -74,9 +74,9 @@ std::vector<PgConstraint> PgConstraintContainer::getConstraintsForRelation(Oid r
return result;
}
boost::optional<PgConstraint> PgConstraintContainer::getPrimaryForRelation(Oid relid) const
std::optional<PgConstraint> PgConstraintContainer::getPrimaryForRelation(Oid relid) const
{
boost::optional<PgConstraint> result;
std::optional<PgConstraint> result;
for (const auto &e : m_container) {
if (e.relid == relid && e.type == ConstraintType::PrimaryKey) {
result = e;

View file

@ -5,7 +5,7 @@
#include "PgConstraint.h"
#include "Pgsql_declare.h"
#include <vector>
#include <boost/optional.hpp>
#include <optional>
class PgConstraintContainer : public PgContainer<PgConstraint> {
public:
@ -16,7 +16,7 @@ public:
const PgConstraint* getFKeyForTableColumn(Oid relid, int16_t attnum) const;
std::vector<PgConstraint> getConstraintsForRelation(Oid relid) const;
boost::optional<PgConstraint> getPrimaryForRelation(Oid relid) const;
std::optional<PgConstraint> getPrimaryForRelation(Oid relid) const;
protected:
virtual PgConstraint loadElem(const Pgsql::Row &row) override;
};

View file

@ -69,7 +69,7 @@ void CodeBuilder::genStructFields(QTextStream &q, const ColumnDataList &columns)
// Any way at generation time we might want to be able to specify the null handle
// - exception/error return
// - magic value
// - boost::optional
// - std::optional
// - boolean flags
// - null pointer (useful for languages where this has no cost, other cases boolean flags will be more performant)
}

View file

@ -41,7 +41,7 @@ public:
* field often provides enough flexibility.
*/
QString m_prefixWith;
// boost::optional<CharToNumericConversion> m_numericConversion;
// std::optional<CharToNumericConversion> m_numericConversion;
};
#endif // STRINGESCAPERULE_H