/// <summary>
        /// Update method implmentation
        /// </summary>
        public void Load(PSHost host)
        {
            ManagementService.Initialize(host, true);
            MFAConfig   cfg = ManagementService.Config;
            OTPProvider otp = cfg.OTPProvider;

            this.IsDirty            = cfg.IsDirty;
            this.Enabled            = otp.Enabled;
            this.EnrollWizard       = otp.EnrollWizard;
            this.EnrollWizardStrict = otp.EnrollWizardStrict;
            this.Algorithm          = otp.Algorithm;
            this.TOTPShadows        = otp.TOTPShadows;
            this.WizardOptions      = otp.WizardOptions;
            this.PinRequired        = otp.PinRequired;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update method implmentation
        /// </summary>
        public override void Load(PSHost host)
        {
            ManagementService.Initialize(host, true);
            MFAConfig   cfg = ManagementService.Config;
            OTPProvider otp = cfg.OTPProvider;

            this.IsDirty       = cfg.IsDirty;
            this.Enabled       = otp.Enabled;
            this.EnrollWizard  = otp.EnrollWizard;
            this.ForceWizard   = otp.ForceWizard;
            this.Algorithm     = otp.Algorithm;
            this.TOTPShadows   = otp.TOTPShadows;
            this.WizardOptions = otp.WizardOptions;
            this.PinRequired   = otp.PinRequired;
            this.FullQualifiedImplementation = otp.FullQualifiedImplementation;
            this.Parameters = otp.Parameters.Data;
        }
        /// <summary>
        /// Update method implmentation
        /// </summary>
        public void Update(PSHost host)
        {
            ManagementService.Initialize(host, true);
            MFAConfig   cfg = ManagementService.Config;
            OTPProvider otp = cfg.OTPProvider;

            cfg.IsDirty            = true;
            otp.Enabled            = this.Enabled;
            otp.EnrollWizard       = this.EnrollWizard;
            otp.EnrollWizardStrict = this.EnrollWizardStrict;
            otp.Algorithm          = this.Algorithm;
            otp.TOTPShadows        = this.TOTPShadows;
            otp.WizardOptions      = this.WizardOptions;
            otp.PinRequired        = this.PinRequired;
            otp.PinRequired        = this.PinRequired;
            ManagementService.ADFSManager.WriteConfiguration(host);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update method implmentation
        /// </summary>
        public override void Update(PSHost host)
        {
            ManagementService.Initialize(host, true);
            MFAConfig   cfg = ManagementService.Config;
            OTPProvider otp = cfg.OTPProvider;

            cfg.IsDirty = true;
            CheckUpdates(host);
            otp.Enabled       = this.Enabled;
            otp.EnrollWizard  = this.EnrollWizard;
            otp.ForceWizard   = this.ForceWizard;
            otp.Algorithm     = this.Algorithm;
            otp.TOTPShadows   = this.TOTPShadows;
            otp.WizardOptions = this.WizardOptions;
            otp.PinRequired   = this.PinRequired;
            otp.FullQualifiedImplementation = this.FullQualifiedImplementation;
            otp.Parameters.Data             = this.Parameters;
            ManagementService.ADFSManager.WriteConfiguration(host);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Authenticate users one time passcode against the OASIS platform
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool Authenticate(string username, string password, string clientIP = null)
        {
            var apiKey = ConfigurationManager.AppSettings["OASISApiKey"];
            var appKey = ConfigurationManager.AppSettings["OASISAppKey"];
            var appID  = long.Parse(ConfigurationManager.AppSettings["OASISAppID"]);

            if (!string.IsNullOrEmpty(clientIP) && (clientIP.Equals("127.0.0.1") || clientIP.Equals("::1")))
            {
                clientIP = null;
            }

            var oasis = new OTPProvider(appID, appKey, apiKey, RemoteIP: clientIP);

            var state = oasis.RequestAuthorisationState(new RequestAuthorisationState
            {
                Username         = username,
                VerificationType = VerificationTypeEnum.LOGIN
            });

            if (state.State == UserAuthenticatorStateEnum.SKIPAUTHENTICATION)
            {
                return(true);
            }

            if (state.State != UserAuthenticatorStateEnum.AUTHENTICATE)
            {
                return(false);
            }

            var result = oasis.VerifyUserOTP(new VerifyUserOTP
            {
                Username         = username,
                OTPCode          = password,
                VerificationType = VerificationTypeEnum.LOGIN
            });

            return(result.State == UserAuthenticatorStateEnum.VALID);
        }
Ejemplo n.º 6
0
        public HttpResponseMessage Login(string u, string p)
        {
            string otp  = string.Empty;
            bool   flag = false;

            using (SpareDBContext db = new SpareDBContext())
            {
                try
                {
                    string    encriptedPassword = Common.EncryptData(p);
                    LoginUser usr = db.LoginUsers.FirstOrDefault(a => a.LoginID.Trim().Equals(u, StringComparison.OrdinalIgnoreCase) && a.Password.Equals(encriptedPassword) && a.HasOTP == false);
                    if (usr != null)
                    {
                        otp        = OTPProvider.GetOTP();
                        usr.Token  = Common.EncryptData(otp);
                        usr.HasOTP = true;
                        db.SaveChanges();
                        if (!string.IsNullOrEmpty(usr.Phone.ToString()))
                        {
                            flag = SMSProvider.SendSMS(usr.Phone.ToString(), otp);
                        }
                        if (flag)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, "OTP Send To Your Registered Mobile."));
                        }
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Please register a mobole no first."));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotFound, "User Not Found, Please Cheak Combination!"));
                    }
                }
                catch
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Internal server Error!"));
                }
            }
        }