You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-31Lines changed: 23 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
# Komodo Defi Proxy
2
+
3
+
Decentralized P2P applications have some limitations by their nature and one of them is the use application/API keys. If an API key is used in the application, any user could retrieve it by simply debugging the app. Some of the blockchain services we use in [komodo-defi-framework](https://github.com/KomodoPlatform/komodo-defi-framework) are paid services and we want to prevent abuse, such as users copying the API key for personal use. To address this problem, we created this project, komodo-defi-proxy. It takes the request, handles the API key, forwards the request to the actual service, and returns the result without modifying the original request. This keeps our secret application keys secure and hidden from end users.
4
+
1
5
### Dev Requirements
2
6
3
7
Creating rsa key pairs
@@ -16,12 +20,14 @@ Create the configuration file for app runtime.
16
20
"pubkey_path": "/path_to_publick_key.pem",
17
21
"privkey_path": "/path_to_private_key.pem",
18
22
"redis_connection_string": "redis://localhost",
23
+
"kdf_rpc_client": "http://127.0.0.1:7783",
24
+
"kdf_rpc_password": "testpass",
19
25
"token_expiration_time": 300,
20
26
"proxy_routes": [
21
27
{
22
28
"inbound_route": "/dev",
23
29
"outbound_route": "http://localhost:8000",
24
-
"proxy_type": "quicknode",
30
+
"proxy_type": "quicknode",# available types are: "quicknode", "moralis", "block_pi"
25
31
"authorized": false,
26
32
"allowed_rpc_methods": [
27
33
"eth_blockNumber",
@@ -36,20 +42,18 @@ Create the configuration file for app runtime.
36
42
"rp_15_min": 200,
37
43
"rp_30_min": 350,
38
44
"rp_60_min": 575
39
-
}
45
+
},
46
+
"peer_healthcheck_caching_secs": 10
40
47
}
41
48
```
42
49
43
50
Expose configuration file's path as an environment variable in `AUTH_APP_CONFIG_PATH`.
44
51
45
-
***Important Note:*** The environment where the application will be deployed, the timezone MUST be as UTC. Also, make sure redis is version `6.*`
@@ -58,29 +62,17 @@ Expose configuration file's path as an environment variable in `AUTH_APP_CONFIG_
58
62
3) If the incoming request comes from the same network, step 4 will be by-passed.
59
63
60
64
4) Request Handling in the Middleware:
65
+
-**Status Checker**:
66
+
-**Blocked**: Return `403 Forbidden`.
67
+
-**Allowed**: Process continues with the rate limiter.
68
+
-**Trusted**: Bypass rate limiter and proof of funding.
61
69
62
-
**For Quicknode:**
63
-
-**Status Checker**:
64
-
-**Blocked**: Return `403 Forbidden` immediately.
65
-
-**Allowed**: Process continues with the rate limiter.
66
-
-**Trusted**: Bypass rate limiter and proof of funding.
70
+
-**Peer Status Checker**:
71
+
- The requesting peer must be active in the KDF network. Validate this by executing the `peer_connection_healthcheck` KDF RPC. If the peer is not connected to the network, return `401 Unauthorized`.
67
72
68
-
-**Rate Limiter**:
69
-
- First, verify the signed message. If not valid, return `401 Unauthorized` immediately.
70
-
- If valid, calculate the request count with the time interval specified in the application configuration. If the wallet address has sent too many requests than the expected amount, process continues with the proof of funding. If not, bypass the proof of funding.
71
-
72
-
-**Proof of Funding**:
73
-
- Return `406 Not Acceptable` if the wallet has a 0 balance. Otherwise, assume the request is valid and process it as usual.
74
-
75
-
**For Moralis:**
76
-
-**Status Checker**:
77
-
-**Blocked**: Return `403 Forbidden` immediately.
78
-
-**Allowed**: Process continues with the rate limiter.
79
-
-**Trusted**: Bypass the rate limiter.
80
-
81
-
-**Rate Limiter**:
82
-
- First, verify the signed message. If not valid, return `401 Unauthorized` immediately.
83
-
- If valid, calculate the request count with the time interval specified in the application configuration. If the wallet address has sent too many requests, return an error `406 Not Acceptable` indicating that the wallet address must wait for some time before making more requests.
73
+
-**Rate Limiter**:
74
+
- First, verify the signed message. If not valid, return `401 Unauthorized`.
75
+
- If valid, calculate the request count with the time interval specified in the application configuration. If the wallet address has sent too many requests than the expected amount, process continues with the proof of funding. If not, bypass the proof of funding.
0 commit comments