Client API: Setting up Authentication and Authorization

Authentication and authorization is based on client X.509 certificates.

The authentication options argument in DocumentStore constructor property allows you to pass a certificate which will be used by the RavenDB client to connect to a server.

Note

If your RavenDB server instance is served using https, then your application is required to use a client certificate in order to be able to access the server. You can find more information here.

Example

import { DocumentStore } from "ravendb";
import * as fs from "fs";

// load certificate and prepare authentication options
const authOptions = {
    certificate: fs.readFileSync("C:\\ravendb\\client-cert.pfx"),
    type: "pfx", // or "pem"
    password: "my passphrase"
};

const store = new DocumentStore([ "https://my_secured_raven" ], "Northwind", authOptions);
store.initialize();

// proceed with your work here