public async Task <IActionResult> ExtensionWebHookHandler(string extensionName, CancellationToken token, [FromServices] IScriptWebHookProvider provider) { if (provider.TryGetHandler(extensionName, out HttpHandler handler)) { var requestMessage = new HttpRequestMessageFeature(this.HttpContext).HttpRequestMessage; HttpResponseMessage response = await handler.ConvertAsync(requestMessage, token); var result = new ObjectResult(response); result.Formatters.Add(new HttpResponseMessageOutputFormatter()); return(result); } return(NotFound()); }
public async Task <IActionResult> ExtensionWebHookHandler(string name, CancellationToken token, [FromServices] IScriptWebHookProvider provider) { if (provider.TryGetHandler(name, out HttpHandler handler)) { // must either be authorized at the admin level, or system level with // a matching key name string keyName = DefaultScriptWebHookProvider.GetKeyName(name); if (!AuthUtility.PrincipalHasAuthLevelClaim(User, AuthorizationLevel.System, keyName)) { return(Unauthorized()); } var requestMessage = new HttpRequestMessageFeature(this.HttpContext).HttpRequestMessage; HttpResponseMessage response = await handler.ConvertAsync(requestMessage, token); var result = new ObjectResult(response); result.Formatters.Add(new HttpResponseMessageOutputFormatter()); return(result); } return(NotFound()); }
public async Task <IActionResult> ExtensionWebHookHandler(string name, CancellationToken token, [FromServices] IScriptWebHookProvider provider) { if (provider.TryGetHandler(name, out HttpHandler handler)) { string keyName = DefaultScriptWebHookProvider.GetKeyName(name); var authResult = await _authorizationService.AuthorizeAsync(User, keyName, PolicyNames.SystemAuthLevel); if (!authResult.Succeeded) { return(Unauthorized()); } var requestMessage = new HttpRequestMessageFeature(this.HttpContext).HttpRequestMessage; HttpResponseMessage response = await handler.ConvertAsync(requestMessage, token); var result = new ObjectResult(response); result.Formatters.Add(new HttpResponseMessageOutputFormatter()); return(result); } return(NotFound()); }