feat(nodes): opt-in encryption at rest for the outbound node API token (#6186)

* node: encrypt outbound bearer token at rest

* fix(nodes): keep bearer tokens encrypted throughout

---------

Co-authored-by: n0ctal <293235942+n0ctal@users.noreply.github.com>
This commit is contained in:
n0ctal
2026-08-15 19:48:50 +05:00
committed by GitHub
parent 8e7fb144ee
commit 1793a9b8b4
9 changed files with 982 additions and 15 deletions
+6 -1
View File
@@ -17,6 +17,7 @@ import (
"sync"
"time"
"github.com/mhsanaei/3x-ui/v3/internal/crypto/nodetoken"
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
"github.com/mhsanaei/3x-ui/v3/internal/logger"
"github.com/mhsanaei/3x-ui/v3/internal/util/netsafe"
@@ -229,7 +230,11 @@ func (r *Remote) do(ctx context.Context, method, path string, body any) (*envelo
return nil, err
}
if r.node.ApiToken != "" {
req.Header.Set("Authorization", "Bearer "+r.node.ApiToken)
token, err := nodetoken.Decrypt(r.node.Id, r.node.ApiToken)
if err != nil {
return nil, fmt.Errorf("decrypt node token: %w", err)
}
req.Header.Set("Authorization", "Bearer "+token)
}
req.Header.Set("Accept", "application/json")
if contentType != "" {