Ejemplo n.º 1
0
        internal bool ValidateRequest(NativeRequestContext requestMemory)
        {
            try
            {
                // Block potential DOS attacks
                if (requestMemory.UnknownHeaderCount > UnknownHeaderLimit)
                {
                    SendError(requestMemory.RequestId, StatusCodes.Status400BadRequest, authChallenges: null);
                    return(false);
                }

                if (!Options.Authentication.AllowAnonymous && !requestMemory.CheckAuthenticated())
                {
                    SendError(requestMemory.RequestId, StatusCodes.Status401Unauthorized,
                              AuthenticationManager.GenerateChallenges(Options.Authentication.Schemes));
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Log.RequestValidationFailed(Logger, ex, requestMemory.RequestId);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
 internal unsafe bool ValidateAuth(NativeRequestContext requestMemory)
 {
     if (!Options.Authentication.AllowAnonymous && !requestMemory.CheckAuthenticated())
     {
         SendError(requestMemory.RequestId, StatusCodes.Status401Unauthorized,
                   AuthenticationManager.GenerateChallenges(Options.Authentication.Schemes));
         return(false);
     }
     return(true);
 }