Пример #1
0
 public Task <ActionResult> GetTopicUpdate([FromRoute] string topic, [FromBody] PresentationUpdate update)
 {
     return(ProcessWebhook(null, topic, update));
 }
Пример #2
0
        private async Task <ActionResult> ProcessWebhook(string apiKey, string topic, PresentationUpdate update)
        {
            if (!string.IsNullOrEmpty(_config.GetValue <string>("ApiKey")) && !string.Equals(_config.GetValue <string>("ApiKey"), apiKey))
            {
                _logger.LogDebug($"Web hook operation un-authorized");
                return(Unauthorized());
            }

            if (string.Equals(ACAPYConstants.PresentationsTopic, topic, StringComparison.InvariantCultureIgnoreCase) == false)
            {
                _logger.LogDebug($"Skipping webhook for topic [{topic}]");
                return(Ok());
            }

            _logger.LogDebug($"Received web hook update object : {update.ToJson()}");

            try
            {
                if (update.State != ACAPYConstants.SuccessfulPresentationUpdate)
                {
                    return(Ok());
                }

                var proof = update.Presentation["requested_proof"].ToObject <RequestedProof>();
                var partialPresentation = new Presentation
                {
                    RequestedProof = proof
                };

                _logger.LogDebug($"Marking Presentation Request with id : {update.PresentationExchangeId} as satisfied");

                await _sessionStorageService.SatisfyPresentationRequestIdAsync(update.PresentationExchangeId, partialPresentation);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to deserialize a payload");
            }

            return(Ok());
        }
Пример #3
0
 public Task <ActionResult> GetTopicUpdateWithApiKey([FromRoute] string apiKey, [FromRoute] string topic, [FromBody] PresentationUpdate update)
 {
     return(ProcessWebhook(apiKey, topic, update));
 }