when validating documents at the sync gateway using the sync function, is it possible to call an external service with some parameters, wait for the response and then act accordingly? The external service could be a network call (https, websocket etc.) or a call to a local file that runs the validations.
Background: we want to verify a digital signature contained in a document before accepting it. This requires fetching the certificate chain of trust and then calling some crypto implementation to verify the signature.
Functional gaps aside, there are perf & security implications to consider when you are calling into external services when processing replications.
One possible workflow
Include a “status” field in the document. Set to “pre-validate”. Configure SGW to ignore docs with that status in import
Every time a document is stored in bucket, trigger eventing service event or a webhooks event that can then call external service to do the validation. Once validated, that external service must update the status field of document to “validated” = SGW can then process the doc and make it available for replication