コード例 #1
0
def verify_password(username_or_token, password=None):
    global database
    #database = lib.get_db()
    LOGGER = lib.get_logger(PROCESS)
    print("Will Verify User: {}, {}", username_or_token, password)
    # First try to verify via token
    user_rec = Users.verify_auth_token(app.config['SECRET_KEY'],
                                       username_or_token)
    if user_rec is None:
        # try to authenticate with username/password
        user_rec = Users.get(username_or_token, password)
    if user_rec is None:
        return False
    g.user = user_rec
    return True
コード例 #2
0
ファイル: api.py プロジェクト: bitgrin/grin-pool
def verify_password(username_or_token, password=None):
    global database
    #database = lib.get_db()
    LOGGER = lib.get_logger(PROCESS)
    debug and LOGGER.warn("Will Verify User: {}, {}".format(username_or_token, password))
    # First try to verify via token
    user_rec = Users.verify_auth_token(app.config['SECRET_KEY'], username_or_token)
    if user_rec is None:
        # try to authenticate with username/password
        user_rec = Users.get(username_or_token, password)
    if user_rec is None:
        return False
    g.user = user_rec
    # Cache username<->user_id in redis for our stratum server
    redis_key = redis_userid_key + user_rec.username
    r.set(redis_key, user_rec.id)
    return True
コード例 #3
0
#!/usr/bin/python

# Given a username and plaintext password,
#  authenticate against the db user records

import sys
from grinbase.model.users import Users
from grinlib import lib

# User to authenticate
username = sys.argv[1]
password = sys.argv[2]

# Initialize a db connection
database = lib.get_db()

# Lookup / authenticate
theUserRecord = Users.get(username, password)

# Print the results
if theUserRecord is None:
    print("Failed to find or autenticate user: {}".format(username))
else:
    print("Success, {} has id {}".format(username, theUserRecord.id))