Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

generate jwt token when looking up needle id

chrislu94fbf02ea2fd
diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go
index a2676accf0..87c7b9990c 100644
--- a/weed/server/master_grpc_server_volume.go
+++ b/weed/server/master_grpc_server_volume.go
@@ -82,25 +82,32 @@ func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupV
resp := &master_pb.LookupVolumeResponse{}
volumeLocations := ms.lookupVolumeId(req.VolumeOrFileIds, req.Collection)
- for _, result := range volumeLocations {
- var locations []*master_pb.Location
- for _, loc := range result.Locations {
- locations = append(locations, &master_pb.Location{
- Url: loc.Url,
- PublicUrl: loc.PublicUrl,
- DataCenter: loc.DataCenter,
- })
+ for _, volumeOrFileId := range req.VolumeOrFileIds {
+ vid := volumeOrFileId
+ commaSep := strings.Index(vid, ",")
+ if commaSep > 0 {
+ vid = vid[0:commaSep]
}
- var auth string
- if strings.Contains(result.VolumeOrFileId, ",") { // this is a file id
- auth = string(security.GenJwtForVolumeServer(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, result.VolumeOrFileId))
+ if result, found := volumeLocations[vid]; found {
+ var locations []*master_pb.Location
+ for _, loc := range result.Locations {
+ locations = append(locations, &master_pb.Location{
+ Url: loc.Url,
+ PublicUrl: loc.PublicUrl,
+ DataCenter: loc.DataCenter,
+ })
+ }
+ var auth string
+ if commaSep > 0 { // this is a file id
+ auth = string(security.GenJwtForVolumeServer(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, result.VolumeOrFileId))
+ }
+ resp.VolumeIdLocations = append(resp.VolumeIdLocations, &master_pb.LookupVolumeResponse_VolumeIdLocation{
+ VolumeOrFileId: result.VolumeOrFileId,
+ Locations: locations,
+ Error: result.Error,
+ Auth: auth,
+ })
}
- resp.VolumeIdLocations = append(resp.VolumeIdLocations, &master_pb.LookupVolumeResponse_VolumeIdLocation{
- VolumeOrFileId: result.VolumeOrFileId,
- Locations: locations,
- Error: result.Error,
- Auth: auth,
- })
}
return resp, nil