Exemple #1
0
 public static bool OtpMatchesDevice(string otp, string deviceId)
 {
     if (OtpCache.TryGetValue(otp, out string cachedDevice) &&
         cachedDevice == deviceId)
     {
         return(true);
     }
     return(false);
 }
Exemple #2
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            if (!AppConfig.RemoteControlRequiresAuthentication)
            {
                return;
            }

            if (context.HttpContext.User.Identity.IsAuthenticated)
            {
                return;
            }

            if (context.HttpContext.Request.Query.TryGetValue("otp", out var otp) &&
                OtpCache.TryGetValue(otp.ToString(), out _))
            {
                return;
            }

            context.Result = new RedirectToPageResult("/Account/Login", new { area = "Identity" });
        }