Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop refreshing when a subject has no active DID Documents #3461

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func CreateSystem(shutdownCallback context.CancelFunc) *core.System {
vdrInstance := vdr.NewVDR(cryptoInstance, networkInstance, didStore, eventManager, storageInstance)
credentialInstance := vcr.NewVCRInstance(cryptoInstance, vdrInstance, networkInstance, jsonld, eventManager, storageInstance, pkiInstance)
didmanInstance := didman.NewDidmanInstance(vdrInstance, credentialInstance, jsonld)
discoveryInstance := discovery.New(storageInstance, credentialInstance, vdrInstance)
discoveryInstance := discovery.New(storageInstance, credentialInstance, vdrInstance, vdrInstance)
authInstance := auth.NewAuthInstance(auth.DefaultConfig(), vdrInstance, vdrInstance, credentialInstance, cryptoInstance, didmanInstance, jsonld, pkiInstance)
statusEngine := status.NewStatusEngine(system)
metricsEngine := core.NewMetricsEngine()
Expand Down
24 changes: 22 additions & 2 deletions discovery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/nuts-foundation/nuts-node/vcr/pe"
"github.com/nuts-foundation/nuts-node/vcr/signature/proof"
"github.com/nuts-foundation/nuts-node/vdr/didsubject"
"github.com/nuts-foundation/nuts-node/vdr/resolver"
"slices"
"strings"
"time"
Expand All @@ -56,15 +57,17 @@ type defaultClientRegistrationManager struct {
client client.HTTPClient
vcr vcr.VCR
subjectManager didsubject.Manager
didResolver resolver.DIDResolver
}

func newRegistrationManager(services map[string]ServiceDefinition, store *sqlStore, client client.HTTPClient, vcr vcr.VCR, subjectManager didsubject.Manager) *defaultClientRegistrationManager {
func newRegistrationManager(services map[string]ServiceDefinition, store *sqlStore, client client.HTTPClient, vcr vcr.VCR, subjectManager didsubject.Manager, didResolver resolver.DIDResolver) *defaultClientRegistrationManager {
return &defaultClientRegistrationManager{
services: services,
store: store,
client: client,
vcr: vcr,
subjectManager: subjectManager,
didResolver: didResolver,
}
}

Expand All @@ -87,9 +90,26 @@ func (r *defaultClientRegistrationManager) activate(ctx context.Context, service
}
}
subjectDIDs = subjectDIDs[:j]

if len(subjectDIDs) == 0 {
return fmt.Errorf("%w: %w for %s", ErrPresentationRegistrationFailed, ErrDIDMethodsNotSupported, subjectID)
}
}

// and filter by deactivated status
j := 0
for i, did := range subjectDIDs {
_, _, err := r.didResolver.Resolve(did, nil)
// any temporary error, like db errors should not cause a deregister action, only ErrDeactivated
if err == nil || !errors.Is(err, resolver.ErrDeactivated) {
subjectDIDs[j] = subjectDIDs[i]
j++
}
}
subjectDIDs = subjectDIDs[:j]

if len(subjectDIDs) == 0 {
return fmt.Errorf("%w: %w for %s", ErrPresentationRegistrationFailed, ErrDIDMethodsNotSupported, subjectID)
return fmt.Errorf("%w: %w for %s", ErrPresentationRegistrationFailed, didsubject.ErrSubjectNotFound, subjectID)
}

log.Logger().Debugf("Registering Verifiable Presentation on Discovery Service (service=%s, subject=%s)", service.ID, subjectID)
Expand Down
Loading
Loading