Verbesserung Auth, Webhook-Handling & Codacy-Integration
- BasicAuthenticationAttribute: AllowAnonymous-Handling ergänzt, Fehlerbehandlung für ungültige Header verbessert, WWW-Authenticate-Header korrigiert, Credential-Handling robuster gestaltet. - WiseController: Webhook akzeptiert jetzt JSON und Text, asynchrone Verarbeitung, robustere Deserialisierung, <AllowAnonymous> auf Klassenebene. - WiseWebhookExampleProcessor: OpenAPI/Swagger-Doku erweitert (application/json & text/plain, Beispiele, flexiblere Schemas). - SwaggerConfig: Unsichtbares Zeichen entfernt. - .gitignore: Codacy-spezifische Anweisungen ausgeschlossen. - codacy.instructions.md: Neue Datei mit KI-Verhaltensregeln für Codacy-Analysen hinzugefügt.
This commit is contained in:
@@ -3,33 +3,39 @@ Imports System.IO
|
||||
Imports System.Web.Http
|
||||
Imports System.Web.Http.Description
|
||||
Imports System.Diagnostics
|
||||
Imports System.Threading.Tasks
|
||||
Imports Newtonsoft.Json
|
||||
Imports VERAG_PROG_ALLGEMEIN
|
||||
Imports VERAG_REST_SERVER
|
||||
|
||||
Namespace ApiController.Controllers
|
||||
<RoutePrefix("wise")>
|
||||
<AllowAnonymous>
|
||||
Public Class WiseController
|
||||
Inherits System.Web.Http.ApiController
|
||||
|
||||
<HttpPost>
|
||||
<Route("webhook")>
|
||||
<AllowAnonymous>
|
||||
<ResponseType(GetType(Void))>
|
||||
Public Function Webhook(<FromBody> payload As WiseWebhookRequest) As IHttpActionResult
|
||||
Dim json As String = ""
|
||||
Public Async Function Webhook() As Task(Of IHttpActionResult)
|
||||
Dim rawContent As String = ""
|
||||
Dim payload As WiseWebhookRequest = Nothing
|
||||
|
||||
Try
|
||||
If payload IsNot Nothing Then
|
||||
json = JsonConvert.SerializeObject(payload)
|
||||
Else
|
||||
If Request IsNot Nothing AndAlso Request.Content IsNot Nothing Then
|
||||
json = Request.Content.ReadAsStringAsync().Result
|
||||
End If
|
||||
If Request IsNot Nothing AndAlso Request.Content IsNot Nothing Then
|
||||
rawContent = Await Request.Content.ReadAsStringAsync()
|
||||
End If
|
||||
|
||||
If Not String.IsNullOrEmpty(rawContent) Then
|
||||
Try
|
||||
payload = JsonConvert.DeserializeObject(Of WiseWebhookRequest)(rawContent)
|
||||
Catch
|
||||
End Try
|
||||
End If
|
||||
Catch
|
||||
End Try
|
||||
|
||||
Dim saveResult = SaveWiseWebhook(json, payload)
|
||||
Dim saveResult = SaveWiseWebhook(rawContent, payload)
|
||||
If payload Is Nothing Then
|
||||
' Invalid JSON or empty body, but Wise expects 200 OK
|
||||
Return Ok()
|
||||
|
||||
Reference in New Issue
Block a user