def _check_client_ip(req):
    """
    Is this client permitted to use the service?
    """
    client_ip = _get_client_ip(req)
    if client_ip in CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.keys():
        return True
    return False
def _check_client_ip(req):
    """
    Is this client permitted to use the service?
    """
    client_ip = _get_client_ip(req)
    if client_ip in CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.keys():
        return True
    return False
Exemple #3
0
     ('773__0', '773__c')),
    # Example: 1234567-p578-591.pdf
    ('recid and page-range',
     re.compile(r'(?i)(^\d+)[-_]p0*(\d+)-0*d+\.pdfa?$'), ('773__0', '773__c')),
    # Example: RepNo_CMS-pas123.pdf
    ('report-number', re.compile(r'(?i)^RepNo[_-](.*)\.pdfa?$'),
     ('reportnumber', )),
    # Example: anything.pdf
    ('garbage', re.compile(r'(?i)^(.+)\.pdfa?$'), ('rec_garbage', ))
]

_CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS_RE = re.compile(
    CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS)

_CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS = []
for _network, _collection in CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.items():
    if '/' not in _network:
        _network += '/32'
    _CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.append(
        (_ip_matcher_builder(_network), _collection))
    del _network
    del _collection


def cli_allocate_record(req):
    req.content_type = "text/plain"
    req.send_http_header()

    # check Authorization header
    allowed_by_token = _check_authorization_bearer(req)
Exemple #4
0
                              record_strip_empty_fields

try:
    from six import StringIO
except ImportError:
    from StringIO import StringIO

from sqlalchemy.exc import SQLAlchemyError as Error

PERMITTED_MODES = ['-i', '-r', '-c', '-a', '-ir',
                   '--insert', '--replace', '--correct', '--append']

_CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS_RE = re.compile(CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS)

_CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS = []
for _network, _collection in CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.items():
    if '/' not in _network:
        _network += '/32'
    _CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS.append((_ip_matcher_builder(_network), _collection))
    del _network
    del _collection


def cli_allocate_record(req):
    req.content_type = "text/plain"
    req.send_http_header()

    # check IP and useragent:
    if not _get_client_authorized_collections(_get_client_ip(req)):
        msg = "[ERROR] Sorry, client IP %s cannot use the service." % _get_client_ip(req)
        _log(msg)