Ejemplo n.º 1
0
 public override void OnActionExecuted(ActionExecutedContext context)
 {
     if (context.Exception != null)
     {
         LoggingBootstrapper.GetLogger().Fatal(context.Exception, GetUserDetails((PhoenixBaseController)context.Controller));
     }
     base.OnActionExecuted(context);
 }
Ejemplo n.º 2
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var apiKey   = context.HttpContext.Request.Query["ApiKey"];
            var jwtToken = context.HttpContext.Request.Query.ContainsKey("ApiKey")
                ? GetTokenFromApiKeyAsync(context.HttpContext.Request.Query["ApiKey"])
                : GetAuthJwtToken(context)
            ;

            try
            {
                var key          = SigningCertificate.Load().GetRSAPrivateKey();
                var payload      = JWT.Decode <JwtToken>(jwtToken.Replace("Bearer ", ""), key, JwsAlgorithm.RS256);
                var tokenExpires = DateTimeOffset.FromUnixTimeSeconds(payload.exp);
                _user = tokenExpires > DateTime.UtcNow ? _userManager.SetUser(payload, jwtToken) : null;
            }
            catch (Exception e)
            {
                LoggingBootstrapper.GetLogger().Fatal(e);
                _user = null;
            }

            base.OnActionExecuting(context);
        }
Ejemplo n.º 3
0
 private static void LogNetworkCall(ResultExecutedContext context, int duration = 0)
 {
     LoggingBootstrapper.GetLogger().Network(context.HttpContext.Request.Method,
                                             (HttpStatusCode)context.HttpContext.Response.StatusCode, context.HttpContext.Request.Path, duration,
                                             Service.Config.ServiceConfiguration?.ServiceId, GetUserDetails((PhoenixBaseController)context.Controller));
 }