Skip to content

Commit 02c2dad

Browse files
authored
Check API permissions (#465)
* Add permissions to API Signed-off-by: ortyomka <[email protected]> * Added Auth between Remote stores Signed-off-by: ortyomka <[email protected]> * Remove duplicate code Signed-off-by: ortyomka <[email protected]> * Fix unused warn Signed-off-by: ortyomka <[email protected]>
1 parent 86234f0 commit 02c2dad

File tree

19 files changed

+506
-150
lines changed

19 files changed

+506
-150
lines changed

core/api/common_api.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,42 @@ namespace fc::api {
1616
using common::Buffer;
1717
using libp2p::peer::PeerInfo;
1818
using primitives::jwt::Permission;
19+
namespace jwt = primitives::jwt;
1920

2021
struct CommonApi {
2122
/**
2223
* Creates auth token to the remote connection
2324
* @return auth token
2425
*/
25-
API_METHOD(AuthNew, Buffer, const std::vector<Permission> &)
26+
API_METHOD(AuthNew,
27+
jwt::kAdminPermission,
28+
Buffer,
29+
const std::vector<Permission> &)
2630
/**
2731
* Verify auth token
2832
* @return allow permissions
2933
*/
30-
API_METHOD(AuthVerify, std::vector<Permission>, const std::string &)
34+
API_METHOD(AuthVerify,
35+
jwt::kReadPermission,
36+
std::vector<Permission>,
37+
const std::string &)
3138

3239
/**
3340
* Returns listen addresses.
3441
*/
35-
API_METHOD(NetAddrsListen, PeerInfo)
42+
API_METHOD(NetAddrsListen, jwt::kReadPermission, PeerInfo)
3643

3744
/**
3845
* Initiates the connection to the peer.
3946
*/
40-
API_METHOD(NetConnect, void, const PeerInfo &)
47+
API_METHOD(NetConnect, jwt::kWritePermission, void, const PeerInfo &)
4148

4249
/**
4350
* Returns all peers connected to the this host.
4451
*/
45-
API_METHOD(NetPeers, std::vector<PeerInfo>)
52+
API_METHOD(NetPeers, jwt::kReadPermission, std::vector<PeerInfo>)
4653

47-
API_METHOD(Version, VersionResult)
54+
API_METHOD(Version, jwt::kReadPermission, VersionResult)
4855
};
4956

5057
template <typename A, typename F>

0 commit comments

Comments
 (0)