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
Problem: Solana wallet couln't be used to control the VM (#700)
* Improve documentation for auth decorator
* Problem: Solana wallet couln't be used to control the VM
* Add new dep to debian package
* Fix mypy error not related to PR
Had do ignore since mypy expect a DataClassIstance that don't exist
* Document solana support for operator endpoints
* mod: Move signature checking for all chain in a function
Copy file name to clipboardExpand all lines: doc/operator_auth.md
+59-49
Original file line number
Diff line number
Diff line change
@@ -1,56 +1,59 @@
1
1
Authentication protocol for VM owner
2
2
=======================================
3
3
4
-
This custom protocol allows a user (owner of a VM) to securely authenticate to a CRN, using their Ethereum wallet.
5
-
This scheme was designed in a way that's convenient to be integrated in the console web page.
4
+
This custom protocol allows a user (owner of a VM) to securely authenticate to a CRN, using their Ethereum or Solana
5
+
wallet. This scheme was designed in a way that's convenient to be integrated into the console web page.
6
6
7
-
It allows the user to control their VM. e.g: stop reboot, view their log, etc…
7
+
It allows the user to control their VM. e.g: stop, reboot, view their log, etc.
8
8
9
9
## Motivations
10
10
11
11
This protocol ensures secure authentication between a blockchain wallet owner and an aleph.im compute node.
12
12
13
-
Signing operations is typically gated by prompts requiring manual approval for each operation.
14
-
With hardware wallets, users are prompted both by the software on their device and the hardware wallet itself.
13
+
Signing operations are typically gated by prompts requiring manual approval for each operation. With hardware wallets,
14
+
users are prompted both by the software on their device and the hardware wallet itself.
15
15
16
16
## Overview
17
17
18
-
The client generates a [JSON Web Key](https://www.rfc-editor.org/rfc/rfc7517) (JWK) key pair and signs the public key with their Ethereum account. The signed public key is sent
19
-
in the `X-SignedPubKey` header. The client also signs the operation payload with the private JWK, sending it in the
20
-
`X-SignedOperation` header. The server verifies both the public key and payload signatures, ensuring the request's
21
-
integrity and authenticity. If validation fails (e.g., expired key or invalid signature), the server returns a 401
22
-
Unauthorized error.
18
+
The client generates a [JSON Web Key](https://www.rfc-editor.org/rfc/rfc7517) (JWK) key pair and signs the public key
19
+
with their Ethereum or Solana account. The signed public key is sent in the `X-SignedPubKey` header. The client also
20
+
signs the operation payload with the private JWK, sending it in the `X-SignedOperation` header. The server verifies both
21
+
the public key and payload signatures, ensuring the request's integrity and authenticity. If validation fails (e.g.,
22
+
expired key or invalid signature), the server returns a 401 Unauthorized error.
23
23
24
-
Support for Solana wallets is planned in the near future.
25
24
26
25
## Authentication Method for HTTP Endpoints
27
26
28
27
Two custom headers are added to each authenticated request:
29
28
30
-
*X-SignedPubKey: This contains the public key and its associated metadata (such as the sender’s address and expiration
31
-
date), along with a signature that ensures its authenticity.
32
-
*X-SignedOperation: This includes the payload of the operation and its cryptographic signature, ensuring that the
29
+
-**X-SignedPubKey**: This contains the public key and its associated metadata (such as the sender’s address, chain, and
30
+
expiration date), along with a signature that ensures its authenticity.
31
+
-**X-SignedOperation**: This includes the payload of the operation and its cryptographic signature, ensuring that the
33
32
operation itself has not been tampered with.
34
33
35
-
### 1. Generate and Sign Public Key
34
+
### 1. Generate an ephemeral keys and Sign Public Key
36
35
37
-
A new JWK is generated using elliptic curve cryptography (EC, P-256).
36
+
An ephemeral key pair (as JWK) is generated using elliptic curve cryptography (EC, P-256).
38
37
39
38
The use of a temporary JWK key allows the user to delegate limited control to the console without needing to sign every
40
-
individual request with their Ethereum wallet. This is crucial for improving the user experience, as constantly signing
41
-
each operation would be cumbersome and inefficient. By generating a temporary key, the user can provide permission for a
42
-
set period of time (until the key expires), enabling the console to perform actions like stopping or rebooting the VM on
43
-
their behalf. This maintains security while streamlining interactions with the console, as the server verifies each
44
-
operation using the temporary key without requiring ongoing involvement from the user's wallet.
39
+
individual request with their Ethereum or Solana wallet. This is crucial for improving the user experience, as
40
+
constantly signing each operation would be cumbersome and inefficient. By generating a temporary key, the user can
41
+
provide permission for a set period of time (until the key expires), enabling the console to perform actions like
42
+
stopping or rebooting the VM on their behalf. This maintains security while streamlining interactions with the console,
43
+
as the server verifies each operation using the temporary key without requiring ongoing involvement from the user's
44
+
wallet.
45
45
46
46
The generated public key is converted into a JSON structure with additional metadata:
47
-
*`pubkey`: The public key information.
48
-
*`alg`: The signing algorithm, ECDSA.
49
-
*`domain`: The domain for which the key is valid.
50
-
*`address`: The Ethereum address of the sender, binding the public key to this identity.
51
-
*`expires`: The expiration time of the key.
52
47
53
-
Example
48
+
-**`pubkey`**: The public key information.
49
+
-**`alg`**: The signing algorithm, ECDSA.
50
+
-**`domain`**: The domain for which the key is valid.
51
+
-**`address`**: The wallet address of the sender, binding the temporary key to this identity.
52
+
-**`chain`**: Indicates the blockchain used for signing (`ETH` or `SOL`). Defaults to `ETH`.
This public key is signed using the Ethereum account to ensure its authenticity. The resulting signature is
70
-
combined with the public key into a payload and sent as the `X-SignedPubKey` header.
73
+
This public key is signed using either the Ethereum or Solana account, depending on the `chain` parameter. The resulting
74
+
signature is combined with the public key into a payload and sent as the `X-SignedPubKey` header.
71
75
72
76
### 2. Sign Operation Payload
73
77
@@ -83,7 +87,7 @@ integrity can be verified through signing. Below are the fields included:
83
87
-**`domain`**: (string) The domain associated with the request. This ensures the request is valid for the intended
84
88
CRN. (e.g., `localhost`).
85
89
86
-
Example
90
+
Example:
87
91
88
92
```json
89
93
{
@@ -97,55 +101,61 @@ Example
97
101
It is sent serialized as a hex string.
98
102
99
103
#### Signature
100
-
This payload is serialized in JSON, signed, and sent in the `X-SignedOperation` header to ensure the integrity and authenticity
101
-
of the request.
102
104
103
-
* The operation payload (containing details such as time, method, path, and domain) is serialized and converted into a byte array.
104
-
* The JWK (private key) is used to sign this operation payload, ensuring its integrity. This signature is then included in the X-SignedOperation header.
105
105
106
+
- The operation payload (containing details such as time, method, path, and domain) is JSON serialized and converted into a
107
+
hex string.
108
+
- The ephemeral key (private key) is used to sign this operation payload, ensuring its integrity. This signature is then included
109
+
in the `X-SignedOperation` header.
110
+
111
+
### 3. Include Authentication Headers
106
112
107
-
### 3. Include authentication Headers
108
-
These two headers are to be added to the HTTP Request:
113
+
These two headers are to be added to the HTTP request:
109
114
110
-
1.**`X-SignedPubKey` Header:**
111
-
- This header contains the public key payload and the signature of the public key generated by the Ethereum account.
115
+
1.**`X-SignedPubKey` Header**:
116
+
- This header contains the public key payload and the signature of the public key generated by the Ethereum or
117
+
Solana account.
112
118
113
119
Example:
120
+
114
121
```json
115
122
{
116
-
"payload": "<hexadecimal string of the public key payload>",
117
-
"signature": "<Ethereum signed public key>"
123
+
"payload": "<hexadecimal string of the public key payload>",
124
+
"signature": "<Ethereum or Solana signed public key>"
118
125
}
119
126
```
120
127
121
-
2.**`X-SignedOperation` Header:**
128
+
2.**`X-SignedOperation` Header**:
122
129
- This header contains the operation payload and the signature of the operation payload generated using the private
123
130
JWK.
124
131
125
132
Example:
133
+
126
134
```json
127
135
{
128
-
"payload": "<hexadecimal string of the operation payload>",
129
-
"signature": "<JWK signed operation payload>"
136
+
"payload": "<hexadecimal string of the operation payload>",
137
+
"signature": "<JWK signed operation payload>"
130
138
}
131
139
```
132
140
133
141
### Expiration and Validation
134
142
135
143
- The public key has an expiration date, ensuring that keys are not used indefinitely.
136
-
- Both the public key and the operation signature are validated for authenticity and integrity at the server side.
144
+
- Both the public key and the operation signature are validated for authenticity and integrity at the server side,
145
+
taking into account the specified blockchain (Ethereum or Solana).
137
146
- Requests failing verification or expired keys are rejected with `401 Unauthorized` status, providing an error message
138
147
indicating the reason.
139
148
140
-
###WebSocket Authentication Protocol
149
+
## WebSocket Authentication Protocol
141
150
142
151
In the WebSocket variant of the authentication protocol, the client establishes a connection and authenticates through
143
-
an initial message that includes their Ethereum-signed identity, ensuring secure communication.
152
+
an initial message that includes their Ethereum or Solana-signed identity, ensuring secure communication.
153
+
154
+
Due to web browsers not allowing custom HTTP headers in WebSocket connections, the two headers are sent in one JSON
155
+
packet, under the `auth` key.
144
156
145
-
Due to web browsers not allowing custom HTTP headers in WebSocket connections,
146
-
the two header are sent in one json packet, under the `auth` key.
0 commit comments