Esempio n. 1
0
 /// <summary>
 /// Create a new RequestResponseInterceptor instance
 /// </summary>
 /// <param name="options">Options configuration</param>
 /// <param name="logger">Logger object</param>
 /// <param name="accessor">Http context accessor</param>
 public RequestResponseInterceptor(IOptions <RequestResponseMiddlewareOptions> options, ILogger <TCategory> logger, IHttpContextAccessor accessor) : base()
 {
     _options  = options?.Value;
     _logger   = logger;
     _accessor = accessor;
     _traceId  = _accessor.HttpContext.TraceIdentifier;
 }
Esempio n. 2
0
        /// <summary>
        /// Apply security analysis to preserve sensitive information
        /// </summary>
        /// <param name="options">Options configuration</param>
        /// <param name="httpVerb">Http verb action (method)</param>
        /// <param name="path">Route path</param>
        /// <param name="body">Request body</param>
        internal static string SecurityApplyBody(RequestResponseMiddlewareOptions options, string httpVerb, string path, string body)
        {
            IEnumerable <string> secList = new List <string>();

            if (options?.SecurityActions != null)
            {
                secList = options?
                          .SecurityActions
                          .Select(s => $"{s.Method.ToUpper()}:{s.Path.ToLower()}")
                          .ToList();
            }

            string action = $"{httpVerb.ToUpper()}:{path.ToLower()}";

            if (secList.Contains(action))
            {
                body = "*** OMITTED FOR SECURITY ***";
            }

            return(body);
        }
Esempio n. 3
0
        /// <summary>
        /// Checks whether the action is in the list of actions to be ignored
        /// </summary>
        /// <param name="options">Options configuration</param>
        /// <param name="httpVerb">Http verb action (method)</param>
        /// <param name="path">Route path</param>
        internal static bool IsIgnoreAction(RequestResponseMiddlewareOptions options, string httpVerb, string path)
        {
            IEnumerable <string> ignoredList = new List <string>();

            if (options?.IgnoreActions != null)
            {
                ignoredList = options?
                              .IgnoreActions
                              .Select(s => $"{s.Method.ToUpper()}:{s.Path.ToLower()}")
                              .ToList();
            }

            string action = $"{httpVerb.ToUpper()}:{path.ToLower()}";

            if (ignoredList.Contains(action))
            {
                return(true);
            }

            return(false);
        }
 /// <summary>
 /// Create a new RequestResponseLogging instance
 /// </summary>
 /// <param name="next">Request delegate</param>
 /// <param name="logger">Logger object</param>
 /// <param name="options">Options configuration</param>
 public RequestResponseLogging(RequestDelegate next, ILogger <TCategory> logger, IOptions <RequestResponseMiddlewareOptions> options)
 {
     _next    = next;
     _logger  = logger;
     _options = options?.Value;
 }