mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-22 22:53:33 +08:00
Add JWT authentication to fs.mergeVolumes command (#6461)
Add jwt authentication to fs.mergeVolumes command
This commit is contained in:
@@ -10,10 +10,12 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"slices"
|
||||||
|
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/security"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/wdclient"
|
"github.com/seaweedfs/seaweedfs/weed/wdclient"
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
"slices"
|
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/operation"
|
"github.com/seaweedfs/seaweedfs/weed/operation"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||||
@@ -341,6 +343,14 @@ func moveChunk(chunk *filer_pb.FileChunk, toVolumeId needle.VolumeId, masterClie
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v := util.GetViper()
|
||||||
|
signingKey := v.GetString("jwt.signing.key")
|
||||||
|
var jwt security.EncodedJwt
|
||||||
|
if signingKey != "" {
|
||||||
|
expiresAfterSec := v.GetInt("jwt.signing.expires_after_seconds")
|
||||||
|
jwt = security.GenJwtForVolumeServer(security.SigningKey(signingKey), expiresAfterSec, toFid.String())
|
||||||
|
}
|
||||||
|
|
||||||
_, err, _ = uploader.Upload(reader, &operation.UploadOption{
|
_, err, _ = uploader.Upload(reader, &operation.UploadOption{
|
||||||
UploadUrl: uploadURL,
|
UploadUrl: uploadURL,
|
||||||
Filename: filename,
|
Filename: filename,
|
||||||
@@ -349,6 +359,7 @@ func moveChunk(chunk *filer_pb.FileChunk, toVolumeId needle.VolumeId, masterClie
|
|||||||
MimeType: contentType,
|
MimeType: contentType,
|
||||||
PairMap: nil,
|
PairMap: nil,
|
||||||
Md5: md5,
|
Md5: md5,
|
||||||
|
Jwt: security.EncodedJwt(jwt),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user