Home

Awesome

SharpGrip OpenIddict API NuGet

Builds

OpenIddict.Api [Build]

Quality Gate Status
Maintainability Rating
Reliability Rating
Security Rating
Coverage

Introduction

SharpGrip OpenIddict API is an extension of the OpenIddict library exposing the OpenIddict entities through a RESTful API.

Installation

Reference NuGet package SharpGrip.OpenIddict.Api (https://www.nuget.org/packages/SharpGrip.OpenIddict.Api).

Follow the OpenIddict installation guide Getting started and call the AddApi<TKey> extension method on the OpenIddictEntityFrameworkCoreBuilder.

serviceCollection.AddOpenIddict().AddCore(options =>
{
    options.UseEntityFrameworkCore()
        .UseDbContext<ApplicationDbContext>()
        .AddApi<long>();
});

Configuration

In case you are overriding the OpenIddict entities you need to use the AddApi<TApplication, TAuthorization, TScope, TToken, TKey> overload to make sure the API is working with the correct entity types.

Both AddApi extension methods expose an options builder with which you can configure your API. In the example below the Application API route will become /open-id-api/application and the endpoints exposed in that route will require an access token with the my_application_access_scope scope.

serviceCollection.AddOpenIddict().AddCore(options =>
{
    options.UseEntityFrameworkCore()
        .UseDbContext<ApplicationDbContext>()
        .AddApi<OpenIdApplication, OpenIdAuthorization, OpenIdScope, OpenIdToken, long>(apiConfiguration =>
        {
            apiConfiguration.ApiRoutePrefix = "open-id-api";
            apiConfiguration.ApplicationApiRoute = "application";
            apiConfiguration.ApplicationApiAccessScope = "my_application_access_scope";
        });
});

Properties

PropertyDefault valueDescription
ApiRoutePrefixapi/open-idThe prefix used in all the API routes.
ApplicationApiRouteapplicationThe Application API route.
ApplicationApiAccessScopeopen_id_application_api_accessThe access scope needed to access the Application endpoints.
AuthorizationApiRouteauthorizationThe Authorization API route.
AuthorizationApiAccessScopeopen_id_authorization_api_accessThe access scope needed to access the Authorization endpoints.
ScopeApiRoutescopeThe Scope API route.
ScopeApiAccessScopeopen_id_scope_api_accessThe access scope needed to access the Scope endpoints.
TokenApiRoutetokenThe Token API route.
TokenApiAccessScopeopen_id_token_api_accessThe access scope needed to access the Token endpoints.

Supported operations

Please find below an overview of the supported operations using the default route configuration.

Application

MethodEndpointDescriptionParameters
GETapi/open-id/applicationReturns all applications.
GETapi/open-id/application/{id}Returns an application by ID.string id
POSTapi/open-id/applicationCreates an application.ApplicationCreateModel
PUTapi/open-id/application/{id}Updates an application by ID.string id & ApplicationUpdateModel
DELETEapi/open-id/application/{id}Deletes an application by ID.string id

Authorization

MethodEndpointDescriptionParameters
GETapi/open-id/authorizationReturns all authorizations.
GETapi/open-id/application/{id}Returns an authorization by ID.string id

Scope

MethodEndpointDescriptionParameters
GETapi/open-id/scopeReturns all scopes.
GETapi/open-id/scope/{id}Returns a scope by ID.string id
POSTapi/open-id/scopeCreates a scope.ScopeCreateModel
PUTapi/open-id/scope/{id}Updates a scope by ID.string id & ScopeUpdateModel
DELETEapi/open-id/scope/{id}Deletes a scope by ID.string id

Token

MethodEndpointDescriptionParameters
GETapi/open-id/tokenReturns all tokens.
GETapi/open-id/token/{id}Returns a token by ID.string id