def authenticate_user_if_possible(request, user):
    """This signs the user in.
    """
    if request.line.uri.startswith('/assets/'):
        pass
    elif 'Authorization' in request.headers:
        header = request.headers['authorization']
        if header.startswith('Basic '):
            user = _get_user_via_basic_auth(header)
            if not user.ANON:
                _turn_off_csrf(request)
    elif SESSION in request.headers.cookie:
        token = request.headers.cookie[SESSION].value
        user = User.from_session_token(token)
    return {'user': user}
dataset/ETHPy150Open gratipay/gratipay.com/gratipay/security/authentication.py/authenticate_user_if_possible/original