Пример #1
0
        public void TestVerifyExpiredUserWithCustomTime()
        {
            long     fake_current_unixtime = 1300157874 - 60;
            DateTime fake_current_dt       = new DateTime(1970, 1, 1).AddSeconds(fake_current_unixtime);

            string expired_user = DuoWeb.VerifyResponse(IKEY, SKEY, AKEY, EXPIRED_RESPONSE + ":" + OLD_REQUEST_APP_SIG, fake_current_dt);

            Assert.AreEqual(expired_user, USER);
        }
Пример #2
0
        public async Task <bool> ValidateAsync(string purpose, string token, UserManager <User> manager, User user)
        {
            var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Duo);

            if (!HasProperMetaData(provider))
            {
                return(false);
            }

            var response = DuoWeb.VerifyResponse((string)provider.MetaData["IKey"], (string)provider.MetaData["SKey"],
                                                 _globalSettings.Duo.AKey, token);

            return(response == user.Email);
        }
        public Task <bool> ValidateAsync(string token, Organization organization, User user)
        {
            if (organization == null || !organization.Enabled || !organization.Use2fa)
            {
                return(Task.FromResult(false));
            }

            var provider = organization.GetTwoFactorProvider(TwoFactorProviderType.OrganizationDuo);

            if (!HasProperMetaData(provider))
            {
                return(Task.FromResult(false));
            }

            var response = DuoWeb.VerifyResponse(provider.MetaData["IKey"].ToString(),
                                                 provider.MetaData["SKey"].ToString(), _globalSettings.Duo.AKey, token);

            return(Task.FromResult(response == user.Email));
        }
Пример #4
0
        private static string doPost(HttpListenerRequest request)
        {
            using (Stream body = request.InputStream)
            {
                using (StreamReader reader = new StreamReader(body, request.ContentEncoding))
                {
                    string bodyStream       = reader.ReadToEnd();
                    var    form             = bodyStream.Split('=');
                    var    sig_response_val = WebUtility.UrlDecode(form[1]);
                    string responseUser     = DuoWeb.VerifyResponse(ikey, skey, akey, sig_response_val);

                    if (string.IsNullOrEmpty(responseUser))
                    {
                        return("Did not authenticate with Duo.");
                    }

                    return($"Authenticated with Duo as {responseUser}.");
                }
            }
        }
Пример #5
0
        public void TestVerifyFutureUserWrongIkey()
        {
            string future_user = DuoWeb.VerifyResponse(WRONG_IKEY, SKEY, AKEY, FUTURE_RESPONSE + ":" + valid_app_sig);

            Assert.IsNull(future_user);
        }
Пример #6
0
        public void TestVerifyFutureUserWrongAppSigFormat()
        {
            string future_user = DuoWeb.VerifyResponse(IKEY, SKEY, AKEY, FUTURE_RESPONSE + ":" + WRONG_PARAMS_APP);

            Assert.IsNull(future_user);
        }
Пример #7
0
        public void TestVerifyFutureUserWrongResponseFormat()
        {
            string future_user = DuoWeb.VerifyResponse(IKEY, SKEY, AKEY, WRONG_PARAMS_RESPONSE + ":" + valid_app_sig);

            Assert.IsNull(future_user, USER);
        }
Пример #8
0
        public void TestVerifyFutureUserValidAppSig()
        {
            string future_user = DuoWeb.VerifyResponse(IKEY, SKEY, AKEY, FUTURE_RESPONSE + ":" + valid_app_sig);

            Assert.AreEqual(future_user, USER);
        }
Пример #9
0
        public void TestVerifyFutureUserInvalidAppSig()
        {
            string future_user = DuoWeb.VerifyResponse(IKEY, SKEY, AKEY, FUTURE_RESPONSE + ":" + invalid_app_sig);

            Assert.IsNull(future_user);
        }
Пример #10
0
        public void TestVerifyExpiredUser()
        {
            string expired_user = DuoWeb.VerifyResponse(IKEY, SKEY, AKEY, EXPIRED_RESPONSE + ":" + valid_app_sig);

            Assert.IsNull(expired_user);
        }
Пример #11
0
        public void TestVerifyInvalidUser()
        {
            string invalid_user = DuoWeb.VerifyResponse(IKEY, SKEY, AKEY, INVALID_RESPONSE + ":" + valid_app_sig);

            Assert.IsNull(invalid_user);
        }