Skip to content

Latest commit

 

History

History

CK.DB.OIddict

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

CK.DB.OIddict

Getting started

Implement Sql Stores and entities on OpenIddict Core.

Use this package to have an sql implementation with CK Database. You can then follow the Samples from OpenIddict. You can consider this package as a replacement of the EntityFramework one.

// The stores are based on CK Database
var connectionString = "Server=.;Database=CKOpenIddictDefault;Integrated Security=True;TrustServerCertificate=true";
services.AddCKDatabase( new ActivityMonitor(), Assembly.GetEntryAssembly()!, connectionString );

// Add OpenIddict code flow like in samples
services.AddOpenIddict()
        .AddCore
        (
            builder =>
            {
                // Configure OpenIddict to use the CK Database stores and models.
                builder.UseOpenIddictCoreSql();
            }
        )
        .AddServer
        (
            builder =>
            {
                // see OpenIddict samples
            }
        )
        .AddValidation
        (
            builder =>
            {
                // see OpenIddict samples
            }
        );

And that is it.

Application

Of course, you need an application. There are Cris commands that you can call directly from your frontend app. You can also do a quick and dirty solution like in the sample. They are some examples on how to create, read, update or delete an application.

Here is an example to quickly setup an application from the C# code:

// Inject IOpenIddictApplicationManager into _applicationManager

var appDescriptor = new ApplicationDescriptorBuilder
                    (
                        "ckdb-default-app",
                        "901564A5-E7FE-42CB-B10D-61EF6A8F3654"
                    )
                    .WithDisplayName( "CK-DB Default application" )
                    .EnsureCodeDefaults()
                    .AddRedirectUri( new Uri( "https://localhost:5044/signin-oidc" ) )
                    .Build();

if( await _applicationManager.FindByClientIdAsync( appDescriptor.ClientId! ) == null )
    await _applicationManager.CreateAsync( appDescriptor );

About technical implementation and choices

For developers or this library

The core / main logic is handled by Stores. They are internally called by OpenIddict managers. Here they provide a way to access sql database created from Db. They are also indirectly called from Cris commands and queries.