identityserver4-azurestorage

Uses Azure Blob and Table Storage services as an alternative to Entity Framework/SQL data access for IdentityServer4. Use the unit tests as a guide to seeding operational and configuration data.

  • ElCamino.IdentityServer4.AzureStorage v1.x uses IdentityServer4 2.x & 3.x
  • ElCamino.IdentityServer4.AzureStorage v2.x uses IdentityServer4 >= 4.x

Build Status

NuGet Badge

IdentityServer4 v3 to v4

There are breaking changes when moving to IdentityServer4 v3 to v4. and respectively upgrading ElCamino.IdentityServer4.AzureStorage v1.x to v2.x.

Config changes to support ApiScope blobs

New config settings, complete settings further down.

{
  "IdentityServer4": {
   ...
    "resourceStorageConfig": {
      "apiScopeBlobContainerName": "idsrv4apiscopes",
      "apiScopeBlobCacheContainerName": "idsrv4apiscopescache",
    }...
  }
}

Changes to startup.cs

Shown below in complete context, add .MigrateResourceV3Storage() into the startup services pipline. Must be added after services.AddIdentityServer().AddResourceStore() in the pipeline. Remove after the first run.

Getting Started

startup.cs

using ElCamino.IdentityServer4.AzureStorage.Stores;
using ElCamino.IdentityServer4.AzureStorage.Services;
using IdentityServer4;
...
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
...
            //Add the Custom IdentityServer PersistentGrantStorageContext/Create Storage Table
            services.AddPersistedGrantContext(Configuration.GetSection("IdentityServer4:persistedGrantStorageConfig"))
                .CreatePersistedGrantStorage() //Can be removed after first run.
                .AddClientContext(Configuration.GetSection("IdentityServer4:clientStorageConfig"))
                .CreateClientStorage() //Can be removed after first run.
                .AddResourceContext(Configuration.GetSection("IdentityServer4:resourceStorageConfig"))
                .CreateResourceStorage() //Can be removed after first run.
                .AddDeviceFlowContext(Configuration.GetSection("IdentityServer4:deviceFlowStorageConfig"))
                .CreateDeviceFlowStorage(); //Can be removed after first run.

        // Adds IdentityServer
            services.AddIdentityServer()
            .AddSigningCredential(credential)            
            .AddResourceStore<ResourceStore>()
            .AddClientStore<ClientStore>()
            .AddCorsPolicyService<StorageCorsPolicyService>()
            .AddPersistedGrantStore<PersistedGrantStore>()
            .AddDeviceFlowStore<DeviceFlowStore>()
...            
            //Use for migrating ApiScopes from IdentityServer4 v3 ApiResources
            //Must be added after services.AddIdentityServer().AddResourceStore() in the pipeline
            //services.MigrateResourceV3Storage();

...

appsettings.json

{
  "IdentityServer4": {
    "persistedGrantStorageConfig": {
      "storageConnectionString": "UseDevelopmentStorage=true;",
      "blobContainerName": "idsrv4persistedgrants",
      "persistedGrantTableName": "idsrv4persistedgrant",
      "enableTokenCleanup": true,
      "tokenCleanupInterval": 3600,
      "tokenCleanupBatchSize": 100
    },
    "clientStorageConfig": {
      "storageConnectionString": "UseDevelopmentStorage=true;",
      "blobContainerName": "idsrv4clientconfig",
      "blobCacheContainerName": "idsrv4clientconfigcache",
      "enableCacheRefresh": true,
      "cacheRefreshInterval": 1800
    },
    "resourceStorageConfig": {
     "storageConnectionString": "UseDevelopmentStorage=true;",
      "apiTableName": "idsrv4apiscopeindex",
      "apiBlobContainerName": "idsrv4apiresources",
      "apiScopeBlobContainerName": "idsrv4apiscopes",
      "identityBlobContainerName": "idsrv4identityresources",
      "apiBlobCacheContainerName": "idsrv4apiresourcescache",
      "apiScopeBlobCacheContainerName": "idsrv4apiscopescache",
      "identityBlobCacheContainerName": "idsrv4identityresourcescache",
      "enableCacheRefresh": true,
      "cacheRefreshInterval": 1800
    },
    "deviceFlowStorageConfig": {
      "storageConnectionString": "UseDevelopmentStorage=true;",
      "blobUserContainerName": "deviceflowusercodes",
      "blobDeviceContainerName": "deviceflowdevicecodes"
    }
  }
}

Identityserver4 Azurestorage

Uses Azure Blob and Table Storage services as an alternative to Entity Framework/SQL data access for IdentityServer4.

Identityserver4 Azurestorage Info

⭐ Stars 12
🔗 Source Code github.com
🕒 Last Update a month ago
🕒 Created 3 years ago
🐞 Open Issues 6
➗ Star-Issue Ratio 2
😎 Author dlmelendez