mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
rename security.GenJwt to security.GenJwtForVolumeServer
This commit is contained in:
parent
eda4c43a08
commit
d156d410ef
|
@ -13,12 +13,14 @@ import (
|
|||
type EncodedJwt string
|
||||
type SigningKey []byte
|
||||
|
||||
// SeaweedFileIdClaims is created by Master server(s) and consumed by Volume server(s),
|
||||
// restricting the access this JWT allows to only a single file.
|
||||
type SeaweedFileIdClaims struct {
|
||||
Fid string `json:"fid"`
|
||||
jwt.StandardClaims
|
||||
}
|
||||
|
||||
func GenJwt(signingKey SigningKey, expiresAfterSec int, fileId string) EncodedJwt {
|
||||
func GenJwtForVolumeServer(signingKey SigningKey, expiresAfterSec int, fileId string) EncodedJwt {
|
||||
if len(signingKey) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupV
|
|||
}
|
||||
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))
|
||||
auth = string(security.GenJwtForVolumeServer(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, result.VolumeOrFileId))
|
||||
}
|
||||
resp.VolumeIdLocations = append(resp.VolumeIdLocations, &master_pb.LookupVolumeResponse_VolumeIdLocation{
|
||||
VolumeOrFileId: result.VolumeOrFileId,
|
||||
|
@ -173,7 +173,7 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest
|
|||
GrpcPort: uint32(dn.GrpcPort),
|
||||
},
|
||||
Count: count,
|
||||
Auth: string(security.GenJwt(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, fid)),
|
||||
Auth: string(security.GenJwtForVolumeServer(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, fid)),
|
||||
Replicas: replicas,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -149,9 +149,9 @@ func (ms *MasterServer) maybeAddJwtAuthorization(w http.ResponseWriter, fileId s
|
|||
}
|
||||
var encodedJwt security.EncodedJwt
|
||||
if isWrite {
|
||||
encodedJwt = security.GenJwt(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, fileId)
|
||||
encodedJwt = security.GenJwtForVolumeServer(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, fileId)
|
||||
} else {
|
||||
encodedJwt = security.GenJwt(ms.guard.ReadSigningKey, ms.guard.ReadExpiresAfterSec, fileId)
|
||||
encodedJwt = security.GenJwtForVolumeServer(ms.guard.ReadSigningKey, ms.guard.ReadExpiresAfterSec, fileId)
|
||||
}
|
||||
if encodedJwt == "" {
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue