Ejemplo n.º 1
0
 def decorated(*args, **kwargs):
     auth = request.authorization
     if not auth:
         return unauthorized()
     elif not check_admin(auth.username, auth.password):
         return authenticate()
     return function(*args, **kwargs)
Ejemplo n.º 2
0
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return errors.unauthorized('Invalid cerdentials')
    return jsonify({
        'token': g.current_user.generate_auth_token(expiration=600),
        'expiration': 600
    })
Ejemplo n.º 3
0
 def decorated(*args, **kwargs):
     auth = request.authorization
     if not auth:
         return unauthorized()
     elif not check_auth(auth.username, auth.password, int(
             kwargs['userid'])):
         return authenticate()
     return f(*args, **kwargs)
Ejemplo n.º 4
0
def get_token():
    if g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({
        'token': g.current_user.generate_auth_token().encode('ascii'),
        'profile': {
            'email': g.current_user.email
        }
    })
Ejemplo n.º 5
0
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized("Invalid credentials")
    return jsonify({
        'token':
        g.current_user.getnerate_reset_token(expiration=3600),
        'expiration':
        3600
    })
Ejemplo n.º 6
0
Archivo: utils.py Proyecto: Rimco/OSPy
    def wrapper(*args, **kwargs):
        if not options.no_password:
            username = password = ''
            try:
                auth_data = web.ctx.env.get('HTTP_AUTHORIZATION')
                assert auth_data, 'No authentication data provided'

                http_auth = re.sub('^Basic ', '', auth_data)
                username, password = base64.decodestring(http_auth).split(':')
                logger.debug('Auth Attempt with: user:\'%s\' password:\'%s\'', username, password)

                assert test_password(password), 'Wrong password'
                # if (username, password) not in dummy_users:
                #     raise  # essentially a goto :P
            except:
                # no or wrong auth provided
                logger.exception('Unauthorized attempt user:\'%s\' password:\'%s\'', username, password)
                web.header('WWW-Authenticate', 'Basic realm="OSPy"')
                raise unauthorized()

        return func(*args, **kwargs)
Ejemplo n.º 7
0
    def wrapper(*args, **kwargs):
        if not options.no_password:
            username = password = ''
            try:
                auth_data = web.ctx.env.get('HTTP_AUTHORIZATION')
                assert auth_data, 'No authentication data provided'

                http_auth = re.sub('^Basic ', '', auth_data)
                username, password = base64.decodestring(http_auth).split(':')
                logger.debug('Auth Attempt with: user:\'%s\' password:\'%s\'',
                             username, password)

                assert test_password(password), 'Wrong password'
                # if (username, password) not in dummy_users:
                #     raise  # essentially a goto :P
            except:
                # no or wrong auth provided
                logger.exception(
                    'Unauthorized attempt user:\'%s\' password:\'%s\'',
                    username, password)
                web.header('WWW-Authenticate', 'Basic realm="OSPy"')
                raise unauthorized()

        return func(*args, **kwargs)
Ejemplo n.º 8
0
def auth_error():
    return unauthorized('Invalid credentials')
Ejemplo n.º 9
0
def get_token():
    if g.current_user.is_anonymous or g.token_used :
        return errors.unauthorized( 'Invalid cerdentials')
    return jsonify( {'token':g.current_user.generate_auth_token(expiration=600),
        'expiration':600})
Ejemplo n.º 10
0
def auth_error():
    return errors.unauthorized('Invalid credentials')
Ejemplo n.º 11
0
def get_token():
    if g.current_user.is_anonymous() or g.token_used:
        return unauthorized('Invalid credentials.')
    return jsonify({'token': g.current_user.generate_auth_token(
        expiration=3600), 'expiration': 3600
    })