Make login configuration consistent.
431129
def sanitize_loginurl (self):
        """"""
        url = self["loginurl"]
        disable = False
        if not self["loginpasswordfield"]:
            log.warn(LOG_CHECK,
            _("no CGI password fieldname given for login URL."))
            disable = True
        if not self["loginuserfield"]:
            log.warn(LOG_CHECK,
            _("no CGI user fieldname given for login URL."))
            disable = True
        if self.get_user_password(url) == (None, None):
            log.warn(LOG_CHECK,
            _("no user/password authentication data found for login URL."))
            disable = True
        if not url.lower().startswith(("http:", "https:")):
            log.warn(LOG_CHECK, _("login URL is not a HTTP URL."))
            disable = True
        urlparts = urlparse.urlsplit(url)
        if not urlparts[0] or not urlparts[1] or not urlparts[2]:
            log.warn(LOG_CHECK, _("login URL is incomplete."))
            disable = True
        if disable:
            log.warn(LOG_CHECK,
              _("disabling login URL %(url)s.") % {"url": url})
            self["loginurl"] = None
866898
def _init_browser(self):
        """"""
        self.browser = splinter.Browser('phantomjs')
        self.browser.visit(self.server_url + "/youraccount/login")
        try:
            self.browser.fill('nickname', self.user)
            self.browser.fill('password', self.password)
        except:
            self.browser.fill('p_un', self.user)
            self.browser.fill('p_pw', self.password)
        self.browser.fill('login_method', self.login_method)
        self.browser.find_by_css('input[type=submit]').click()
28758
def check_config(db, level):
    """"""
    if level == 'global':
        configuration = config.read(config.HOMEDIR, '.passpierc')
    elif level == 'local':
        configuration = config.read(os.path.join(db.path))
    elif level == 'current':
        configuration = db.config

    if configuration:
        click.echo(yaml.safe_dump(configuration, default_flow_style=False))
872761
def login():
    """"""

    form_class = _security.login_form

    if request.is_json:
        form = form_class(MultiDict(request.get_json()))
    else:
        form = form_class(request.form)

    if form.validate_on_submit():
        login_user(form.user, remember=form.remember.data)
        after_this_request(_commit)

        if not request.is_json:
            return redirect(get_post_login_redirect(form.next.data))

    if request.is_json:
        return _render_json(form, include_auth_token=True)

    return _security.render_template(config_value('LOGIN_USER_TEMPLATE'),
                                     login_user_form=form,
                                     **_ctx('login'))
1368024
def save_user_config(username, conf_dict, path=settings.LOGIN_FILE):
    
    users = load_users(path=path)
    users[username]["full_name"] = _encode_config(conf_dict)
    save_users(users, path=path)
399218
private void setupDefaultUser()
    {
        try
        {
            // insert the default superuser if AUTH_KS.CREDENTIALS_CF is empty.
            if (!hasExistingUsers())
            {
                process(String.format("INSERT INTO %s.%s (username, salted_hash) VALUES ('%s', '%s') USING TIMESTAMP 0",
                                      Auth.AUTH_KS,
                                      CREDENTIALS_CF,
                                      DEFAULT_USER_NAME,
                                      escape(hashpw(DEFAULT_USER_PASSWORD))),
                        ConsistencyLevel.ONE);
                logger.info("PasswordAuthenticator created default user '{}'", DEFAULT_USER_NAME);
            }
        }
        catch (RequestExecutionException e)
        {
            logger.warn("PasswordAuthenticator skipped default user setup: some nodes were not ready");
        }
    }
36766
def init_login(self, from_local=False):
        """"""
        if self.toolbar:
            self.removeToolBar(self.toolbar)
        widget_login = login.Loading(self.statusBar(), self.theory_main)
        self.centralWidget().addWidget(widget_login)
        widget_login.loaded.connect(self.init_tabs)
        widget_login.canceled.connect(self._quit)
        widget_login.updated.connect(self.on_update_at_launch)
        if from_local:
            widget_login.propose_load_local()
        else:
            self.statusBar().showMessage("Données chargées depuis le serveur.", 5000)
799109
def _init_login_manager(app_):
    """"""
    login_manager = flogin.LoginManager()
    login_manager.setup_app(app_)
    login_manager.anonymous_user = Anonymous
    login_manager.login_view = "login"

    users = {app_.config['USERNAME']: User('Admin', 0)}
    names = dict((int(v.get_id()), k) for k, v in users.items())

    @login_manager.user_loader
    def load_user(userid):
        userid = int(userid)
        name = names.get(userid)
        return users.get(name)

    return users, names
227780
def setConfiguration(self, configuration):
        
        """
        if isinstance(configuration, Configuration):
           configuration = configuration.value

        self.dev.set_configuration(configuration)
1286851
def commit_config(self):
        """"""
        commands = []
        commands.append('copy startup-config flash:rollback-0')
        commands.append('configure session {}'.format(self.config_session))
        commands.append('commit')
        commands.append('write memory')

        self.device.run_commands(commands)
        self.config_session = None
744681
protected static function login() :void {
		
		// look for users with this login
		$account = \Models\Accounts::getFirstEnabledWithLogin(
			Request::post( Config::get('security', 'login') )
		);
		// if the account does not exist/is not found
		if(!$account) {
			// we deny access
			self::refuse('Account does not exist or is disabled'); 
		}
		// if the account has been forced by that ip recently
		if($account->hasFailedLoginAttemptsRecentFrom(self::getSafeRemoteAddress())) {
			// extend the lock on the account
			$account->extendLoginBan();
			// refuse access
			self::refuse('Please wait '.Config::get('security', 'waiting_duration').' seconds before trying again');
		}
		// if the account has expired
		if($account->hasItsValidityExpired()) {
			// register that failure
			$account->registerFailedLoginAttemptFrom(self::getSafeRemoteAddress(), self::getSafeUserAgent());
			// refuse access
			self::refuse("Your account has expired, it was valid until {$account->get('account_expiration_date')}");	
		}
		// if the posted password doesn't match the account's password
		if(!$account->hasThisPassword(Request::post(Config::get('security', 'password')))) {
			// register that failure
			$account->registerFailedLoginAttemptFrom(self::getSafeRemoteAddress(), self::getSafeUserAgent());
			// refuse access
			self::refuse('Wrong password');
		}
		// if we failed to open a session
		if(!$account->tryOpeningSession()) {
			// we report that something is wrong
			self::refuse('Your session failed to open, make sure your browser accepts cookies', 500);
		}
		// then session has been opened
		else {
			// log the loggin action
			Logger::info("Account {$account->get('login')} has logged in");
			// put the user inside of us
			self::$_account = $account;
			// set the most basic authentication block as being true/passed
			self::$_granted = true;
			// if we have an url in the session, redirect to it (and remove it)
			!Session::has('previously_requested_url') ?: self::redirectToThePreviouslyRequestedUrl();
		}
		
	}
699531
def login(self, schema, username, password):
        
        self.schema = schema
        self.username = username
        self.password = password
        self.connection = schema
1212357
def store_login_attempt(user_agent, ip_address, username,
                        http_accept, path_info, login_valid):
    
    AccessAttempt.objects.create(
        user_agent=user_agent,
        ip_address=ip_address,
        username=username,
        http_accept=http_accept,
        path_info=path_info,
        login_valid=login_valid,
    )
1114770
function equalConfig(page, oldPage) {
  const keys = Object.keys(page.config || {});
  const oldKeys = Object.keys(oldPage.config || {});

  if (keys.length !== oldKeys.length) return false;
  if (keys.some(key => page.config[key] !== oldPage.config[key])) return false;
  return true;
}
706500
public static function configureSession() : void
    {
        // Session runtime configuration    http://php.net/manual/en/session.configuration.php
        if (session_status() !== \PHP_SESSION_ACTIVE ) {
            session_start([
                'cookie_httponly'  => true,
                'cookie_secure'    => \PHUNDER_SESSION_HTTPS,
                'name'             => \PHUNDER_SESSION_NAME,
                'use_cookies'      => true,
                'use_only_cookies' => true,
                'use_trans_sid'    => false
            ]);
        }



        // Session id auto regeneration

        // mode: time
        $regen_time_modes = [
            \PHUNDER_SESSION_REGENERATE_MODE_BOTH,
            \PHUNDER_SESSION_REGENERATE_MODE_TIME
        ];
        $regenerate_on_time  = in_array(\PHUNDER_SESSION_REGENERATE_MODE, $regen_time_modes);

        if ($regenerate_on_time) {
            if (!isset($_SESSION['phunder']['regen_time'])) {
                $_SESSION['phunder']['regen_time'] = time();
            }
            if (time() > ($_SESSION['phunder']['regen_time'] + \PHUNDER_SESSION_REGENERATE_TIME)) {
                session_regenerate_id(true);
                $_SESSION['phunder']['regen_time']    = time();
                $_SESSION['phunder']['regen_request'] = 1;
            }
        }

        // mode: request
        $regen_request_modes = [
            \PHUNDER_SESSION_REGENERATE_MODE_BOTH,
            \PHUNDER_SESSION_REGENERATE_MODE_REQUEST
        ];
        $regenerate_on_request = in_array(\PHUNDER_SESSION_REGENERATE_MODE, $regen_request_modes);

        if ($regenerate_on_request) {
            if (!isset($_SESSION['phunder']['regen_request'])) {
                $_SESSION['phunder']['regen_request'] = 1;
            }
            if (time() > ($_SESSION['phunder']['regen_request'] + \PHUNDER_SESSION_REGENERATE_REQUEST_AMOUNT)) {
                session_regenerate_id(true);
                $_SESSION['phunder']['regen_request'] = 1;
                $_SESSION['phunder']['regen_time']    = time();
            }
            $_SESSION['phunder']['regen_request']++;
        }



        // Current user setup
        if (!isset($_SESSION['phunder']['user']['logged_in'])) {
            $_SESSION['phunder']['user']['logged_in'] = false;
        }
    }
975956
def accept(self):
        """"""
        if not self.runconfigoptions.is_valid():
            return
        configurations = _get_run_configurations()
        configurations.insert(0, (self.filename, self.runconfigoptions.get()))
        _set_run_configurations(configurations)
        QDialog.accept(self)
1268724
def login(self, password):
        """"""

        if self.logged_in:
            raise RuntimeError("User already logged in!")

        params = {"name": self.nick, "password": password}
        resp = self.conn.make_api_call("login", params)
        if "error" in resp:
            raise RuntimeError(
                f"Login failed: {resp['error'].get('message') or resp['error']}"
            )
        self.session = resp["session"]
        self.conn.make_call("useSession", self.session)
        self.conn.cookies.update({"session": self.session})
        self.logged_in = True
        return True