add modules.StorageAuthWithURL to set correct token
This commit is contained in:
@@ -103,6 +103,7 @@ func ConfigStorageMiner(c interface{}) Option {
|
||||
),
|
||||
|
||||
If(!cfg.Subsystems.EnableSectorStorage,
|
||||
Override(new(sectorstorage.StorageAuth), modules.StorageAuthWithURL(cfg.Subsystems.SectorIndexApiInfo)),
|
||||
Override(new(modules.MinerStorageService), modules.ConnectStorageService(cfg.Subsystems.SectorIndexApiInfo)),
|
||||
Override(new(sectorstorage.Unsealer), From(new(modules.MinerStorageService))),
|
||||
Override(new(sectorblocks.SectorBuilder), From(new(modules.MinerStorageService))),
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.uber.org/fx"
|
||||
@@ -693,6 +694,19 @@ func StorageAuth(ctx helpers.MetricsCtx, ca v0api.Common) (sectorstorage.Storage
|
||||
return sectorstorage.StorageAuth(headers), nil
|
||||
}
|
||||
|
||||
func StorageAuthWithURL(url string) func(ctx helpers.MetricsCtx, ca v0api.Common) (sectorstorage.StorageAuth, error) {
|
||||
log.Infow("Setting auth token based on URL", "url", url)
|
||||
return func(ctx helpers.MetricsCtx, ca v0api.Common) (sectorstorage.StorageAuth, error) {
|
||||
s := strings.Split(url, ":")
|
||||
if len(s) != 2 {
|
||||
return nil, errors.New("unexpected format of URL")
|
||||
}
|
||||
headers := http.Header{}
|
||||
headers.Add("Authorization", "Bearer "+s[0])
|
||||
return sectorstorage.StorageAuth(headers), nil
|
||||
}
|
||||
}
|
||||
|
||||
func NewConsiderOnlineStorageDealsConfigFunc(r repo.LockedRepo) (dtypes.ConsiderOnlineStorageDealsConfigFunc, error) {
|
||||
return func() (out bool, err error) {
|
||||
err = readCfg(r, func(cfg *config.StorageMiner) {
|
||||
|
||||
Reference in New Issue
Block a user