public string AuthEventNotify( [FromQuery] string msg_signature, [FromQuery] string timestamp, [FromQuery] string nonce, [FromBody] ComponentNotifyModel componentNotifyModel) { _logger.LogInformation($"{nameof(msg_signature)} is {msg_signature}"); _logger.LogInformation($"{nameof(timestamp)} is {timestamp}"); _logger.LogInformation($"{nameof(nonce)} is {nonce}"); _logger.LogInformation(JsonConvert.SerializeObject(componentNotifyModel)); return(_componentAuthEventPublisher.AuthEventNotify(msg_signature, timestamp, nonce, componentNotifyModel)); }
public virtual string AuthEventNotify( string msg_signature, string timestamp, string nonce, ComponentNotifyModel componentNotifyModel) { if (string.IsNullOrEmpty(msg_signature)) { throw new ArgumentException($"“{nameof(msg_signature)}”不能是 Null 或为空。", nameof(msg_signature)); } if (string.IsNullOrEmpty(timestamp)) { throw new ArgumentException($"“{nameof(timestamp)}”不能是 Null 或为空。", nameof(timestamp)); } if (string.IsNullOrEmpty(nonce)) { throw new ArgumentException($"“{nameof(nonce)}”不能是 Null 或为空。", nameof(nonce)); } if (componentNotifyModel is null) { throw new ArgumentNullException(nameof(componentNotifyModel)); } if (WeChatComponentOptions is null) { throw new ArgumentNullException(nameof(WeChatComponentOptions)); } string signature = _tokenSignerProvider.SignWithToken(WeChatComponentOptions?.Token, timestamp, nonce, componentNotifyModel.Encrypt?.Trim()); if (msg_signature != signature) { throw new SignException("校验签名失败"); } ComponentNotifyModelDecrypted result = _componentAuthEventDecryptor.Decrypt(componentNotifyModel, new WeChatComponentDecryptorOption() { EncodingAESKey = WeChatComponentOptions?.EncodingAESKey }); if (result is ComponentVerifyTicketNotifyModel) { return(ComponentVerifyTicketNotifyHandler(result as ComponentVerifyTicketNotifyModel)); } return(null); }