RavenDB API Key and Windows Authentication

RavenDB API Key and Windows Authentication A couple weeks ago while playing around with a new version of RavenDb hosted under IIS I ran accross authentication issues. After some investigation it became clear setting up RavenDB Authentication would resolve the issue. The documentation from RavenDB for Windows Authentication and OAuth configurations is good. If you decide to leverage OAuth, an RavenDB API Keys must be setup.

Host RavenDb in IIS:

Click on `New Database` to launch the database creation wizard seen below.Click on New Database to launch the database creation wizard seen below.

Advanced Settings are available permitting an override of database, log, and index locations.Advanced Settings are available permitting an override of database, log, and index locations.

SocialTrails database created successfully.SocialTrails database created successfully.

The documentation from RavenDb shows how to configure this by convention. Recently I’ve been using more convention based configuration but in this scenario I’d prefer to set in my app.config. I specifically want to leverage app.config transformations to alter the configuration between environments and prevent my information from getting into github. Below is an example app.config and app.debug.config transformation example. I’m using SlowCheetah – XML Transforms to perform app.config transformations.

app.config
1
2
3
4
 <connectionStrings>
    <add name="RavenDbSocialTrails" connectionString="" />
    <add name="RavenDbSocialTrailsSecure" connectionString="" />
  </connectionStrings>
app.debug.config
1
2
3
4
5
6
7
8
9
10
<connectionStrings>
    <add    name="RavenDbSocialTrails"
            connectionString="DataDir=~\App_Data\Database"
            xdt:Transform="SetAttributes"
            xdt:Locator="Match(name)" />
    <add    name="RavenDbSocialTrailsSecure"
            connectionString="Url=http://localhost:9090/ravendb; ApiKey=MyName/MySecureKey; Database=SocialTrails"
            xdt:Transform="SetAttributes"
            xdt:Locator="Match(name)" />
</connectionStrings>

References

Comments