Check the authorization for the command
12117
def check_auth(self, name):
        
        if name in self.auths:
            # if the command name is in the **need authorization list**
            # get the authorization for the command
            auth = self.auths[name]
            if self.args.auth is None:
                # if we didn't pass the authorization phrase raise the
                # appropriate exception
                raise exceptions.ArgParseInatorAuthorizationRequired
            elif ((auth is True and self.args.auth != self.auth_phrase) or
                  (auth is not True and self.args.auth != auth)):
                # else if the authorization phrase is wrong
                raise exceptions.ArgParseInatorNotValidAuthorization
        return True
1077447
def rights_check(self, form, sub_auth, name, load, eauth=None):
        '''
        
        '''
        if load.get('eauth'):
            sub_auth = sub_auth[load['eauth']]
        good = self.ckminions.any_auth(
                form,
                sub_auth[name] if name in sub_auth else sub_auth['*'],
                load.get('fun', None),
                load.get('arg', None),
                load.get('tgt', None),
                load.get('tgt_type', 'glob'))

        # Handle possible return of dict data structure from any_auth call to
        # avoid a stacktrace. As mentioned in PR #43181, this entire class is
        # dead code and is marked for removal in Salt Neon. But until then, we
        # should handle the dict return, which is an error and should return
        # False until this class is removed.
        if isinstance(good, dict):
            return False

        if not good:
            # Accept find_job so the CLI will function cleanly
            if load.get('fun', '') != 'saltutil.find_job':
                return good
        return good
287720
def authorized?(robot, user, required_groups)
      required_groups.nil? || required_groups.any? do |group|
        robot.auth.user_in_group?(user, group)
      end
    end
1046326
def permitted_to! (privilege, object_or_sym = nil, options = {})
      authorization_engine.permit!(privilege, options_for_permit(object_or_sym, options, true))
    end
795293
def check(self, radl):
        """"""

        SIMPLE_FEATURES = {
            "host": (str, None),
            "credentials.username": (str, None),
            "credentials.password": (str, None),
            "credentials.private_key": (str, None)
        }
        self.check_simple(SIMPLE_FEATURES, radl)

        if not self.getHost():
            raise RADLParseException("Ansible host must have a host", line=self.line)
        (username, password, private_key) = self.getCredentialValues()
        if not username:
            raise RADLParseException("Ansible host must have a credentials.username", line=self.line)
        if not password and not private_key:
            raise RADLParseException("Ansible host must have a credentials.password or credentials.private_key",
                                     line=self.line)
955042
def _check_authorization(cls, authzr, identifier):
        
        if authzr.body.identifier != identifier:
            raise errors.UnexpectedUpdate(authzr)
        return authzr
795542
def authorization_middleware(environ, start_response=None):
    '''
    '''
    key = 'http.authorization'
    c = environ.get(key)
    if c is None:
        code = 'HTTP_AUTHORIZATION'
        if code in environ:
            environ[key] = parse_authorization_header(environ[code])
984114
def _check_permission(self, request):
        

        if self.access_controller:
            self.access_controller.check_perm(request, self)
182819
def permitted_to! (privilege, options = {} )
      options = {
        :user =>  Authorization.current_user,
        :object => self
      }.merge(options)
      Authorization::Engine.instance.permit!(privilege,
          {:user => options[:user],
           :object => options[:object]})
    end
644249
def check_basic_auth(user, passwd):
    """"""

    auth = request.authorization
    return auth and auth.username == user and auth.password == passwd
480930
function cmd_auth(args, done) {
    var seneca = this
    var userent = seneca.make(user_canon)
    var loginent = seneca.make(login_canon)

    var q = { id: args.token }

    loginent.load$(q, function(err, login) {
      if (err) return done(err)

      if (!login) {
        return done(null, {
          ok: false,
          token: args.token,
          why: 'login-not-found'
        })
      }

      if (!login.active) {
        return done(null, {
          ok: false,
          token: args.token,
          why: 'login-inactive'
        })
      }

      userent.load$({ id: login.user }, function(err, user) {
        if (err) return done(err)

        if (!user) {
          return done(null, {
            ok: false,
            token: args.token,
            user: login.user,
            why: 'user-not-found'
          })
        }

        done(null, { user: user, login: login, ok: true })
      })
    })
  }
1175227
def check_auth(name, sock_dir=None, queue=None, timeout=300):
    '''
    
    '''
    event = salt.utils.event.SaltEvent('master', sock_dir, listen=True)
    starttime = time.mktime(time.localtime())
    newtimeout = timeout
    log.debug('In check_auth, waiting for %s to become available', name)
    while newtimeout > 0:
        newtimeout = timeout - (time.mktime(time.localtime()) - starttime)
        ret = event.get_event(full=True)
        if ret is None:
            continue
        if ret['tag'] == 'salt/minion/{0}/start'.format(name):
            queue.put(name)
            newtimeout = 0
            log.debug('Minion %s is ready to receive commands', name)
306251
def check_command(args):
    """"""
    outdated = check_requirements_file(args.requirements_file,
                                       args.skip_packages)

    if outdated:
        print('Requirements in {} are out of date:'.format(
            args.requirements_file))

        for item in outdated:
            print(' * {} is {} latest is {}.'.format(*item))

        sys.exit(1)
    else:
        print('Requirements in {} are up to date.'.format(
            args.requirements_file))
742868
def check_is_admin(context):
    """"""
    init()
    credentials = context.to_policy_values()
    target = credentials
    return _ENFORCER.authorize('admin_required', target, credentials)
901386
def has_permission(self, perm):
        
        return self.user.superuser or self.auth.has_permission(perm)
1345700
def check_command(self, name):
        
        if not check_command(
            name, 
            exclude_packages=self.get_exclude_packages(),
            exclude_command_class=self.__class__):
            raise management.CommandError(
                "The management command \"{name:s}\" is not available. "
                "Please ensure that you've added the application with "
                "the \"{name:s}\" command to your INSTALLED_APPS "
                "setting".format(
                    name=name))
8556
def _perform_command(user, command_type, command_args):
    """"""
    command_uuid = _gen_uuid()
    command = {
        'type': command_type,
        'args': command_args,
        'uuid': command_uuid,
        'temp_id': _gen_uuid()
    }
    commands = json.dumps([command])
    response = API.sync(user.api_token, user.sync_token, commands=commands)
    _fail_if_contains_errors(response, command_uuid)
    response_json = response.json()
    user.sync_token = response_json['sync_token']