use grpc and jwt

This commit is contained in:
Chris Lu
2021-08-12 21:40:33 -07:00
parent 6238644c35
commit 5a0f92423e
15 changed files with 453 additions and 453 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/chrislusf/raft"
"reflect"
"strings"
"sync"
"time"
@@ -69,7 +70,7 @@ func (ms *MasterServer) ProcessGrowRequest() {
func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupVolumeRequest) (*master_pb.LookupVolumeResponse, error) {
resp := &master_pb.LookupVolumeResponse{}
volumeLocations := ms.lookupVolumeId(req.VolumeIds, req.Collection)
volumeLocations := ms.lookupVolumeId(req.VolumeOrFileIds, req.Collection)
for _, result := range volumeLocations {
var locations []*master_pb.Location
@@ -79,10 +80,15 @@ func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupV
PublicUrl: loc.PublicUrl,
})
}
var auth string
if strings.Contains(result.VolumeOrFileId, ",") { // this is a file id
auth = string(security.GenJwt(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, result.VolumeOrFileId))
}
resp.VolumeIdLocations = append(resp.VolumeIdLocations, &master_pb.LookupVolumeResponse_VolumeIdLocation{
VolumeId: result.VolumeId,
Locations: locations,
Error: result.Error,
VolumeOrFileId: result.VolumeOrFileId,
Locations: locations,
Error: result.Error,
Auth: auth,
})
}