def _htdigest(username, password, **kwargs):
    '''
    Provide authentication via Apache-style htdigest files
    '''

    realm = kwargs.get('realm', None)
    if not realm:
        log.error('salt.auth.file: A ^realm must be defined in '
                  'external_auth:file for htdigest filetype')
        return False

    from passlib.apache import HtdigestFile

    pwfile = HtdigestFile(kwargs['filename'])

    # passlib below version 1.6 uses 'verify' function instead of 'check_password'
    if salt.utils.versions.version_cmp(kwargs['passlib_version'], '1.6') < 0:
        return pwfile.verify(username, realm, password)
    else:
        return pwfile.check_password(username, realm, password)
Provide authentication via Apache-style htdigest files