Example #1
0
        /// <summary>
        /// Creates a pop-up window
        /// </summary>
        /// <param name="sender">Profile select panel</param>
        /// <param name="e">Event parameters</param>
        public TwoFactorEnrollmentPopup(object sender, RequestTwoFactorEnrollmentEventArgs e)
        {
            var selection_panel = sender as ConnectingSelectPanel;

            User = e.User;
            AuthenticatingInstance = e.AuthenticatingInstance;
            Profile = e.Profile;

            // Prepare the list of methods.
            var last_method = Properties.Settings.Default.InstanceSettings.TryGetValue(AuthenticatingInstance.Base.AbsoluteUri, out var settings) ? settings.LastTwoFactorAuthenticationMethod : null;

            MethodList = new ObservableCollection <TwoFactorAuthenticationBasePanel>();
            TwoFactorAuthenticationBasePanel method;

            if (Profile.TwoFactorMethods.HasFlag(TwoFactorAuthenticationMethods.TOTP))
            {
                MethodList.Add(method = new TOTPEnrollmentPanel(selection_panel.Wizard, AuthenticatingInstance));
                if (last_method == method.ID)
                {
                    _selected_method = method;
                }
            }
            if (Profile.TwoFactorMethods.HasFlag(TwoFactorAuthenticationMethods.YubiKey))
            {
                MethodList.Add(method = new YubiKeyAuthenticationPanel(selection_panel.Wizard, AuthenticatingInstance));
                if (last_method == method.ID)
                {
                    _selected_method = method;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Creates a pop-up window
        /// </summary>
        /// <param name="sender">VPN session</param>
        /// <param name="e">Event arguments</param>
        public TwoFactorAuthenticationPopup(object sender, UsernamePasswordAuthenticationRequestedEventArgs e) :
            base(sender, e)
        {
            var session = sender as VPNSession;

            // Query profile supported & user enrolled 2-Factor authentication methods.
            var methods = TwoFactorAuthenticationMethods.Any;

            if (Session.ConnectingProfile.IsTwoFactorAuthentication)
            {
                methods &= Session.ConnectingProfile.TwoFactorMethods;
            }
            if (Session.UserInfo.IsTwoFactorAuthentication)
            {
                methods &= Session.UserInfo.TwoFactorMethods;
            }

            // Prepare the list of methods.
            var last_method = Properties.Settings.Default.InstanceSettings.TryGetValue(session.AuthenticatingInstance.Base.AbsoluteUri, out var settings) ? settings.LastTwoFactorAuthenticationMethod : null;

            MethodList = new ObservableCollection <TwoFactorAuthenticationBasePanel>();
            TwoFactorAuthenticationBasePanel method;

            if (methods.HasFlag(TwoFactorAuthenticationMethods.TOTP))
            {
                MethodList.Add(method = new TOTPAuthenticationPanel(session.Wizard, session.AuthenticatingInstance));
                if (last_method == method.ID)
                {
                    _selected_method = method;
                }
            }
            if (methods.HasFlag(TwoFactorAuthenticationMethods.YubiKey))
            {
                MethodList.Add(method = new YubiKeyAuthenticationPanel(session.Wizard, session.AuthenticatingInstance));
                if (last_method == method.ID)
                {
                    _selected_method = method;
                }
            }
        }