Will get called before the login page is shownr. Ff NTLM SSO
is enabled, and the user is in the right network, we'll redirect
to the magic NTLM page for SSO...
189297
function loginpage_hook() {
        global $CFG, $SESSION;

        // HTTPS is potentially required
        //httpsrequired(); - this must be used before setting the URL, it is already done on the login/index.php

        if (($_SERVER['REQUEST_METHOD'] === 'GET'         // Only on initial GET of loginpage
             || ($_SERVER['REQUEST_METHOD'] === 'POST'
                 && (get_local_referer() != strip_querystring(qualified_me()))))
                                                          // Or when POSTed from another place
                                                          // See MDL-14071
            && !empty($this->config->ntlmsso_enabled)     // SSO enabled
            && !empty($this->config->ntlmsso_subnet)      // have a subnet to test for
            && empty($_GET['authldap_skipntlmsso'])       // haven't failed it yet
            && (isguestuser() || !isloggedin())           // guestuser or not-logged-in users
            && address_in_subnet(getremoteaddr(), $this->config->ntlmsso_subnet)) {

            // First, let's remember where we were trying to get to before we got here
            if (empty($SESSION->wantsurl)) {
                $SESSION->wantsurl = null;
                $referer = get_local_referer(false);
                if ($referer &&
                        $referer != $CFG->wwwroot &&
                        $referer != $CFG->wwwroot . '/' &&
                        $referer != $CFG->wwwroot . '/login/' &&
                        $referer != $CFG->wwwroot . '/login/index.php') {
                    $SESSION->wantsurl = $referer;
                }
            }

            // Now start the whole NTLM machinery.
            if($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESATTEMPT ||
                $this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) {
                if (core_useragent::is_ie()) {
                    $sesskey = sesskey();
                    redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_magic.php?sesskey='.$sesskey);
                } else if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) {
                    redirect($CFG->wwwroot.'/login/index.php?authldap_skipntlmsso=1');
                }
            }
            redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_attempt.php');
        }

        // No NTLM SSO, Use the normal login page instead.

        // If $SESSION->wantsurl is empty and we have a 'Referer:' header, the login
        // page insists on redirecting us to that page after user validation. If
        // we clicked on the redirect link at the ntlmsso_finish.php page (instead
        // of waiting for the redirection to happen) then we have a 'Referer:' header
        // we don't want to use at all. As we can't get rid of it, just point
        // $SESSION->wantsurl to $CFG->wwwroot (after all, we came from there).
        if (empty($SESSION->wantsurl)
            && (get_local_referer() == $CFG->wwwroot.'/auth/ldap/ntlmsso_finish.php')) {

            $SESSION->wantsurl = $CFG->wwwroot;
        }
    }
128101
def safe_login
      if not Masq::Engine.config.masq.include? 'protect_phishing' or Masq::Engine.config.masq['protect_phishing']
        render :layout => false
      else
        redirect_to login_url
      end
    end
237758
private function remoteLogin()
    {
        $ftp_login = true;
        $connet = ftp_connect($this->host, $this->port);
        $login = ftp_login($connet, $this->user, $this->pwd);
        if (!$connet || $login) {
            $this->tips = 'connet';
            $ftp_login = false;
        }
        $this->link = $connet;
        ftp_pasv($this->link, true);
        return $ftp_login;
    }
861534
public function logInFromSession()
    {
        $app = App::getInstance();

        $sql = $app['safesql']->query(
            "SELECT
                TIMESTAMPDIFF(SECOND,timestamp,NOW()) AS timediff,
                ip,
                browser
            FROM `login`
            WHERE session_id = '%s'
            AND session_name = '%s'
            AND logged_in = 1
            AND valid = 1
            AND user = '%s'
            AND deleted = 0
            ORDER BY timediff ASC
            LIMIT 1",
            array(
                $app['env']['session']->getId(),
                SESSION_NAME,
                $app['env']['session']['uname'],
            ));

        $user = $app['db']->get_row($sql);

        if (
            $user
            && $user->timediff <= SESSION_LENGTH
            && $user->ip == $app['env']['RemoteIP']
            && $user->browser == $app['env']['RemoteUA']
        ) {
            return true;
        } else {
            $this->destroySession(); // Clear invalid session data
            return false;
        }
    }
500267
public function sendToVatsim() {
		// a token must have been returned to redirect this user
		if (!$this->token){
			return false;
		}
		
		// redirect to the SSO login location, appending the token
		return $this->base . $this->loc_login . $this->token->key;
	}
245410
def redirect(self):
        

        logger.info("--- In SSO Redirect ---")
        saml_msg = self.unpack_redirect()

        try:
            _key = saml_msg["key"]
            saml_msg = IDP.ticket[_key]
            self.req_info = saml_msg["req_info"]
            del IDP.ticket[_key]
        except KeyError:
            try:
                self.req_info = IDP.parse_authn_request(saml_msg["SAMLRequest"],
                                                        BINDING_HTTP_REDIRECT)
            except KeyError:
                resp = BadRequest("Message signature verification failure")
                return resp(self.environ, self.start_response)

            _req = self.req_info.message

            if "SigAlg" in saml_msg and "Signature" in saml_msg:  # Signed
            # request
                issuer = _req.issuer.text
                _certs = IDP.metadata.certs(issuer, "any", "signing")
                verified_ok = False
                for cert in _certs:
                    if verify_redirect_signature(saml_msg, IDP.sec.sec_backend,
                                                 cert):
                        verified_ok = True
                        break
                if not verified_ok:
                    resp = BadRequest("Message signature verification failure")
                    return resp(self.environ, self.start_response)

            if self.user:
                if _req.force_authn:
                    saml_msg["req_info"] = self.req_info
                    key = self._store_request(saml_msg)
                    return self.not_authn(key, _req.requested_authn_context)
                else:
                    return self.operation(saml_msg, BINDING_HTTP_REDIRECT)
            else:
                saml_msg["req_info"] = self.req_info
                key = self._store_request(saml_msg)
                return self.not_authn(key, _req.requested_authn_context)
        else:
            return self.operation(saml_msg, BINDING_HTTP_REDIRECT)
1224289
def wafer_sso_url(context, sso_method):
    '''
    
    '''
    request = context.request
    url = reverse(getattr(views, '%s_login' % sso_method))
    if 'next' in request.GET:
        url += '?' + urlencode({'next': request.GET['next']})
    return url
928223
def __pre_check(self, requestedUrl):
		'''
		
		'''
		components = urllib.parse.urlsplit(requestedUrl)

		netloc_l = components.netloc.lower()
		if netloc_l in Domain_Constants.SUCURI_GARBAGE_SITE_NETLOCS:
			self.__check_suc_cookie(components)
		elif netloc_l in Domain_Constants.CF_GARBAGE_SITE_NETLOCS:
			self.__check_cf_cookie(components)
		elif components.path == '/sucuri_shit_2':
			self.__check_suc_cookie(components)
		elif components.path == '/sucuri_shit_3':
			self.__check_suc_cookie(components)
		elif components.path == '/cloudflare_under_attack_shit_2':
			self.__check_cf_cookie(components)
		elif components.path == '/cloudflare_under_attack_shit_3':
			self.__check_cf_cookie(components)
738639
def authenticated(function):
    """"""
    def wrapped(*args):
        """Wrap function."""
        try:
            return function(*args)
        except MoparError:
            _LOGGER.info("attempted to access page before login")
            _login(args[0])
            return function(*args)
    return wrapped
1172874
public function __isAllowed()
    {
        if ($this->checkAuthentication !== true) {
            // this controller is not responsible for the authentication
            return false;
        }

        $this->typo3Loader->initializeFrontEndUser($this->determinePageIdFromArguments());

        $feUser = $this->typo3Loader->getFrontEndUser();
        if ($feUser->user === null) {
            return false;
        }
        return true;
    }
342772
public function beforeFilter()
    {
        $authentication = $this->getAuthenticationService();
        $provider = $authentication->getAuthenticationProvider();

        if ($provider === null ||
            $provider instanceof PersistenceInterface ||
            $provider instanceof StatelessInterface
        ) {
            return;
        }

        $this->dispatchEvent('Authentication.afterIdentify', [
            'provider' => $provider,
            'identity' => $this->getIdentity(),
            'service' => $authentication
        ], $this->getController());
    }
228193
public static boolean loginAtStart() {
		boolean loginAtStart = Application.getInstance().isLoginRequired() || Configuration.get("MjLoginAtStart", "false").equals("true");
		if (loginAtStart && !Backend.getInstance().isAuthenticationActive()) {
			throw new IllegalStateException("Login required but authorization is not configured!");
		}
		return loginAtStart;
	}
1006781
def login_required(self, fresh=False, redirect_to=None):
        
        if not self.logged_in() or (fresh and not self.login_manager.login_fresh()):
            if redirect_to:
                resp = redirect(redirect_to)
            else:
                resp = self.login_manager.unauthorized()
            current_context.exit(resp, trigger_action_group="missing_user")
100793
def login_user(self, request):
        
        # only actavted users can login if activation required.
        user = auth.authenticate(identity=self.identity, provider=self.provider)
        if user and settings.ACTIVATION_REQUIRED and not user.is_active:
            messages.add_message(request, messages.ERROR, lang.NOT_ACTIVATED)
            return redirect(settings.ACTIVATION_REDIRECT_URL)
        # login
        if user:
            auth.login(request, user)
            return True

        return False
1311818
public function loginByRememberMe(): bool {
		
		// build the cookie name
		$cookieName = static::getRememberMeCookieName();

		// check if cookie exists
		if (!isset($_COOKIE[$cookieName])) {
			return FALSE;
		}
			
		// try to unserialize the cookie content
		$content = unserialize($_COOKIE[$cookieName]);
		
		// cookie content is not unserializable
		if (FALSE === $content) {
			return FALSE;
		}

		// check if content exists and RememberMe length
		if (isset($content[0]) and isset($content[1]) and 32==strlen($content[1])) {
			
			// try to load user
			$user = static::getByRememberMe($content[1]);
			
			// if user exists, return it
			if (is_a($user, 'Pair\User')) {
				$user->createSession($content[0]);
				$user->renewRememberMe();
				return TRUE;
			}
		
		}
		
		return FALSE;
	
	}
569452
protected function beforeRenderView()
    {
        $login = $this->getLoginProvider();

        if (isset($_GET["logout"])) {
            $login->logOut();
        }

        if ( $login->isLoggedIn() ){
            $this->onSuccess();
        }
    }
485159
def login(request, template_name=None,
          redirect_field_name=REDIRECT_FIELD_NAME,
          authentication_form=AuthenticationForm,
          current_app=None, extra_context=None):
    
    redirect_to = request.POST.get(
        redirect_field_name,
        request.GET.get(redirect_field_name, '')
    )

    def get_redirect_to():
        # Ensure the user-originating redirection url is safe.
        if not is_safe_url(url=redirect_to, host=request.get_host()):
            return resolve_url(settings.LOGIN_REDIRECT_URL)
        return redirect_to

    if request.user.is_authenticated:
        return HttpResponseRedirect(get_redirect_to())

    if request.method == "POST":
        form = authentication_form(request=request, data=request.POST)
        if form.is_valid():

            # Okay, security check complete. Log the user in.
            auth_login(request, form.get_user())

            return HttpResponseRedirect(get_redirect_to())
    else:
        form = authentication_form(request=request)

    current_site = get_current_site(request)

    context = {
        'form': form,
        redirect_field_name: redirect_to,
        'site': current_site,
        'site_name': current_site.name,
    }
    if extra_context is not None:
        context.update(extra_context)

    if current_app is not None:
        request.current_app = current_app

    return TemplateResponse(request, template_name, context)