Skip to content

Commit

Permalink
feat: Check resource provider when allowlist enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bgins committed Jan 10, 2025
1 parent 3b217b7 commit 3a67aaa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/solver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
corehttp "net/http"
"os"
"path/filepath"
"slices"
"time"

"github.com/go-chi/httprate"
Expand Down Expand Up @@ -308,6 +309,21 @@ func (solverServer *solverServer) addResourceOffer(resourceOffer data.ResourceOf
if signerAddress != resourceOffer.ResourceProvider {
return nil, fmt.Errorf("resource provider address does not match signer address")
}

// Resource provider must be in allowlist when enabled
if solverServer.options.AccessControl.EnableResourceProviderAllowlist {
allowedProviders, err := solverServer.store.GetAllowedResourceProviders()
if err != nil {
log.Error().Err(err).Msgf("Unable to load resource provider allowlist: %s", err)
return nil, err
}

if !slices.Contains(allowedProviders, resourceOffer.ResourceProvider) {
log.Debug().Msgf("resource provider not in allowlist %s", resourceOffer.ResourceProvider)
return nil, errors.New("resource provider not in beta program, request beta program access here: https://forms.gle/XaE3rRuXVLxTnZto7")
}
}

err = data.CheckResourceOffer(resourceOffer)
if err != nil {
log.Error().Err(err).Msgf("Error checking resource offer")
Expand Down

0 comments on commit 3a67aaa

Please sign in to comment.