Beispiel #1
0
def index():
    sources_ids = match_ids('sources', authz.sources(authz.READ))
    q = Document.all().filter(Document.source_id.in_(sources_ids))
    hashes = request.args.getlist('content_hash')
    if len(hashes):
        q = q.filter(Document.content_hash.in_(hashes))
    return jsonify(Pager(q))
Beispiel #2
0
def index():
    sources_ids = match_ids('sources', authz.sources(authz.READ))
    q = Document.all().filter(Document.source_id.in_(sources_ids))
    hashes = request.args.getlist('content_hash')
    if len(hashes):
        q = q.filter(Document.content_hash.in_(hashes))
    return jsonify(Pager(q))
Beispiel #3
0
def status():
    return jsonify({
        'logged_in': authz.logged_in(),
        'api_key': request.auth_role.api_key if authz.logged_in() else None,
        'role': request.auth_role,
        'roles': list(request.auth_roles),
        'permissions': {
            'watchlists': {
                'read': authz.watchlists(authz.READ),
                'write': authz.watchlists(authz.WRITE)
            },
            'sources': {
                'read': authz.sources(authz.READ),
                'write': authz.sources(authz.WRITE)
            }
        },
        'logout': url_for('.logout')
    })
Beispiel #4
0
def status():
    enable_cache(vary_user=True)
    return jsonify({
        'logged_in': authz.logged_in(),
        'api_key': request.auth_role.api_key if authz.logged_in() else None,
        'role': request.auth_role,
        'roles': list(request.auth_roles),
        'permissions': {
            'collections': {
                'read': authz.collections(authz.READ),
                'write': authz.collections(authz.WRITE)
            },
            'sources': {
                'read': authz.sources(authz.READ),
                'write': authz.sources(authz.WRITE)
            }
        },
        'logout': url_for('.logout')
    })
Beispiel #5
0
def status():
    enable_cache(vary_user=True)
    return jsonify({
        'logged_in': authz.logged_in(),
        'api_key': request.auth_role.api_key if authz.logged_in() else None,
        'role': request.auth_role,
        'roles': list(request.auth_roles),
        'permissions': {
            'collections': {
                'read': authz.collections(authz.READ),
                'write': authz.collections(authz.WRITE)
            },
            'sources': {
                'read': authz.sources(authz.READ),
                'write': authz.sources(authz.WRITE)
            }
        },
        'logout': url_for('.logout')
    })
Beispiel #6
0
def query():
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    result['alert'] = None
    if authz.logged_in():
        result['alert'] = Alert.exists(request.args, request.auth_role)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Beispiel #7
0
def query():
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    result['alert'] = None
    if authz.logged_in():
        result['alert'] = Alert.exists(request.args, request.auth_role)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Beispiel #8
0
def _query(escape=False):
    '''
    everything here should be applicable both to the internal and to the
    public api
    '''
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args, escape=escape)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return result
Beispiel #9
0
def index():
    q = Source.all_by_ids(ids=authz.sources(authz.READ))
    return jsonify(Pager(q))
Beispiel #10
0
Datei: util.py Projekt: 01-/aleph
def authz_filter(q):
    return add_filter(q, {
        "terms": {"source_id": list(authz.sources(authz.READ))}
    })
Beispiel #11
0
def index():
    q = Source.all_by_ids(ids=authz.sources(authz.READ))
    return jsonify(Pager(q))
Beispiel #12
0
def authz_sources_filter(q):
    return add_filter(q, {
        "terms": {"source_id": list(authz.sources(authz.READ))}
    })
Beispiel #13
0
def index():
    pager = Pager(Source.all(ids=authz.sources(authz.READ)))
    return jsonify(pager)