Alex's Coding Blog
  • home
  • about
  • projects
  • contact

Blog

Working with Identity Server Local Apis

  • November 04, 2019 March 17, 2025
  • by Alexander

Some background: The Identity Server is powerful fully customizable authentication and authorization solution. I'm using it for last two years in my projects. It is cool system and most times works out of the box however, in some scenarios an cause a lot of troubles.

The official example can be found here Adding Apis. It's a good working example if you settings up Identity Server from scratch. However, in my case, I have to migrate existing endpoints from another application to existing Identity Server,ย which gives me no option to run the seeding data procedure(?).

To enable token validation for local API we just need to add the following to Startup.cs:

services.AddLocalApiAuthentication();

That was the easy part, now let's what is the tricky part: LocalApi schema is using IdentityServerApi scope. It is not added by default and need to be added manually in my case.

  1. Create the API Resource for your local API
INSERT  [dbo].[ApiResources] ([Enabled], [Name], [DisplayName], [Created], [NonEditable])
VALUES (1, 'apiAuth', 'Auth API', GETDATE(), 0)
  1. Create new API scope
INSERT [dbo].[ApiScopes] ([Name], [DisplayName], [Description], [Required], [Emphasize], [ShowInDiscoveryDocument], [ApiResourceId])
VALUES ('IdentityServerApi', 'Auth API', null, 0, 0, 1, <here comes the is from #1>)
  1. Add IdentityServerApi to client scopes:
INSERT [dbo].[ClientScopes] ([Scope], [ClientId])
VALUES ('IdentityServerApi', <clientId assuming you have one>)

To the full gist

How-to

๐Ÿš€ Turbocharge Your Kubernetes Cluster with my Terraform Kits! ๐Ÿš€

๐ŸŒŸ Slash deployment time and costs! Discover the ultimate solution for efficient, cost-effective Kubernetes Terraform Kits. Perfect for DevOps enthusiasts looking for a reliable, scalable setup.

Learn More about Terraform Kits for AKS,EKS and GKE

Alexander Lvovich

Solution Architect & Software Developer | Automating & Scaling Infrastructure

๐Ÿ’ก Working with Kubernetes, Istio, and DevOps. Got questions? Feel free to reach out!

Share on:

No comments are allowed for this post

Recent Posts

  • Securing Web Services Against Unwanted Traffic with NGINX
  • Optimizing API by Offloading Responsibilities to an API Gateway
  • How to Clean Up Local Branches of Remote Merged Branches
  • Resolving Namespace Overriding in Argo CD with Kustomize
  • Connecting to Gitlab's private Nuget registry
  • Why Istio?

Categories

  • Azure
  • Architecture
  • .NET Core
  • Certification
  • DevOps
  • How-to
  • Azure Functions
  • Serverless
  • Cosmos DB
  • Security
  • Thoughts
  • Kubernetes
  • Istio
ยฉ Copyright 2025, Alexander Lvovich. Theme by Colorlib
I use cookies and similar technologies on our website to enhance your browsing experience and analyze website traffic. By clicking "Accept," you consent with my Privacy Policy to the use of these technologies.
Accept