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)
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 })
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)
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 } })
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 })
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)
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)
def auth_error(): return unauthorized('Invalid credentials')
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})
def auth_error(): return errors.unauthorized('Invalid credentials')
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 })