Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::login_plugin Class Reference

#include <login_plugin.hpp>

Inheritance diagram for sysio::login_plugin:
Collaboration diagram for sysio::login_plugin:

Classes

struct  do_not_use_gen_r1_key_params
 
struct  do_not_use_gen_r1_key_results
 
struct  do_not_use_get_secret_params
 
struct  do_not_use_get_secret_results
 
struct  do_not_use_sign_params
 
struct  do_not_use_sign_results
 
struct  finalize_login_request_params
 
struct  finalize_login_request_results
 
struct  start_login_request_params
 
struct  start_login_request_results
 

Public Member Functions

 APPBASE_PLUGIN_REQUIRES ((chain_plugin)(http_plugin)) login_plugin()
 
virtual ~login_plugin ()
 
virtual void set_program_options (options_description &, options_description &) override
 
void plugin_initialize (const variables_map &)
 
void plugin_startup ()
 
void plugin_shutdown ()
 
start_login_request_results start_login_request (const start_login_request_params &)
 
finalize_login_request_results finalize_login_request (const finalize_login_request_params &)
 
do_not_use_gen_r1_key_results do_not_use_gen_r1_key (const do_not_use_gen_r1_key_params &)
 
do_not_use_sign_results do_not_use_sign (const do_not_use_sign_params &)
 
do_not_use_get_secret_results do_not_use_get_secret (const do_not_use_get_secret_params &)
 
- Public Member Functions inherited from appbase::plugin< login_plugin >
 plugin ()
 
virtual ~plugin ()
 
virtual state get_state () const override
 
virtual const std::string & name () const override
 
virtual void register_dependencies ()
 
virtual void initialize (const variables_map &options) override
 
virtual void handle_sighup () override
 
virtual void startup () override
 
virtual void shutdown () override
 
- Public Member Functions inherited from appbase::abstract_plugin
virtual ~abstract_plugin ()
 

Additional Inherited Members

- Public Types inherited from appbase::abstract_plugin
enum  state { registered , initialized , started , stopped }
 
- Protected Member Functions inherited from appbase::plugin< login_plugin >
 plugin (const string &name)
 

Detailed Description

Definition at line 10 of file login_plugin.hpp.

Constructor & Destructor Documentation

◆ ~login_plugin()

sysio::login_plugin::~login_plugin ( )
virtual

Definition at line 46 of file login_plugin.cpp.

46{}

Member Function Documentation

◆ APPBASE_PLUGIN_REQUIRES()

sysio::login_plugin::APPBASE_PLUGIN_REQUIRES ( (chain_plugin)(http_plugin) )

◆ do_not_use_gen_r1_key()

login_plugin::do_not_use_gen_r1_key_results sysio::login_plugin::do_not_use_gen_r1_key ( const do_not_use_gen_r1_key_params & params)

Definition at line 145 of file login_plugin.cpp.

145 {
147 return {priv.get_public_key(), priv};
148}
static private_key generate_r1()
Here is the call graph for this function:

◆ do_not_use_get_secret()

login_plugin::do_not_use_get_secret_results sysio::login_plugin::do_not_use_get_secret ( const do_not_use_get_secret_params & params)

Definition at line 156 of file login_plugin.cpp.

156 {
157 return {params.priv_key.generate_shared_secret(params.pub_key)};
158}
account_query_db::get_accounts_by_authorizers_params params

◆ do_not_use_sign()

login_plugin::do_not_use_sign_results sysio::login_plugin::do_not_use_sign ( const do_not_use_sign_params & params)

Definition at line 151 of file login_plugin.cpp.

151 {
152 return {params.priv_key.sign(chain::sha256::hash(params.data))};
153}

◆ finalize_login_request()

login_plugin::finalize_login_request_results sysio::login_plugin::finalize_login_request ( const finalize_login_request_params & params)

Definition at line 105 of file login_plugin.cpp.

105 {
106 finalize_login_request_results result;
107 my->expire_requests();
108 auto& index = my->requests.get<login_request_pub_key_index>();
109 auto it = index.find(params.server_ephemeral_pub_key);
110 if (it == index.end()) {
111 result.error = "server_ephemeral_pub_key expired or not found";
112 return result;
113 }
114 auto request = *it;
115 index.erase(it);
116
117 auto shared_secret = request.server_ephemeral_priv_key.generate_shared_secret(params.client_ephemeral_pub_key);
118
119 chain::bytes combined_data(1024 * 1024);
120 chain::datastream<char*> sig_data_ds{combined_data.data(), combined_data.size()};
121 fc::raw::pack(sig_data_ds, params.permission);
122 fc::raw::pack(sig_data_ds, shared_secret);
123 fc::raw::pack(sig_data_ds, params.data);
124 combined_data.resize(sig_data_ds.tellp());
125
126 result.digest = chain::sha256::hash(combined_data);
127 for (auto& sig : params.signatures)
128 result.recovered_keys.insert(chain::public_key_type{sig, result.digest});
129
130 try {
131 auto noop_checktime = [] {};
132 auto& chain = app().get_plugin<chain_plugin>().chain();
133 chain.get_authorization_manager().check_authorization( //
134 params.permission.actor, params.permission.permission, result.recovered_keys, {}, fc::microseconds(0),
135 noop_checktime, true);
136 result.permission_satisfied = true;
137 } catch (...) {
138 result.error = "keys do not satisfy permission";
139 }
140
141 return result;
142}
abstract_plugin & get_plugin(const string &name) const
application & app()
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
fc::crypto::public_key public_key_type
Definition types.hpp:76
vector< char > bytes
Definition types.hpp:243
Here is the call graph for this function:
Here is the caller graph for this function:

◆ plugin_initialize()

void sysio::login_plugin::plugin_initialize ( const variables_map & options)

Definition at line 56 of file login_plugin.cpp.

56 {
57 my->max_login_requests = options.at("max-login-requests").as<uint32_t>();
58 my->max_login_timeout = options.at("max-login-timeout").as<uint32_t>();
59}
unsigned int uint32_t
Definition stdint.h:126

◆ plugin_shutdown()

void sysio::login_plugin::plugin_shutdown ( )

Definition at line 86 of file login_plugin.cpp.

86{}

◆ plugin_startup()

void sysio::login_plugin::plugin_startup ( )

Definition at line 75 of file login_plugin.cpp.

75 {
76 ilog("starting login_plugin");
77 app().get_plugin<http_plugin>().add_api({
80 // CALL(do_not_use_gen_r1_key, 200), //
81 // CALL(do_not_use_sign, 200), //
82 // CALL(do_not_use_get_secret, 200), //
83 });
84}
start_login_request_results start_login_request(const start_login_request_params &)
finalize_login_request_results finalize_login_request(const finalize_login_request_params &)
#define ilog(FORMAT,...)
Definition logger.hpp:118
#define CALL(call_name, http_response_code)
Here is the call graph for this function:

◆ set_program_options()

void sysio::login_plugin::set_program_options ( options_description & ,
options_description & cfg )
overridevirtual

Implements appbase::abstract_plugin.

Definition at line 48 of file login_plugin.cpp.

48 {
49 cfg.add_options() //
50 ("max-login-requests", bpo::value<uint32_t>()->default_value(1000000),
51 "The maximum number of pending login requests") //
52 ("max-login-timeout", bpo::value<uint32_t>()->default_value(60),
53 "The maximum timeout for pending login requests (in seconds)");
54}

◆ start_login_request()

login_plugin::start_login_request_results sysio::login_plugin::start_login_request ( const start_login_request_params & params)

Definition at line 89 of file login_plugin.cpp.

89 {
90 my->expire_requests();
91 SYS_ASSERT(params.expiration_time > fc::time_point::now(), fc::timeout_exception,
92 "Requested expiration time ${expiration_time} is in the past",
93 ("expiration_time", params.expiration_time));
94 SYS_ASSERT(my->requests.size() < my->max_login_requests, fc::timeout_exception, "Too many pending login requests");
95 login_request request;
96 request.server_ephemeral_priv_key = chain::private_key_type::generate_r1();
97 request.server_ephemeral_pub_key = request.server_ephemeral_priv_key.get_public_key();
98 request.expiration_time =
99 std::min(params.expiration_time, fc::time_point_sec{fc::time_point::now()} + my->max_login_timeout);
100 my->requests.insert(request);
101 return {request.server_ephemeral_pub_key};
102}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
static time_point now()
Definition time.cpp:14
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: