parent
5fbff6cf52
commit
3a9d0df75c
5 changed files with 30 additions and 2 deletions
|
|
@ -313,6 +313,11 @@ namespace detail {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_api_access_info(const string& username, api_access_info&& permissions)
|
||||||
|
{
|
||||||
|
_apiaccess.permission_map.insert(std::make_pair(username, std::move(permissions)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If delegate has the item, the network has no need to fetch it.
|
* If delegate has the item, the network has no need to fetch it.
|
||||||
*/
|
*/
|
||||||
|
|
@ -668,6 +673,11 @@ optional< api_access_info > application::get_api_access_info( const string& user
|
||||||
return my->get_api_access_info( username );
|
return my->get_api_access_info( username );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void application::set_api_access_info(const string& username, api_access_info&& permissions)
|
||||||
|
{
|
||||||
|
my->set_api_access_info(username, std::move(permissions));
|
||||||
|
}
|
||||||
|
|
||||||
bool application::is_finished_syncing() const
|
bool application::is_finished_syncing() const
|
||||||
{
|
{
|
||||||
return my->_is_finished_syncing;
|
return my->_is_finished_syncing;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ namespace graphene { namespace app {
|
||||||
|
|
||||||
void set_block_production(bool producing_blocks);
|
void set_block_production(bool producing_blocks);
|
||||||
fc::optional< api_access_info > get_api_access_info( const string& username )const;
|
fc::optional< api_access_info > get_api_access_info( const string& username )const;
|
||||||
|
void set_api_access_info(const string& username, api_access_info&& permissions);
|
||||||
|
|
||||||
bool is_finished_syncing()const;
|
bool is_finished_syncing()const;
|
||||||
/// Emitted when syncing finishes (is_finished_syncing will return true)
|
/// Emitted when syncing finishes (is_finished_syncing will return true)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@
|
||||||
BlockChain::BlockChain()
|
BlockChain::BlockChain()
|
||||||
: chainThread(new fc::thread("chainThread")),
|
: chainThread(new fc::thread("chainThread")),
|
||||||
fcTaskScheduler(new QTimer(this)),
|
fcTaskScheduler(new QTimer(this)),
|
||||||
grapheneApp(new graphene::app::application)
|
grapheneApp(new graphene::app::application),
|
||||||
|
webUsername(QStringLiteral("webui")),
|
||||||
|
webPassword(QString::fromStdString(fc::sha256::hash(fc::ecc::private_key::generate())))
|
||||||
{
|
{
|
||||||
fcTaskScheduler->setInterval(100);
|
fcTaskScheduler->setInterval(100);
|
||||||
fcTaskScheduler->setSingleShot(false);
|
fcTaskScheduler->setSingleShot(false);
|
||||||
|
|
@ -50,6 +52,13 @@ void BlockChain::start()
|
||||||
grapheneApp->initialize_plugins(map);
|
grapheneApp->initialize_plugins(map);
|
||||||
grapheneApp->startup();
|
grapheneApp->startup();
|
||||||
grapheneApp->startup_plugins();
|
grapheneApp->startup_plugins();
|
||||||
|
|
||||||
|
graphene::app::api_access_info webPermissions;
|
||||||
|
auto passHash = fc::sha256::hash(webPassword.toStdString());
|
||||||
|
webPermissions.password_hash_b64 = fc::base64_encode(passHash.data(), passHash.data_size());
|
||||||
|
webPermissions.password_salt_b64 = fc::base64_encode("");
|
||||||
|
webPermissions.allowed_apis = {"database_api", "network_broadcast_api", "network_node_api", "history_api"};
|
||||||
|
grapheneApp->set_api_access_info(webUsername.toStdString(), std::move(webPermissions));
|
||||||
} catch (const fc::exception& e) {
|
} catch (const fc::exception& e) {
|
||||||
elog("Crap went wrong: ${e}", ("e", e.to_detail_string()));
|
elog("Crap went wrong: ${e}", ("e", e.to_detail_string()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,15 @@ namespace fc { class thread; }
|
||||||
namespace graphene { namespace app { class application; } }
|
namespace graphene { namespace app { class application; } }
|
||||||
class BlockChain : public QObject {
|
class BlockChain : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString webUsername MEMBER webUsername CONSTANT)
|
||||||
|
Q_PROPERTY(QString webPassword MEMBER webPassword CONSTANT)
|
||||||
|
|
||||||
fc::thread* chainThread;
|
fc::thread* chainThread;
|
||||||
QTimer* fcTaskScheduler;
|
QTimer* fcTaskScheduler;
|
||||||
graphene::app::application* grapheneApp;
|
graphene::app::application* grapheneApp;
|
||||||
fc::future<void> startFuture;
|
fc::future<void> startFuture;
|
||||||
|
QString webUsername;
|
||||||
|
QString webPassword;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BlockChain();
|
BlockChain();
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@ Window {
|
||||||
|
|
||||||
BlockChain {
|
BlockChain {
|
||||||
id: blockChain
|
id: blockChain
|
||||||
onStarted: webView.url = "qrc:/index.html"
|
onStarted: {
|
||||||
|
var url = "qrc:/index.html#authTokens/" + webUsername + ":" + webPassword
|
||||||
|
console.log("Loading %1 in web view".arg(url))
|
||||||
|
webView.url = url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Component.onCompleted: blockChain.start()
|
Component.onCompleted: blockChain.start()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue