returns an object to work with the site security
969248
def security(self):
        """"""
        if self._resources is None:
            self.__init()
        if "security" in self._resources:
            url = self._url + "/security"
            return _security.Security(url=url,
                                      securityHandler=self._securityHandler,
                                      proxy_url=self._proxy_url,
                                      proxy_port=self._proxy_port,
                                      initialize=True)
        else:
            return None
643066
def authentication(self):
        '''
        
        '''
        url = '%s/authentication' % (self.domain)
        res = self.session.get(url)
        self._check_response(res)
        return res.json()
1104694
def auth_basic(check, realm="private", text="Access denied"):
    '''  '''
    def decorator(func):
        def wrapper(*a, **ka):
            user, password = request.auth or (None, None)
            if user is None or not check(user, password):
                err = HTTPError(401, text)
                err.add_header('WWW-Authenticate', 'Basic realm="%s"' % realm)
                return err
            return func(*a, **ka)
        return wrapper
    return decorator
394506
def requires_user(fn):
        
        @functools.wraps(fn)
        def wrap(*args, **kwargs):

            subject = WebYosai.get_current_subject()

            if subject.identifiers is None:
                msg = ("Attempting to perform a user-only operation.  The "
                       "current Subject is NOT a user (they haven't been "
                       "authenticated or remembered from a previous login). "
                       "ACCESS DENIED.")
                raise WebYosai.get_current_webregistry().raise_unauthorized(msg)
            return fn(*args, **kwargs)
        return wrap
1300284
def get_object(self, queryset=None):
        '''  '''
        return get_object_or_404(
            GuestList.objects.filter(id=self.kwargs.get('guestlist_id')))
60624
function get(ignored, cb) {
  assert(this.$session);
  const ugRequest = {
    userId: this.$session.userId,
  };
  this.syscall('UserManager', 'get', ugRequest, (err, userInfo, curVersion) => {
    if (err) return cb(err);

    // Strip security-sensitive information.
    delete userInfo.hashedPassword;
    _.forEach(userInfo.securityEvents, (secEvt) => {
      if (secEvt.eventType === 'password_reset_requested') {
        delete secEvt.data.resetCode;
      }
    });

    return cb(null, userInfo, curVersion);
  });
}
988610
def get_site(self, url, cookies={}, page_format='html', return_on_error=[], retry_enabled=True,
                 num_tries=0, num_apikey_tries=0, headers={}, api=False, track_stat=True, timeout=30,
                 force_requests=False, driver_args=(), driver_kwargs={}, parser='beautifulsoup',
                 custom_source_checks=[]):
        
        self._reset_response()

        num_tries += 1
        # Save args and kwargs so they can be used for trying the function again
        tmp_args = locals().copy()
        get_site_args = [tmp_args['url']]
        # Remove keys that dont belong to the keywords passed in
        del tmp_args['url']
        del tmp_args['self']
        get_site_kwargs = tmp_args

        # Check driver_kwargs for anything that we already set
        kwargs_cannot_be = ['headers', 'cookies', 'timeout']
        for key_name in kwargs_cannot_be:
            if driver_kwargs.get(key_name) is not None:
                del driver_kwargs[key_name]
                logger.warning("Cannot pass `{key}` in driver_kwargs to get_site(). `{key}` is already set by default"
                               .format(key=key_name))

        # Check if a url is being passed in
        if url is None:
            logger.error("Url cannot be None")
            return None

        ##
        # url must start with http....
        ##
        prepend = ''
        if url.startswith('//'):
            prepend = 'http:'

        elif not url.startswith('http'):
            prepend = 'http://'

        url = prepend + url

        ##
        # Try and get the page
        ##
        rdata = None
        try:
            source_text = self._get_site(url, headers, cookies, timeout, driver_args, driver_kwargs)
            if custom_source_checks:
                # Check if there are any custom check to run
                for re_text, status_code in custom_source_checks:
                    if re.search(re_text, source_text):
                        if self.response is None:
                            # This is needed when using selenium and we still need to pass in the 'response'
                            self.response = type('', (), {})()
                        self.response.status_code = status_code
                        self.status_code = status_code
                        raise requests.exceptions.HTTPError("Custom matched status code", response=self.response)

            rdata = self.parse_source(source_text, page_format, parser)

        ##
        # Exceptions from Selenium
        ##
        # Nothing yet

        ##
        # Exceptions from Requests
        ##
        except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e:
            """
            Try again with a new profile (do not get new apikey)
            Wait n seconds before trying again
            """
            e_name = type(e).__name__
            if num_tries < self._num_retries and retry_enabled is True:
                logger.info("{} [get_site]: try #{} on {} Error {}".format(e_name, num_tries, url, e))
                time.sleep(2)
                self.new_profile()
                return self.get_site(*get_site_args, **get_site_kwargs)

            else:
                logger.error("{} [get_site]: try #{} on{}".format(e_name, num_tries, url))

        except requests.exceptions.TooManyRedirects as e:
            logger.exception("TooManyRedirects [get_site]: {}".format(url))

        ##
        # Exceptions shared by Selenium and Requests
        ##
        except (requests.exceptions.HTTPError, SeleniumHTTPError) as e:
            """
            Check the status code returned to see what should be done
            """
            status_code = str(e.response.status_code)
            # If the client wants to handle the error send it to them
            if int(status_code) in return_on_error:
                raise e.with_traceback(sys.exc_info()[2])

            try_again = self._get_site_status_code(url, status_code, api, num_tries, num_apikey_tries)
            if try_again is True and retry_enabled is True:
                # If True then try request again
                return self.get_site(*get_site_args, **get_site_kwargs)

        # Every other exceptions that were not caught
        except Exception:
            logger.exception("Unknown Exception [get_site]: {url}".format(url=url))

        return rdata
371194
def from_urlsafe(cls, urlsafe):
        
        try:
            key = ndb.Key(urlsafe=urlsafe)
        except:
            return None
        obj = key.get()
        if obj and isinstance(obj, cls):
            return obj
883043
def get_object(self):
        
        obj = super(PublishActionView, self).get_object()

        if obj:
            if not hasattr(obj, 'publish'):
                raise http.Http404

        return obj
1373219
def get(security_token=None, key=None):
    
    if security_token is None:
        security_token = nago.core.get_my_info()['host_name']
    data = node_data.get(security_token, {})
    if not key:
        return data
    else:
        return data.get(key)
247250
def getReturnPage(context, prior=False):
    '''
    
    '''
    siteHistory = getattr(context.get('request',None),'session',{}).get('SITE_HISTORY',{})
    return returnPageHelper(siteHistory,prior=prior)
273291
def _get_client_and_key(url, user, password, verbose=0):
    '''
    
    '''
    session = {}
    session['client'] = six.moves.xmlrpc_client.Server(url, verbose=verbose, use_datetime=True)
    session['key'] = session['client'].auth.login(user, password)

    return session
248330
def _get(app, endpoint, id=None, auth_required=False, **kwargs):
    '''
    
    '''
    nb = _nb_obj(auth_required=auth_required)
    if id:
        item = getattr(getattr(nb, app), endpoint).get(id)
    else:
        kwargs = __utils__['args.clean_kwargs'](**kwargs)
        item = getattr(getattr(nb, app), endpoint).get(**kwargs)
    return item
544552
def requires_authentication(fn):
        

        @functools.wraps(fn)
        def wrap(*args, **kwargs):
            subject = WebYosai.get_current_subject()

            if not subject.authenticated:
                msg = "The current Subject is not authenticated.  ACCESS DENIED."
                raise WebYosai.get_current_webregistry().raise_unauthorized(msg)

            return fn(*args, **kwargs)
        return wrap
469558
function checkUser( &$siteBasics, $uri )
    {
        $http = eZHTTPTool::instance();
        $check = array( "module" => "user",
                        "function" => "login" );
        if ( eZSession::issetkey( 'eZUserLoggedInID', false ) &&
             $http->sessionVariable( "eZUserLoggedInID" ) != '' &&
             $http->sessionVariable( "eZUserLoggedInID" ) != self::anonymousId() )
        {
            $currentUser = eZUser::currentUser();
            if ( !$currentUser->isEnabled() )
            {
                eZUser::logoutCurrent();
                $currentUser = eZUser::currentUser();
            }
            else
            {
                return null;
            }
        }

        $ini        = eZINI::instance();
        $moduleName = $uri->element();
        $viewName   = $uri->element( 1 );
        $anonymousAccessList = $ini->variable( "SiteAccessSettings", "AnonymousAccessList" );
        foreach ( $anonymousAccessList as $anonymousAccess )
        {
            $elements = explode( '/', $anonymousAccess );
            if ( !isset( $elements[1] ) )
            {
                if ( $moduleName == $elements[0] )
                {
                    return null;
                }
            }
            else
            {
                if ( $moduleName == $elements[0] and
                     $viewName == $elements[1] )
                {
                    return null;
                }
            }
        }

        return $check;
    }
319018
function getReqObj(url, obj){
  if(typeof url === 'object') return url;
  else {
    obj = {}
    obj.url = url
    return obj
  }
}
568176
def code_object(url)
      sha = url_key url
      if o = @url_bucket.get(sha, :r => 1)
        fix_url_object(o)
      end
    rescue Riak::FailedRequest => err
      raise unless err.not_found?
    end