I'm looking for some help in retrieving a user id from the binary network token generated through OrientDB:
https://github.com/orientechnologies/orientdb/wiki/Network-Binary-Token-Format
I'm able to authenticate users and retrieve the token, but am so far unable to identify the authenticated user to my (nodejs) application, which is incredibly frustrating!
My assumption is that the token would be a jwt, which I could decode in my client app, using the key configured in orientdb-server-config as secret. The encryption algorithm I have configured is HmacSHA256.
I'm using the binary network protocol via Oriento. Upon authentication this yields a token as byte array, which I hoped to be able to convert to base64 encoded string, and then validate and decode using an appropriate library e.g.
https://github.com/auth0/node-jsonwebtoken.
Firstly, is my assumption correct that the token should be jwt? If so, how can I convert the provided token (byte array) to a valid base64 encoded string representation of the jwt? I would expect to see a string composed of three period-delimited base64 encoded parts that should validate at
http://jwt.io/.
Trying...
tokenAsBuffer.toString('base64')
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '') // make url safe
...gives a base64 encoded string but not segmented as expected for a valid jwt.
Any help greatly appreciated!