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 17, 2025
1 parent b4fb0f3 commit 4b4117f
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 @@ -9,6 +9,7 @@ import (
corehttp "net/http"
"os"
"path/filepath"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -312,6 +313,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 4b4117f

Please sign in to comment.