mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
* mount: read chunks with filer-issued exact-file read tokens * mount: preserve read authorization across delayed lookups and hard links * mount: retain response tokens across read cache eviction * mount: keep a shared read-token lookup alive when its first caller is cancelled Token refreshes for one entry share a singleflight lookup that ran under the first caller's context. An interrupted read cancelled that lookup, so every other read of the entry waiting on it got no token, went out unauthenticated, and failed with EIO on a volume server enforcing read JWTs. Run the lookup detached from the caller (each attempt stays bounded by the filer RPC wait) and let a cancelled caller stop waiting at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: serve a cached chunk past the cache cutoff instead of fetching it The full-chunk read path consulted the chunk cache only for chunks below the cache size cutoff. Read-auth and peer-sharing mounts cache every chunk they upload, so a read-after-write of a high-offset chunk went to the volume, where a read-auth mount has no token before the entry is published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: re-track read tokens when this mount renames an open file Writeback mounts skip their own rename event, so only the subscriber path re-tracked an open handle's chunks. After a local rename a token refresh looked up the vacated name and the read failed. The rename response, the subscriber rename and the surviving hard link now share ReadAuth.TrackHandle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package security
|
|
|
|
import (
|
|
"context"
|
|
"sync/atomic"
|
|
)
|
|
|
|
// VolumeReadTokenProvider supplies the volume read credential for one file id.
|
|
// A client that must not hold jwt.signing.read.key -- a mount whose filer hands
|
|
// it exact-fid read capabilities (LookupDirectoryEntries read_auth) -- installs
|
|
// one; while installed it replaces local signing wherever a chunk is read
|
|
// directly from a volume server.
|
|
type VolumeReadTokenProvider func(ctx context.Context, fileId string) string
|
|
|
|
var volumeReadTokenProvider atomic.Pointer[VolumeReadTokenProvider]
|
|
|
|
// SetVolumeReadTokenProvider installs p process-wide; nil removes it.
|
|
func SetVolumeReadTokenProvider(p VolumeReadTokenProvider) {
|
|
if p == nil {
|
|
volumeReadTokenProvider.Store(nil)
|
|
return
|
|
}
|
|
volumeReadTokenProvider.Store(&p)
|
|
}
|
|
|
|
// VolumeReadToken returns the installed provider's token for fileId, and
|
|
// whether a provider is installed. An installed provider that has no token
|
|
// returns "", so the read fails closed instead of falling back to a key.
|
|
func VolumeReadToken(ctx context.Context, fileId string) (string, bool) {
|
|
p := volumeReadTokenProvider.Load()
|
|
if p == nil {
|
|
return "", false
|
|
}
|
|
return (*p)(ctx, fileId), true
|
|
}
|