How codewithiulian/coffeeshopper-is4 works
Project type and purpose
• This is a full-stack ASP.NET Core application demonstrating integration of IdentityServer 4 with ASP.NET Identity.
• It consists of four main deliverables:
• A Blazor front-end (“Client”)
• A REST API (“API”) serving coffee-shop data
• A DataAccess layer (EF Core contexts and migrations)
• An IdentityServer host (“Server”) for authentication/authorization
File structure
• Top-level projects:
• Client/ – Blazor UI (razor pages, token service)
• API/ – ASP.NET Core Web API (Controllers, Models, Services)
• DataAccess/ – EF Core DbContext, Entities, Migrations
• Server/ – IdentityServer4 host with ASP.NET Identity integration, Quickstart UI, multiple EF contexts (Identity, Configuration, Persisted Grants)
README
• States the purpose: integrate ASP.NET Identity with IdentityServer 4
• Implies OAuth2/OIDC flows will secure the API and UI
Main components
a. Frontend (Client)
• Blazor WebAssembly or Server-side app
• TokenService obtains and stores access tokens via IdentityServer OIDC endpoints
b. IdentityServer (Server)
• Hosts /connect/authorize, /connect/token, /connect/userinfo, etc.
• Underlying ASP.NET Identity user store (AspNetIdentityDbContext)
• ConfigurationDbContext (client, resources)
• PersistedGrantDbContext (tokens, consents)
c. CoffeeShop API (API)
• Exposes /api/coffeeshops endpoints
• Validates bearer tokens against IdentityServer
• Delegates business logic to CoffeeShopService and persistence to DataAccess
d. DataAccess (DataAccess)
• ApplicationDbContext with CoffeeShop entity
• EF Core migrations
• Connects to a SQL database
e. Database(s)
• One DB for application data
• One or more DBs (or schemas) for IdentityServer’s configuration, operational, and identity tables
Relationships and interactions
• User → Client UI: browser loads Blazor app
• Client → IdentityServer: OIDC authorize code flow to sign in, receive id_token and access_token
• Client → API: each API request includes the Bearer access_token
• API → DataAccess/ApplicationDbContext → Application DB: CRUD on CoffeeShop
• IdentityServer → AspNetIdentityDbContext → Identity DB: user lookup, password checks
• IdentityServer → ConfigurationDbContext → Config DB: client/resource settings
• IdentityServer → PersistedGrantDbContext → Operational DB: store tokens, consents
Architectural patterns and design principles
• Layered architecture: UI / API / Business services / Data access
• Separation of concerns: authentication & token service separated from data-oriented API
• Dependency injection of services (ICoffeeShopService, ITokenService)
• Use of EF Core Code-First migrations