Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Aug 5, 2019
1 parent d36e6a4 commit 07a3abe
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions api_access.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"permission_map":
"permission_map":
[
[
"*",
Expand All @@ -23,26 +23,26 @@
"required_lifetime_member": false,
"required_registrar": "registrar_name1",
"required_referrer": "",
"allowed_apis":
"allowed_apis":
[
"database_api",
"history_api",
"block_api",
"orders_api"
]
},
},
{
"required_lifetime_member": true,
"required_registrar": "registrar_name2",
"required_referrer": "",
"allowed_apis":
"allowed_apis":
[
"database_api",
"history_api",
"block_api",
"orders_api"
]
}
}
],
"permission_map_signed_user":
[
Expand All @@ -51,7 +51,7 @@
{
"required_lifetime_member": false,
"required_registrar": "",
"allowed_apis":
"allowed_apis":
[
"database_api",
"history_api",
Expand Down
12 changes: 6 additions & 6 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace graphene { namespace app {
auto db = _app.chain_database();
int64_t offset( (trx.expiration - db->head_block_time()).to_seconds() );
if( offset > 5*60 || offset < 0 )
return false;
return false;

auto op = trx.operations[0];
if( op.which() != operation::tag<transfer_operation>::value ) // only transfer op for validation
Expand Down Expand Up @@ -127,7 +127,7 @@ namespace graphene { namespace app {
{
const auto& api_access_info = api_access_info_var->get<api_access_info_signed>();
if( !verify_api_access_info_signed( acc, api_access_info ) )
return false;
return false;

for( const auto& api : api_access_info.allowed_apis )
enable_api( api );
Expand All @@ -141,10 +141,10 @@ namespace graphene { namespace app {
{
if( !verify_api_access_info_signed( acc, api_access_info ) )
continue;

for( const auto& api : api_access_info.allowed_apis )
enable_api( api );

return true;
}
return false;
Expand All @@ -156,7 +156,7 @@ namespace graphene { namespace app {
{
auto db = _app.chain_database();

if( api_access_info.required_lifetime_member && !acc.is_lifetime_member() )
if( api_access_info.required_lifetime_member && !acc.is_lifetime_member() )
return false;

const auto& required_registrar_name = api_access_info.required_registrar;
Expand Down Expand Up @@ -191,7 +191,7 @@ namespace graphene { namespace app {
if( acc.original_referrer )
acc_original_referrer_name = (*acc.original_registrar)(*db).name;

has_required_referrer = required_referrer_name == acc_referrer_name
has_required_referrer = required_referrer_name == acc_referrer_name
|| required_referrer_name == acc_original_referrer_name;
}

Expand Down
14 changes: 7 additions & 7 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,18 @@ void application_impl::new_connection( const fc::http::websocket_connection_ptr&
auto wsc = std::make_shared<fc::rpc::websocket_api_connection>(c, GRAPHENE_NET_MAX_NESTED_OBJECTS);
auto login = std::make_shared<graphene::app::login_api>( std::ref(*_self) );
login->enable_api("database_api");

wsc->register_api(login->database());
wsc->register_api(fc::api<graphene::app::login_api>(login));
c->set_session_data( wsc );

std::string username = "*";
std::string password = "*";
// Try to extract login information from "Authorization" header if present
std::string auth = c->get_request_header("Authorization");
if( !boost::starts_with(auth, "Basic ") )
login->login(username, password);

FC_ASSERT( auth.size() > 6 );
auto decoded_auth = fc::base64_decode(auth.substr(6));

Expand All @@ -257,8 +257,8 @@ void application_impl::new_connection( const fc::http::websocket_connection_ptr&
password = parts[1];
login->login( username, password );
}
else
{
else
{
string base64_encoded_trx = parts[1];
login->login_signed( base64_encoded_trx );
}
Expand Down Expand Up @@ -530,12 +530,12 @@ optional< api_access_info > application_impl::get_api_access_info(const string&
optional< api_access_info_signed_variant > application_impl::get_api_access_info_signed(const string& username)const
{
auto it = _apiaccess.permission_map_signed_user.find( username );
if( it != _apiaccess.permission_map_signed_user.end() )
if( it != _apiaccess.permission_map_signed_user.end() )
return it->second;

if( !_apiaccess.permission_map_signed_default.empty() )
return _apiaccess.permission_map_signed_default;

return optional< api_access_info_signed_variant >();
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/app/application_impl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class application_impl : public net::node_delegate

fc::optional< api_access_info > get_api_access_info(const string& username)const;

fc::optional< api_access_info_signed_variant > get_api_access_info_signed(const string& username)const;
fc::optional< api_access_info_signed_variant > get_api_access_info_signed(const string& username)const;

void set_api_access_info(const string& username, api_access_info&& permissions);

void set_api_access_info_signed_default(std::vector<api_access_info_signed>&& permissions);

void set_api_access_info_signed_user(const string& username, api_access_info_signed&& permissions);

/**
* If delegate has the item, the network has no need to fetch it.
*/
Expand Down
2 changes: 1 addition & 1 deletion libraries/app/include/graphene/app/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ namespace graphene { namespace app {
optional< fc::api<orders_api> > _orders_api;
optional< fc::api<graphene::debug_witness::debug_api> > _debug_api;

bool verify_api_access_info_signed( const account_object& acc,
bool verify_api_access_info_signed( const account_object& acc,
const api_access_info_signed& api_access_info );
};

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/account_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void_result account_upgrade_evaluator::do_evaluate(const account_upgrade_evaluat
void_result account_upgrade_evaluator::do_apply(const account_upgrade_evaluator::operation_type& o)
{ try {
database& d = db();

d.modify(*account, [&](account_object& a) {
if( o.upgrade_to_lifetime_member )
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/graphene/chain/account_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ namespace graphene { namespace chain {

/// The account's name. This name must be unique among all account names on the graph. May not be empty.
string name;

/**
* The owner authority represents absolute control over the account. Usually the keys in this authority will
* be kept in cold storage, as they should not be needed very often and compromise of these keys constitutes
Expand Down
2 changes: 1 addition & 1 deletion libraries/fc
Submodule fc updated 169 files
6 changes: 3 additions & 3 deletions tests/tests/login_signed_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ BOOST_FIXTURE_TEST_SUITE( login_signed_tests, login_signed_fixture )

BOOST_AUTO_TEST_CASE( fail_with_timestamp_too_fresh )
{ try {

ACTOR( alice );
transfer_operation op;
op.from = alice_id;
Expand Down Expand Up @@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE( fail_with_not_transfer_op_in_trx )
ACTOR( alice );
account_update_operation op;
op.account = alice_id;

signed_transaction trx;
trx.operations.push_back( op );
trx.expiration = db.head_block_time() + 60;
Expand All @@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE( fail_with_empty_signature_keys )
signed_transaction trx;
trx.operations.push_back( op );
trx.expiration = db.head_block_time() + 60;

auto json = fc::json::to_string<signed_transaction>( trx );
auto encoded = fc::base64_encode( json );

Expand Down

0 comments on commit 07a3abe

Please sign in to comment.