Esempio n. 1
0
 def is_client_permitted(self, ip: str) -> bool:
     """
     Check whether a client is permitted.
     """
     return is_client_permitted(ip,
                                'server.whois.access_list',
                                default_deny=False)
Esempio n. 2
0
File: server.py Progetto: icing/irrd
    def handle_get(self, path) -> Tuple[HTTPStatus, str]:
        if not is_client_permitted(self.client_ip, 'server.http.access_list'):
            return HTTPStatus.FORBIDDEN, 'Access denied'

        if path.rstrip('/') != '/v1/status':
            return HTTPStatus.NOT_FOUND, 'Not found'

        content = StatusGenerator().generate_status()
        return HTTPStatus.OK, content
Esempio n. 3
0
def resolve_rpsl_object_journal(rpsl_object, info: GraphQLResolveInfo):
    """
    Resolve a journal subquery on an RPSL object.
    """
    database_handler = info.context['request'].app.state.database_handler
    access_list = f"sources.{rpsl_object['source']}.nrtm_access_list"
    if not is_client_permitted(info.context['request'].client.host,
                               access_list):
        raise GraphQLError(
            f"Access to journal denied for source {rpsl_object['source']}")

    query = RPSLDatabaseJournalQuery()
    query.sources([rpsl_object['source']]).rpsl_pk(rpsl_object['rpslPk'])
    for row in database_handler.execute_query(query, refresh_on_error=True):
        response = {snake_to_camel_case(k): v for k, v in row.items()}
        response['operation'] = response['operation'].name
        if response['origin']:
            response['origin'] = response['origin'].name
        if response['objectText']:
            response['objectText'] = remove_auth_hashes(response['objectText'])
        yield response
Esempio n. 4
0
    def get(self, request: Request) -> Response:
        if not is_client_permitted(request.client.host, 'server.http.status_access_list'):
            return PlainTextResponse('Access denied', status_code=403)

        response = StatusGenerator().generate_status()
        return PlainTextResponse(response)