How to use the neo4j.v1.basic_auth function in neo4j

To help you get started, we’ve selected a few neo4j examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github swarris / pyPaSWAS / pyPaSWAS / Core / GraphFormatter.py View on Github external
def __init__(self, logger, hitlist, outputfile, settings):
        
        ''' The output file name will be used as prefix for contig names 
        '''
        DefaultFormatter.__init__(self, logger, hitlist, outputfile)
        self.outputfile = outputfile.split("/")[-1]
        driver = GraphDatabase.driver("bolt://{}".format(settings.hostname), auth=basic_auth(settings.username, settings.password))
        self.session = driver.session()
        self.insert = []
        self.sequence_node=settings.sequence_node
        self.target_node=settings.target_node
github TwoBitAlchemist / NeoAlchemy / neoalchemy / graph.py View on Github external
if password is None:
            password = 'neo4j'

        try:
            protocol, url = url.split('://')
            if protocol.lower() != 'bolt':
                warnings.warn('Switching protocols. Only Bolt is supported.')
        except ValueError:
            pass

        try:
            credentials, url = url.split('@')
        except ValueError:
            kw['auth'] = basic_auth(user, password)
        else:
            kw['auth'] = basic_auth(*credentials.split(':', 1))

        self.driver = GraphDatabase.driver('bolt://%s' % url, **kw)
github TwoBitAlchemist / NeoAlchemy / neoalchemy / graph.py View on Github external
if user is None:
            user = 'neo4j'
        if password is None:
            password = 'neo4j'

        try:
            protocol, url = url.split('://')
            if protocol.lower() != 'bolt':
                warnings.warn('Switching protocols. Only Bolt is supported.')
        except ValueError:
            pass

        try:
            credentials, url = url.split('@')
        except ValueError:
            kw['auth'] = basic_auth(user, password)
        else:
            kw['auth'] = basic_auth(*credentials.split(':', 1))

        self.driver = GraphDatabase.driver('bolt://%s' % url, **kw)
github neo4j-examples / neo4j-movies-template / flask-api / app.py View on Github external
from flask_cors import CORS
from flask_restful import Resource, reqparse
from flask_restful_swagger_2 import Api, swagger, Schema

from neo4j.v1 import GraphDatabase, basic_auth, ResultError

from . import config


app = Flask(__name__)
app.config['SECRET_KEY'] = 'super secret guy'
api = Api(app, title='Neo4j Movie Demo API', api_version='0.0.10')
CORS(app)


driver = GraphDatabase.driver('bolt://localhost', auth=basic_auth(config.DATABASE_USERNAME, str(config.DATABASE_PASSWORD)))


def get_db():
    if not hasattr(g, 'neo4j_db'):
        g.neo4j_db = driver.session()
    return g.neo4j_db


@app.teardown_appcontext
def close_db(error):
    if hasattr(g, 'neo4j_db'):
        g.neo4j_db.close()


def set_user(sender, **extra):
    auth_header = request.headers.get('Authorization')
github THIBER-ORG / userline / src / lib / output / neo4j.py View on Github external
# TODO: Store this relations in a redis-like cache
		self.cache = Cache(cache_data)
		self.cache.create_cache(self.DEST_RELS)
		self.cache.create_cache(self.DOM_RELS)
		self.cache.create_cache(self.SRC_RELS)
		self.cache.create_cache(self.SRCDST_RELS)
		self.cache.create_cache(self.SRCLOGIN_RELS)
		self.cache.create_cache(self.SESSIONS_RELS)
		self.cache.create_cache(self.FROM_SESSIONS)
		self.cache.create_cache(self.USER_LIST)
		self.cache.create_cache(self.DOM_LIST)
		self.cache.create_cache(self.SRV_LIST)
		self.cache.create_cache(self.SRVDOM_RELS)

		# setup neo4j
		self.drv = GraphDatabase.driver(data[0], auth=basic_auth(data[1], data[2]))
		self.neo = self.drv.session()
		self.neo.run("CREATE INDEX ON :User(sid)")
		self.neo.run("CREATE INDEX ON :Computer(name)")
		self.neo.run("CREATE INDEX ON :Domain(name)")
github RTXteam / RTX / code / reasoningtool / QuestionAnswering / Q1Utils.py View on Github external
import QueryNCBIeUtils
except ImportError:
	sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../kg-construction')))  # Go up one level and look for it
	import QueryNCBIeUtils
import math
import MarkovLearning
import ReasoningUtilities as RU

requests_cache.install_cache('orangeboard')

sys.path.append(os.path.dirname(os.path.abspath(__file__))+"/../../")  # code directory
from RTXConfiguration import RTXConfiguration
RTXConfiguration = RTXConfiguration()

# Connection information for the neo4j server, populated with orangeboard
driver = GraphDatabase.driver(RTXConfiguration.bolt, auth=basic_auth("neo4j", "precisionmedicine"))
session = driver.session()

# Connection information for the ipython-cypher package
connection = "http://neo4j:precisionmedicine@" + RTXConfiguration.database
DEFAULT_CONFIGURABLE = {
	"auto_limit": 0,
	"style": 'DEFAULT',
	"short_errors": True,
	"data_contents": True,
	"display_limit": 0,
	"auto_pandas": False,
	"auto_html": False,
	"auto_networkx": False,
	"rest": False,
	"feedback": False,  # turn off verbosity in ipython-cypher
	"uri": connection,
github suprfanz / flask-fb-neo4j-d3 / neo4j2d3_mb.py View on Github external
def create_event_node():
    # fetches the event nodes from neo4j
    insert_query_guest = '''
    MATCH (a:fb_event)
    WITH collect({id:a.fb_event_id, name:a.event_name, group:0}) AS nodes RETURN nodes 
    '''
    with  GraphDatabase.driver("bolt://{}:7687".format(neo4j_dbip),
                               auth=basic_auth("neo4j", "{}".format(neo4j_password))) as driver:
        with driver.session() as session:
            result = session.run(insert_query_guest)
            for record in result:
                return json.dumps(record['nodes'])
github phenopolis / phenopolis / views / neo4j_setup.py View on Github external
def setup_neo4j_driver(host, port, password):
    default_password = 'neo4j' # Travis will use a fresh Neo4j, with the default password.
    local_password = password
    uri = "bolt://"+host+":"+str(port)

    # Try local_password.
    try:
        driver = GraphDatabase.driver(uri, auth=basic_auth("neo4j", local_password))
        return driver
    except:
        pass

    # Try default_password.
    # Password handling from https://github.com/robinedwards/django-neomodel
    driver = GraphDatabase.driver(uri, auth=basic_auth("neo4j", default_password))
    with driver.session() as neo4j_session:
        try:
            result = neo4j_session.run("MATCH (a:Person) WHERE a.name = {name} RETURN a", {"name": "Crick"})

        except CypherError as ce:
            if 'The credentials you provided were valid, but must be changed before you can use this instance' in str(ce):
                neo4j_session.run("CALL dbms.changePassword({password})", {'password': local_password})
                print("New database with no password set, setting password to '", local_password, "'.")
                neo4j_session.close()
github RTXteam / RTX / code / reasoningtool / QuestionAnswering / MarkovLearning.py View on Github external
np.warnings.filterwarnings('ignore')
import cypher
from collections import namedtuple
from neo4j.v1 import GraphDatabase, basic_auth
#import Q1Utils
import ReasoningUtilities as RU
import sys
import os


sys.path.append(os.path.dirname(os.path.abspath(__file__))+"/../../")  # code directory
from RTXConfiguration import RTXConfiguration
RTXConfiguration = RTXConfiguration()

# Connection information for the neo4j server, populated with orangeboard
driver = GraphDatabase.driver(RTXConfiguration.bolt, auth=basic_auth("neo4j", "precisionmedicine"))
session = driver.session()

# Connection information for the ipython-cypher package
connection = "http://neo4j:precisionmedicine@" + RTXConfiguration.database
DEFAULT_CONFIGURABLE = {
	"auto_limit": 0,
	"style": 'DEFAULT',
	"short_errors": True,
	"data_contents": True,
	"display_limit": 0,
	"auto_pandas": False,
	"auto_html": False,
	"auto_networkx": False,
	"rest": False,
	"feedback": False,  # turn off verbosity in ipython-cypher
	"uri": connection,