JanusGraph Authentication from Python/Java

895 views
Skip to first unread message

Debasish Kanhar

unread,
Oct 11, 2017, 8:08:10 AM10/11/17
to JanusGraph users
Hi,

I wanted to implement a simple Database connector for JanusGraph. A basic for each connector for Database, may it be relational or anything requires an authentication string. Is there any way I can incorporate authentication for JanusGraph from inside Gremlin Python? Or any other way to create authentication for JanusGraph. Having a Java implementation is not a problem.

Thanks
Debasish

d.ka...@gmail.com

unread,
Oct 11, 2017, 8:08:20 AM10/11/17
to JanusGraph users

HadoopMarc

unread,
Oct 11, 2017, 4:28:34 PM10/11/17
to JanusGraph users
Hi Debasish,

You can use JanusGraph in two ways:
  1. In combination with gremlin server (both java and python), then see the authentication section at:
    http://tinkerpop.apache.org/docs/3.2.3/reference/#_security_and_execution
  2. As a database embedded in your application (jvm only), then you can use the Kerberos authentication for the underlying storage backend, e.g. HBase. So your application would need a Kerberos keytab and the right jaas config for your application to find the keytab.
HTH,    Marc

Op woensdag 11 oktober 2017 14:08:20 UTC+2 schreef Debasish Kanhar:

Debasish Kanhar

unread,
Oct 22, 2017, 6:49:25 AM10/22/17
to JanusGraph users
Hi HadoopMarc.

I followed the link you directed me to, and did following steps but just to be clear my understanding of 1st link wasnt perfect

Added the following to my existing properties file for gremlin-server and saved it as gremlin-remote-secure.yaml:
authentication: {
  className: org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator,
  config: {
    credentialsDb: conf/gremlin-server/tinkergraph-credentials.properties}}


while starting gremlin server as: 
Couldn't find file conf/gremlin-server/tinkergraph-credentials.properties

So, I created a copy of file conf/gremlin-server/janusgraph-cassandra.properties and renames it as conf/gremlin-server/tinkergraph-credentials.properties.

The server starts perfectly and then I open gremlin shell and do following:

bin/gremlin.sh
graph = JanusGraphFactory.open("conf/gremlin-server/tinkergraph-credentials.properties")
credentials = credentials(graph)
credentials.createUser("admin", "admin")


Logically, that creates user with username admin and password as admin. So I should be able to authenticate with those credentials also: 

I authenticate using a Python client named Goblin as that is only OGM for Janusraph which can help me query in Janus directly (I'm using Gremlin python 3.2.3 and it doesn't provide Cluster method)

async def run(loop, query):
cluster = await Cluster.open(loop, username='admin', password='admin')
client = await cluster.connect()
resp = await client.submit(query)
async for msg in resp:
messages.append(msg)
await cluster.close()

But after running, I'm unable to push anything to JanusGraph. When after running the above mentioned function, I still did a count of all vertex and it showed me 1, corresponding to user I just created but none of vertex or nodes created by calling the above mentioned function.

Is there something I'm missing out on? My specific query was to do I create tinkerpop-credentials.properties file?

Please note my config:
JanusGraph
Cassandra backend
ES indexing
Python client using Goblin.

Any alternatives for the same is also appreciated.

Thanks

HadoopMarc

unread,
Oct 23, 2017, 4:06:55 PM10/23/17
to JanusGraph users
Hi Debasish,

It seems you were almost there, my directions were rather global, indeed!

You are right that you have to combine the gremlin-server-secure.yaml file from the TinkerPop distribution with the gremlin-server.yaml from the JanusGraph distribution.
 
I would advise to first get the example from the TinkerPop ref docs working with your JanusGraph server. So, in addition, you have to copy
the tinkergraph-credentials.properties and data/credentials.kryo files from the TinkerPop distribution to the JanusGraph distribution. The credentials.kryo TinkerGraph file already contains the "stephen", "password" credentials. In your description above it was not clear to me whether you got the idea that gremlin server reads a second graph, the credentialsDb, in addition to your JanusGraph graph in Cassandra. The credentialsDb is not accessible to the graph application. You need separate properties files for the graph with your own data and for the credentialsDb graph (i.e. tinkergraph-credentials.properties).
After you succeed in connecting and authenticating from gremlin shell and can do the query you want, you can try to do the same using goblin/python. Of course, after that you can also use the Cassandra backend for the credentialsDb in case you want multiple gremlin-server instances to read the same credentialsDb.

I hope this helps you on your way,

Cheers,    Marc

Op zondag 22 oktober 2017 12:49:25 UTC+2 schreef Debasish Kanhar:
Reply all
Reply to author
Forward
0 new messages