当前位置: 首页>>代码示例>>Python>>正文


Python utils.verify_password方法代码示例

本文整理汇总了Python中flask_security.utils.verify_password方法的典型用法代码示例。如果您正苦于以下问题:Python utils.verify_password方法的具体用法?Python utils.verify_password怎么用?Python utils.verify_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_security.utils的用法示例。


在下文中一共展示了utils.verify_password方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_verify_password_single_hash_list

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def test_verify_password_single_hash_list(app, sqlalchemy_datastore):
    init_app_with_options(
        app,
        sqlalchemy_datastore,
        **{
            "SECURITY_PASSWORD_HASH": "bcrypt",
            "SECURITY_PASSWORD_SALT": "salty",
            "SECURITY_PASSWORD_SINGLE_HASH": ["django_pbkdf2_sha256", "plaintext"],
            "SECURITY_PASSWORD_SCHEMES": [
                "bcrypt",
                "pbkdf2_sha256",
                "django_pbkdf2_sha256",
                "plaintext",
            ],
        }
    )
    with app.app_context():
        # double hash
        assert verify_password("pass", hash_password("pass"))
        assert verify_password("pass", pbkdf2_sha256.hash(get_hmac("pass")))
        # single hash
        assert verify_password("pass", django_pbkdf2_sha256.hash("pass"))
        assert verify_password("pass", plaintext.hash("pass")) 
开发者ID:Flask-Middleware,项目名称:flask-security,代码行数:25,代码来源:test_hashing.py

示例2: _http_auth

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def _http_auth(self, user, username, password):
        """Perform basic user authentication
        - Check that the password that was passed in the request can be
          verified against the password stored in the DB

        :param user: The DB user object
        :param username: The username from the request
        :param password: The password from the request
        :return: The DB user object
        """
        self.logger.debug('Running basic HTTP authentication')
        if not user:
            raise_unauthorized_user_error(
                'Authentication failed for '
                '<User username=`{0}`>'.format(username)
            )
        if not verify_password(password, user.password):
            self._increment_failed_logins_counter(user)
            raise_unauthorized_user_error(
                'Authentication failed for {0}.'
                ' Bad credentials or locked account'.format(user)
            )
        return user 
开发者ID:cloudify-cosmo,项目名称:cloudify-manager,代码行数:25,代码来源:authentication.py

示例3: correct_password

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def correct_password(email, password):
    user = User.objects.get(email=email)
    return utils.verify_password(password, user.password) 
开发者ID:fkie-cad,项目名称:LuckyCAT,代码行数:5,代码来源:Users.py

示例4: post

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def post(self):
        args = parser.parse_args()
        email = args['email']
        password = args['password']
        if email is None or password is None:
            return {'message': "Email or password empty"}, 401
        user = User.query.filter_by(email=args["email"]).first()
        if security_utils.verify_password(password, user.password):
            return {'message': 'Login Successful', 'apikey': user.api_key}, 200
        return {'message': 'Login Failed'}, 401 
开发者ID:dhamaniasad,项目名称:crestify,代码行数:12,代码来源:apiservice.py

示例5: test_verify_password_bcrypt_double_hash

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def test_verify_password_bcrypt_double_hash(app, sqlalchemy_datastore):
    init_app_with_options(
        app,
        sqlalchemy_datastore,
        **{
            "SECURITY_PASSWORD_HASH": "bcrypt",
            "SECURITY_PASSWORD_SALT": "salty",
            "SECURITY_PASSWORD_SINGLE_HASH": False,
        }
    )
    with app.app_context():
        assert verify_password("pass", hash_password("pass")) 
开发者ID:Flask-Middleware,项目名称:flask-security,代码行数:14,代码来源:test_hashing.py

示例6: test_verify_password_bcrypt_single_hash

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def test_verify_password_bcrypt_single_hash(app, sqlalchemy_datastore):
    init_app_with_options(
        app,
        sqlalchemy_datastore,
        **{
            "SECURITY_PASSWORD_HASH": "bcrypt",
            "SECURITY_PASSWORD_SALT": None,
            "SECURITY_PASSWORD_SINGLE_HASH": True,
        }
    )
    with app.app_context():
        assert verify_password("pass", hash_password("pass")) 
开发者ID:Flask-Middleware,项目名称:flask-security,代码行数:14,代码来源:test_hashing.py

示例7: test_verify_password_backward_compatibility

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def test_verify_password_backward_compatibility(app, sqlalchemy_datastore):
    init_app_with_options(
        app,
        sqlalchemy_datastore,
        **{
            "SECURITY_PASSWORD_HASH": "bcrypt",
            "SECURITY_PASSWORD_SINGLE_HASH": False,
            "SECURITY_PASSWORD_SCHEMES": ["bcrypt", "plaintext"],
        }
    )
    with app.app_context():
        # double hash
        assert verify_password("pass", hash_password("pass"))
        # single hash
        assert verify_password("pass", plaintext.hash("pass")) 
开发者ID:Flask-Middleware,项目名称:flask-security,代码行数:17,代码来源:test_hashing.py

示例8: test_verify_password_argon2

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def test_verify_password_argon2(app, sqlalchemy_datastore):
    init_app_with_options(
        app, sqlalchemy_datastore, **{"SECURITY_PASSWORD_HASH": "argon2"}
    )
    with app.app_context():
        hashed_pwd = hash_password("pass")
        assert verify_password("pass", hashed_pwd)
        assert "t=10" in hashed_pwd

        # Verify double hash
        assert verify_password("pass", argon2.hash(get_hmac("pass"))) 
开发者ID:Flask-Middleware,项目名称:flask-security,代码行数:13,代码来源:test_hashing.py

示例9: authenticate_user

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def authenticate_user(self, username, password):
        user = User.objects(email=username).first()
        if user and verify_password(password, user.password):
            return user 
开发者ID:opendatateam,项目名称:udata,代码行数:6,代码来源:oauth2.py

示例10: authenticate

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def authenticate(username, password):
    user = user_datastore.find_user(email=username)
    if user and username == user.email and verify_password(password, user.password):
        return user
    return None 
开发者ID:graup,项目名称:flask-restless-security,代码行数:7,代码来源:server.py

示例11: password_is_correct

# 需要导入模块: from flask_security import utils [as 别名]
# 或者: from flask_security.utils import verify_password [as 别名]
def password_is_correct(self, user_name, password):
        user = self.find_user(email=user_name)
        return verify_password(password, user.password) 
开发者ID:fkie-cad,项目名称:FACT_core,代码行数:5,代码来源:user_role_db_interface.py


注:本文中的flask_security.utils.verify_password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。