Example #1
0
        private async Task <bool> ValidateHmacSha1SignatureAsync(FissionContext context)
        {
            HmacSha1Attribute attr = _info.GetCustomAttribute <HmacSha1Attribute>(true);

            if (attr != null)
            {
                return(await attr.IsSignatureValidAsync(context));
            }

            return(true); // if attr is null then no hmacsha1 validation was specified
        }
Example #2
0
        public async Task <IActionResult> ExecuteFunction()
        {
            FissionContext ctx = new FissionContext(Request, Response, _logger);

            if (_cache.TryGetValue("func", out Function function) == false)
            {
                _logger.LogCritical("Generic container: no requests supported");
                Console.WriteLine("Generic container: this container does not contantn the fuccion reqeusted OR no requests supported");
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            return(await function.Invoke(ctx));
        }
Example #3
0
        public Task <IActionResult> Invoke(FissionContext context)
        {
            if (ValidateMethod(context.Request.Method) == false)
            {
                return(Task.FromResult((IActionResult) new StatusCodeResult((int)HttpStatusCode.MethodNotAllowed)));
            }

            if (ValidateHmacSha1SignatureAsync(context).Result == false)
            {
                return(Task.FromResult((IActionResult) new StatusCodeResult((int)HttpStatusCode.Forbidden)));
            }

            string funcName = _info.GetCustomAttribute <FunctionNameAttribute>()?.Name;

            context.Logger.LogInformation($"Function Name Called: {funcName}");

            return((Task <IActionResult>)_info.Invoke(_assembly.CreateInstance(_type.FullName), new[] { context }));
        }