This function is called to check if a username /
        password combination is valid via the htpasswd file.
188330
def check_basic_auth(self, username, password):
        
        valid = self.users.check_password(
            username, password
        )
        if not valid:
            log.warning('Invalid login from %s', username)
            valid = False
        return (
            valid,
            username
        )
157112
def compare_password(expected, actual):
    """"""
    if expected == actual:
        return True, "OK"
    msg = []
    ver_exp = expected[-8:].rstrip()
    ver_act = actual[-8:].rstrip()

    if expected[:-8] != actual[:-8]:
        msg.append("Password mismatch")
    if ver_exp != ver_act:
        msg.append("asterisk_mbox version mismatch.  Client: '" +
                   ver_act + "',  Server: '" + ver_exp + "'")
    return False, ". ".join(msg)
1158972
function(callback) {
          ftpout.raw.pwd(function(err) {
            if (err && err.code === 530) {
              grunt.fatal('bad username or password');
            }
            callback(err);
          });
        }
239257
def get_user_data_triplet(username, password):
    """"""
    context = SRPContext(username, password)
    username, password_verifier, salt = context.get_user_data_triplet(base64=True)

    click.secho('Username: %s' % username)
    click.secho('Password verifier: %s' % password_verifier)
    click.secho('Salt: %s' % salt)
1110675
def set_user_password(name, passwd, **client_args):
    '''
    
    '''
    if not user_exists(name, **client_args):
        log.info('User \'%s\' does not exist', name)
        return False

    client = _client(**client_args)
    client.set_user_password(name, passwd)

    return True
684611
def isMember(userid, password, group):
    
    try:
        certfile = getCert(userid, password)

        group_url = getGroupsURL(certfile, group)
        logging.debug("group url: %s" % ( group_url))

        con = httplib.HTTPSConnection(_SERVER,
                                      443,
                                      key_file=certfile.name,
                                      cert_file=certfile.name,
                                      timeout=600)

        con.connect()
        con.request("GET", group_url)
        resp = con.getresponse()
        if resp.status == 200:
            return True
    except Exception as e:
        logging.error(str(e))

    #logging.debug(str(resp.status))

    return False
287072
def verify(user, password):
    """"""
    def verify_user(user_name, user_password):
        if user_name == user and user_password == password:
            return user_name
        return False
    return verify_user
311759
def _check_auth(self, username: str, password: str) -> bool:
        """"""
        try:
            return self.credentials[username] == password
        except KeyError:
            return False
808999
def check_auth(self, username, password):
        """"""
        if username == self.args.username:
            from glances.password import GlancesPassword
            pwd = GlancesPassword()
            return pwd.check_password(self.args.password, pwd.sha256_hash(password))
        else:
            return False
619714
def _text(username, password, **kwargs):
    '''
    
    '''

    filename = kwargs['filename']
    hashtype = kwargs['hashtype']
    field_separator = kwargs['field_separator']
    username_field = kwargs['username_field']-1
    password_field = kwargs['password_field']-1

    with salt.utils.files.fopen(filename, 'r') as pwfile:
        for line in pwfile.readlines():
            fields = line.strip().split(field_separator)

            try:
                this_username = fields[username_field]
            except IndexError:
                log.error('salt.auth.file: username field (%s) does not exist '
                          'in file %s', username_field, filename)
                return False
            try:
                this_password = fields[password_field]
            except IndexError:
                log.error('salt.auth.file: password field (%s) does not exist '
                          'in file %s', password_field, filename)
                return False

            if this_username == username:
                if hashtype == 'plaintext':
                    if this_password == password:
                        return True
                else:
                    # Exceptions for unknown hash types will be raised by hashutil.digest
                    if this_password == __salt__['hashutil.digest'](password, hashtype):
                        return True

                # Short circuit if we've already found the user but the password was wrong
                return False
    return False
1152082
def is_valid(self):
        ''' 
        '''
        if not super(ProfileRequestForm, self).is_valid():
            return False
        validity = True
        if self.cleaned_data['password'] != self.cleaned_data['confirm_password']:
            form_add_error(self, 'password', "Passwords don't match.")
            form_add_error(self, 'confirm_password', "Passwords don't match.")
            validity = False
        return validity
733894
@Override
    public PasswordStrengthCheckResult check(String userName, String password, List<PasswordRestriction> restictions) {
        try {
            this.userName = userName;
            this.password = password;
            this.passwordLength = this.password.length();
            this.adHocRestrictions = restictions;
            this.result = new SimplePasswordStrengthCheckResult();

            this.checkRestrictions();
            // positive checks
            result.positive(password.length() * PWD_LEN_WEIGHT);
            this.checkSymbols();
            this.checkDigits();
            this.checkMiddleNonChar();
            this.checkAlpha();

            // negatives checks
            this.checkAlphaOnly();
            this.checkNumbersOnly();
            this.checkConsecutiveAlpha();
            this.checkConsecutiveNumbers();
            this.checkConsecutiveSymbols();
            this.checkSequential();

            // now evaluate.
            this.result.calculateStrength();
        } finally {
            this.password = null;
            this.passwordLength = 0;
            this.adHocRestrictions = null;
        }
        return result;
    }
98800
@CommandArgument
  public void passwd(
      @OptionArgument("username") String username,
      @OptionArgument("password") String password) {

    User user = users.get(username);

    if (user != null) {
      user.salt = passwd.generateSalt();
      user.hash = passwd.getEncryptedPassword(password, user.salt);
    } else {
      System.err.println(String.format("User '%s' does not exist", username));
    }

  }
603087
public function check()
    {
        if ($this->path[0] == '/') {
            $filename = $this->path;
        } else {
            $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path);
        }

        if (file_exists($filename)) {
            $isWriteable = is_writeable($filename);
        } else {
            $isWriteable = is_writeable(dirname($filename));
        }

        if (!$isWriteable) {
            if (function_exists('posix_getgroups')) {
                $userID = posix_geteuid();
                $user = posix_getpwuid($userID);

                $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename));
                $currentOwner = posix_getpwuid($currentOwnerID);

                $message = "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is "
                    . "currently owned by '$currentOwner[name]'.  ";

                if ($user['name'] == $currentOwner['name']) {
                    $message .= 'We recommend that you make the file writeable.';
                } else {
                    $groups = posix_getgroups();
                    $groupList = [];
                    foreach ($groups as $group) {
                        $groupInfo = posix_getgrgid($group);
                        if (in_array($currentOwner['name'], $groupInfo['members'])) {
                            $groupList[] = $groupInfo['name'];
                        }
                    }
                    if ($groupList) {
                        $message .= "	We recommend that you make the file group-writeable and change the group to "
                            . "one of these groups:\n - " . implode("\n - ", $groupList)
                            . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename";
                    } else {
                        $message .= "  There is no user-group that contains both the web-server user and the owner "
                            . "of this file.  Change the ownership of the file, create a new group, or temporarily "
                            . "make the file writeable by everyone during the install process.";
                    }
                }
            } else {
                $message = "The webserver user needs to be able to write to this file:\n$filename";
            }

            return [EnvironmentCheck::ERROR, $message];
        }

        return [EnvironmentCheck::OK, ''];
    }
177293
function isAuthenticated(username, password) {

    var userIndex = userdb.users.findIndex(function (user) {
        return (user.name === username && user.password === password);
    });

    return userIndex != -1;
}
1171977
private function validate()
    {
        if (!$this->testServer($this->ssh, sprintf('-d "%s"', $this->directory))) {
            throw new SshValidateException('Directory does not exists');
        }

        if (!$this->testServer($this->ssh, sprintf('-x "%s"', $this->executable), $this->directory)) {
            throw new SshValidateException('Executable does not exists');
        }

        return true;
    }
623023
def validate_request(request):
    
    if getattr(settings, 'BASICAUTH_DISABLE', False):
        # Not to use this env
        return True

    if 'HTTP_AUTHORIZATION' not in request.META:
        return False

    authorization_header = request.META['HTTP_AUTHORIZATION']
    ret = extract_basicauth(authorization_header)
    if not ret:
        return False

    username, password = ret

    raw_pass = settings.BASICAUTH_USERS.get(username)
    if raw_pass is None:
        return False

    # To avoid timing atacks
    # https://security.stackexchange.com/questions/83660/simple-string-comparisons-not-secure-against-timing-attacks
    if not constant_time_compare(raw_pass, password):
        return False

    request.META['REMOTE_USER'] = username
    return True