Skip to content

Commit

Permalink
Merge pull request #399 from ipfs-force-community/feat/add-IAuthClien…
Browse files Browse the repository at this point in the history
…t-stub

feat: add IAuthClient stub
  • Loading branch information
simlecode authored Aug 8, 2023
2 parents 4bef30d + 3708eee commit e81ba4d
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
10 changes: 7 additions & 3 deletions cmd/droplet/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,16 @@ func runDaemon(cctx *cli.Context) error {
authClient, _ = jwtclient.NewAuthClient(cfg.AuthNode.Url, cfg.AuthNode.Token)
}

var iAuthClient jwtclient.IAuthClient = authClient
if authClient == nil {
iAuthClient = &models.IAuthClientStub{}
}

resAPI := &impl.MarketNodeImpl{}
shutdownChan := make(chan struct{})
closeFunc, err := builder.New(ctx,
// defaults
builder.Override(new(*jwtclient.AuthClient), authClient),
builder.Override(new(jwtclient.IAuthClient), authClient),
builder.Override(new(jwtclient.IAuthClient), iAuthClient),
builder.Override(new(journal.DisabledEvents), journal.EnvDisabledEvents),
builder.Override(new(journal.Journal), func(lc fx.Lifecycle, home config.IHome, disabled journal.DisabledEvents) (journal.Journal, error) {
return journal.OpenFilesystemJournal(lc, home.MustHomePath(), "droplet", disabled)
Expand All @@ -215,7 +219,7 @@ func runDaemon(cctx *cli.Context) error {
minermgr.MinerMgrOpts(),

// clients
clients.ClientsOpts(true, &cfg.Messager, &cfg.Signer, authClient),
clients.ClientsOpts(true, &cfg.Messager, &cfg.Signer, iAuthClient),
models.DBOptions(true, &cfg.Mysql),
network.NetworkOpts(true, cfg.SimultaneousTransfersForRetrieval, cfg.SimultaneousTransfersForStoragePerClient, cfg.SimultaneousTransfersForStorage),
piecestorage.PieceStorageOpts(&cfg.PieceStorage),
Expand Down
87 changes: 87 additions & 0 deletions models/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package models

import (
"context"

"github.com/filecoin-project/go-address"
"github.com/ipfs-force-community/sophon-auth/auth"
"github.com/ipfs-force-community/sophon-auth/core"
"github.com/ipfs-force-community/sophon-auth/jwtclient"
)

type IAuthClientStub struct {
}

var _ jwtclient.IAuthClient = (*IAuthClientStub)(nil)

func (*IAuthClientStub) MinerExistInUser(ctx context.Context, user string, miner address.Address) (bool, error) {
return true, nil
}

func (*IAuthClientStub) SignerExistInUser(ctx context.Context, user string, signer address.Address) (bool, error) {
return true, nil
}

func (ia *IAuthClientStub) Verify(ctx context.Context, token string) (*auth.VerifyResponse, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) VerifyUsers(ctx context.Context, names []string) error {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) HasUser(ctx context.Context, name string) (bool, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) GetUser(ctx context.Context, name string) (*auth.OutputUser, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) GetUserByMiner(ctx context.Context, miner address.Address) (*auth.OutputUser, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) GetUserBySigner(ctx context.Context, signer address.Address) (auth.ListUsersResponse, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) ListUsers(ctx context.Context, skip int64, limit int64, state core.UserState) (auth.ListUsersResponse, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) ListUsersWithMiners(ctx context.Context, skip int64, limit int64, state core.UserState) (auth.ListUsersResponse, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) GetUserRateLimit(ctx context.Context, name string, id string) (auth.GetUserRateLimitResponse, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) HasMiner(ctx context.Context, miner address.Address) (bool, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) ListMiners(ctx context.Context, user string) (auth.ListMinerResp, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) UpsertMiner(ctx context.Context, user string, miner string, openMining bool) (bool, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) HasSigner(ctx context.Context, signer address.Address) (bool, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) ListSigners(ctx context.Context, user string) (auth.ListSignerResp, error) {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) RegisterSigners(ctx context.Context, user string, addrs []address.Address) error {
panic("not implemented") // TODO: Implement
}

func (ia *IAuthClientStub) UnregisterSigners(ctx context.Context, user string, addrs []address.Address) error {
panic("not implemented") // TODO: Implement
}
2 changes: 1 addition & 1 deletion retrievalprovider/event_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
gatewayAPIV2 "github.com/filecoin-project/venus/venus-shared/api/gateway/v2"
)

func NewMarketEventStream(mCtx metrics.MetricsCtx, authClient *jwtclient.AuthClient) gatewayAPIV2.IMarketEvent {
func NewMarketEventStream(mCtx metrics.MetricsCtx, authClient jwtclient.IAuthClient) gatewayAPIV2.IMarketEvent {

marketStream := marketevent.NewMarketEventStream(mCtx, validator.NewMinerValidator(authClient), &types.RequestConfig{
RequestQueueSize: 30,
Expand Down

0 comments on commit e81ba4d

Please sign in to comment.