Skip to content

panoukos41/couchdb-openiddict

Repository files navigation

P41.OpenIddict.CouchDB

Release NuGet License

CouchDB store provider for the Openiddict using CouchDB.NET.

The project was insipired from the existing OpenIddict MongoDB implementation.

Before Getting started

This project was made in a hurry and was live tested on a really simple application so some things might not work as expected. Feel free to open an issue and even a pull request.

I will try my best to support the project and provide tests and samples whenever i find time.

Thanks for looking at this library 😄

Getting Started

By default a database named openiddict is used but you can change it using the options overload.

Your CouchDB database must implement the ddoc.json in the ddocs folder.

At your Startup.cs add your ICouchClient in DI and use the following code.

// Configure OpenIddict stores and services.
services.AddOpenIddict()
    // Register the OpenIddict core components and to use the CouchDb stores and models.
    .AddCore(options => options.UseCouchDb())

Or you can provide your own instance of ICouchClient in the options.

// Configure OpenIddict stores and services.
// With custom client.
services.AddOpenIddict()
    // Register the OpenIddict core components and to use the CouchDb stores and models.
    .AddCore(options => options
        .UseCouchDb(options => options
            .UseClient(new CouchClient("http://localhost:5984"))))

You can also customize the design document and views used by the library. More information as to what a view returns and when can be found in the ddocs fodler.

services.AddIdentity<CouchDbUser, CouchDbRole>()
        .AddCouchDbStores(options => options
            .UseViewOptions(new CouchDbOpenIddictViewOptions
            {
                Document = "openiddict";
                Application = "application";
                ApplicationClientId = "application.client_id";
                ApplicationRedirectUri = "application.redirect_uris";
                ApplicationPostLogoutRedirectUri = "application.post_logout_redirect_uris";
                Authorization = "authorization";
                AuthorizationApplicationId = "authorization.application_id";
                AuthorizationSubject = "authorization.subject";
                AuthorizationPrune = "authorization.prune";
                Scope = "scope";
                ScopeName = "scope.name";
                ScopeResources = "scope.resources";
                Token = "token";
                TokenApplicationId = "token.application_id";
                TokenAuthorizationId = "token.authorization_id";
                TokenReferenceId = "token.reference_id";
                TokenSubject = "token.subject";
                TokenPrune = "token.prune";
            })));

Services are registered as Singleton since ICouchClient is/should be registered as such and no other dependency is needed.

LICENSE

The project is Licensed under the Apache-2.0 License see the LICENSE for more info.

Packages

No packages published

Languages