### Install Duende IdentityServer Templates Source: https://docs.duendesoftware.com/identityserver/quickstarts/1-client-credentials Installs the Duende IdentityServer templates for the .NET CLI, enabling the creation of quickstart projects. ```bash dotnet new install Duende.Templates ``` -------------------------------- ### Install Duende IdentityServer Templates Source: https://docs.duendesoftware.com/identityserver/quickstarts/0-overview Installs the necessary Duende IdentityServer templates for ASP.NET Core applications. This is a prerequisite for following the quickstart tutorials. ```bash dotnet new install Duende.Templates ``` -------------------------------- ### Install Duende Templates Source: https://docs.duendesoftware.com/index Installs the Duende templates for .NET, allowing for quick project setup. This command is executed in the terminal. ```bash dotnet new install Duende.Templates ``` -------------------------------- ### Create IdentityServer Project Source: https://docs.duendesoftware.com/identityserver/quickstarts/1-client-credentials Creates a new ASP.NET Core web project with a basic IdentityServer setup using the 'duende-is-empty' template. It installs the IdentityServer package and adds minimal configuration. ```bash cd src dotnet new duende-is-empty -n IdentityServer ``` -------------------------------- ### Install and Copy oidc-client Source: https://docs.duendesoftware.com/identityserver/quickstarts/javascript-clients/js-without-backend Installs the 'oidc-client' JavaScript library using NPM and then copies the necessary distribution files into the 'wwwroot' directory for the application to serve. ```Bash npm i oidc-client copy node_modules/oidc-client/dist/* wwwroot ``` -------------------------------- ### Install OIDC NuGet Package Source: https://docs.duendesoftware.com/identityserver/quickstarts/2-interactive Installs the Microsoft.AspNetCore.Authentication.OpenIdConnect NuGet package to the WebClient project to enable OIDC authentication. ```bash dotnet add package Microsoft.AspNetCore.Authentication.OpenIdConnect ``` -------------------------------- ### Add Duende IdentityServer UI Source: https://docs.duendesoftware.com/identityserver/quickstarts/2-interactive Adds the quickstart UI to an IdentityServer project using the .NET CLI. ```bash dotnet new duende-is-ui ``` -------------------------------- ### Example Local API Controller Source: https://docs.duendesoftware.com/bff/getting-started/single-frontend Provides an example of a self-contained local API controller (`LocalApiController`) that returns a "hello world" message. This controller is designed to be integrated into a BFF application and can be secured using Duende BFF's endpoint protection mechanisms. ```csharp [Route("hello")] publicclassLocalApiController : ControllerBase { [Route("world")] [HttpGet] public IActionResult SelfContained() { returnOk("hello world"); } } ``` -------------------------------- ### Install Configuration API Package Source: https://docs.duendesoftware.com/identityserver/configuration/dcr Installs the Duende.IdentityServer.Configuration NuGet package using the .NET CLI. This package is required to add the Configuration API's services. ```bash dotnetaddpackageDuende.IdentityServer.Configuration ``` -------------------------------- ### Duende Software Client Configuration Example Source: https://docs.duendesoftware.com/identityserver/diagnostics/data This snippet shows a configuration example for a client named 'interactive' within the Duende Software identity server. ```json { "ClientId": "interactive" } ``` -------------------------------- ### Install Duende Templates Source: https://docs.duendesoftware.com/identityserver/overview/packaging Command to install the Duende.Templates NuGet package for the .NET CLI. This enables the use of Duende-specific project templates. ```bash dotnet new install Duende.Templates ``` -------------------------------- ### Install Configuration API Entity Framework Package Source: https://docs.duendesoftware.com/identityserver/configuration/dcr Installs the Duende.IdentityServer.Configuration.EntityFramework NuGet package using the .NET CLI. This package provides the Entity Framework implementation for the client configuration store. ```bash dotnetaddpackageDuende.IdentityServer.Configuration.EntityFramework ``` -------------------------------- ### Install OpenID Connect NuGet Package Source: https://docs.duendesoftware.com/identityserver/fundamentals/openid-connect-events This command installs the necessary NuGet package for integrating OpenID Connect authentication in ASP.NET Core applications. It enables the use of the OpenIdConnectHandler. ```bash dotnet package add Microsoft.AspNetCore.Authentication.OpenIdConnect ``` -------------------------------- ### Create Duende IdentityServer Project Source: https://docs.duendesoftware.com/index Creates a new project using the Duende IdentityServer template. This command is executed in the terminal after installing the templates. ```bash dotnet new duende-is ``` -------------------------------- ### Create Solution and Project Structure Source: https://docs.duendesoftware.com/identityserver/quickstarts/1-client-credentials Creates a new solution directory, a subdirectory for source code, and initializes a new .NET solution file. This sets up the basic structure for the quickstart project. ```bash mkdir quickstart cd quickstart mkdir src dotnet new sln -n Quickstart ``` -------------------------------- ### Authorize Request URL Example Source: https://docs.duendesoftware.com/identityserver/reference/endpoints/authorize An example of a GET request to the /connect/authorize endpoint with common query parameters such as client_id, scope, response_type, redirect_uri, state, and nonce. ```HTTP GET /connect/authorize? client_id=client1& scope=openid email api1& response_type=id_token token& redirect_uri=https://myapp/callback& state=abc& nonce=xyz ``` -------------------------------- ### Token Management Quickstart Source: https://docs.duendesoftware.com/identityserver/quickstarts/3a-token-management This section provides a quickstart guide for managing access tokens in Duende IdentityServer. It covers requesting refresh tokens, caching tokens, using access tokens until expiration, and using refresh tokens to obtain new access tokens. It also highlights the Duende.AccessTokenManagement library for token storage and automatic refresh. ```csharp using Duende.AccessTokenManagement; // ... // Request a refresh token in addition to the access token at login time // Cache those tokens // Use the access token to call APIs until it expires // Use the refresh token to get a new access token // Repeat the process of caching and refreshing with the new token // Duende.AccessTokenManagement provides abstractions for storing tokens, automatic refresh of expired tokens, etc. ``` -------------------------------- ### Create ASP.NET Core Project with Duende.BFF Source: https://docs.duendesoftware.com/bff/getting-started/single-frontend This snippet demonstrates how to create a new ASP.NET Core Web Application and navigate into its directory using the .NET CLI. ```bash dotnet new web -n MyBffApp cd MyBffApp ``` -------------------------------- ### Create OIDC Client Application Source: https://docs.duendesoftware.com/identityserver/quickstarts/2-interactive This guide explains how to create an ASP.NET Core Razor Pages application that uses Duende IdentityServer for authentication. It covers installing the necessary NuGet package, configuring authentication services, setting up the request pipeline, and displaying authentication cookies. ```C# // Install the OIDC NuGet Package: // dotnet add package Duende.IdentityModel.OidcClient ``` ```C# // Configure Authentication Services (in Program.cs or Startup.cs): // builder.Services.AddAuthentication("Cookies") // .AddCookie("Cookies"); // // builder.Services.AddOidcAuthentication(options => // { // options.Authority = "https://localhost:5001"; // IdentityServer URL // options.ClientId = "web_client"; // options.Scope.Add("api1"); // options.Scope.Add("openid"); // options.Scope.Add("profile"); // options.CallbackPath = new PathString("/signin-oidc"); // }); ``` ```C# // Configure the Pipeline (in Program.cs or Startup.cs): // app.UseAuthentication(); // app.UseAuthorization(); ``` ```C# // Display the Auth Cookie (in a Razor Page or Controller): // var authProperties = new AuthenticationProperties // { // RedirectUri = Url.Content("~") // }; // return Challenge(authProperties, "Cookies"); ``` -------------------------------- ### Add a Frontend During Startup Source: https://docs.duendesoftware.com/bff/fundamentals/multi-frontend Demonstrates the simplest way to add a frontend during application startup using the AddBff() and WithFrontends() methods. ```C# services .AddBff() .WithFrontends(new BffFrontend(BffFrontendName.Parse("frontend1"))); ``` -------------------------------- ### Sample Project for Migration Source: https://docs.duendesoftware.com/identityserver/upgrades/identityserver4-v3-to-duende-identityserver-v6 Provides a link to a sample project designed to assist with the migration process from IdentityServer4 to Duende IdentityServer. ```General A sample project for this migration exercise is located here. ``` -------------------------------- ### Register Server Data Accessor and Map Embedded API Endpoint (C#) Source: https://docs.duendesoftware.com/bff/fundamentals/blazor/rendering-modes This snippet demonstrates server-side setup for accessing data directly. It registers a server implementation of IDataAccessor and maps a GET endpoint '/some_data' that requires authorization and uses the BFF API endpoint convention. ```csharp // Setup on the server // Register the server implementation for accessing some data builder.Services.AddSingleton(); // Register an api that will access the data app.MapGet("/some_data", async (IDataAccessor dataAccessor) =>awaitdataAccessor.GetData()) .RequireAuthorization() .AsBffApiEndpoint(); // Create a class that would actually get the data from the database internalclassServerWeatherClient() : IDataAccessor { public Task GetData() { // get the actual data from the database } } ``` -------------------------------- ### Integrate IdentityServer with ASP.NET Core Identity Source: https://docs.duendesoftware.com/identityserver/quickstarts/5-aspnetid This section details the process of integrating IdentityServer with ASP.NET Core Identity. It assumes familiarity with ASP.NET Core Identity and recommends starting from a copy of the reference implementation of Quickstart 4. The approach involves creating a new project for the IdentityServer host to incorporate necessary UI assets for login and logout functionality. ```C# using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; // ... other usings public class ApplicationDbContext : IdentityDbContext { public ApplicationDbContext(DbContextOptions options) : base(options) { } // Add any additional DbSets or configurations here } public class ApplicationUser : IdentityUser { // Add custom properties to your user model if needed } ``` -------------------------------- ### Create and Add Client Project Source: https://docs.duendesoftware.com/identityserver/quickstarts/1-client-credentials These Bash commands demonstrate how to create a new console client project within an existing solution structure and then add it to the solution file. ```Bash cd src dotnet new console -n Client ``` ```Bash cd .. dotnet sln add ./src/Client ``` -------------------------------- ### Create Duende IdentityServer Empty Project Source: https://docs.duendesoftware.com/identityserver/overview/packaging Command to create a new project using the 'Duende IdentityServer Empty' template. This serves as a minimal starting point for an IdentityServer instance. ```bash dotnet new duende-is-empty ``` -------------------------------- ### Install Duende.AccessTokenManagement NuGet Package Source: https://docs.duendesoftware.com/accesstokenmanagement/web-apps This command installs the Duende.AccessTokenManagement library via the .NET CLI. Ensure you are in your project directory when executing this command. ```bash dotnet add package Duende.AccessTokenManagement.OpenIdConnect ``` -------------------------------- ### Docker Hosting for BFF and IdentityServer Source: https://docs.duendesoftware.com/bff/samples This sample demonstrates how to host the BFF framework and IdentityServer using Docker containers. It was contributed by @Marco Cabrera. ```C# // Sample code for Docker Hosting would go here. // This is a placeholder as the provided text only describes the sample. ``` -------------------------------- ### Install Duende.IdentityServer.AspNetIdentity NuGet Package Source: https://docs.duendesoftware.com/identityserver/aspnet-identity Installs the necessary NuGet package for integrating ASP.NET Identity with IdentityServer. This package provides the required extensions and implementations. ```bash dotnet add package Duende.IdentityServer.AspNetIdentity ``` -------------------------------- ### Create API Project using .NET CLI Source: https://docs.duendesoftware.com/identityserver/quickstarts/1-client-credentials Demonstrates creating a new ASP.NET Core Web API project named 'Api' using the .NET CLI. It also includes commands to add the newly created API project to the solution file. ```bash cd src dotnet new webapi -n Api --no-openapi cd .. dotnet sln add ./src/Api ``` -------------------------------- ### Create ASP.NET Core Project for BFF Source: https://docs.duendesoftware.com/bff/getting-started/multi-frontend This snippet demonstrates how to create a new ASP.NET Core project that will serve as the Backend for Frontend (BFF). It uses the .NET CLI to scaffold a new web application and then navigates into the project directory. ```bash dotnet new web -n MyMultiBffApp cd MyMultiBffApp ``` -------------------------------- ### Install Duende.IdentityServer.EntityFramework NuGet Package Source: https://docs.duendesoftware.com/identityserver/data/ef This command installs the EntityFramework integration NuGet package for IdentityServer, enabling the use of EF-supported databases for configuration and operational stores. ```bash dotnet add package Duende.IdentityServer.EntityFramework ``` -------------------------------- ### Create Configuration API Project Source: https://docs.duendesoftware.com/identityserver/configuration/dcr Creates a new empty web application project for the Configuration API using the .NET CLI. ```bash dotnet new web -n Configuration ``` -------------------------------- ### Access Token CNF Claim Example Source: https://docs.duendesoftware.com/identityserver/tokens/pop An example of the 'cnf' claim within an access token, which embeds the thumbprint of the public key JWK used for Proof-of-Possession (DPoP). ```JSON { "cnf": { "jkt": "JGSVlE73oKtQQI1dypYg8_JNat0xJjsQNyOI5oxaZf4" } } ``` -------------------------------- ### Configure Duende BFF Options Source: https://docs.duendesoftware.com/bff/fundamentals/options Demonstrates how to configure Duende BFF framework options at startup using C#. The `AddBff` extension method on `IServiceCollection` is used to set various configuration aspects. ```C# builder.Services.AddBff(options => { // configure options here... }) ``` -------------------------------- ### UserInfo Endpoint Response Example Source: https://docs.duendesoftware.com/identityserver/reference/endpoints/userinfo Provides an example of a successful HTTP response from the UserInfo endpoint, including the status code and a JSON payload containing user claims. ```http GET /connect/userinfo Authorization: Bearer ``` ```json HTTP/1.1 200 OK Content-Type: application/json { "sub": "248289761001", "name": "Bob Smith", "given_name": "Bob", "family_name": "Smith" } ``` -------------------------------- ### Create Blazor BFF App Project Structure Source: https://docs.duendesoftware.com/bff/getting-started/blazor This snippet demonstrates how to create a new Blazor application with a Server project and a client project using the .NET CLI. It initializes an interactive Blazor application. ```bash mkdir BlazorBffApp cd BlazorBffApp dotnet new blazor --interactivity auto --all-interactive ``` -------------------------------- ### Duende IdentityModel OIDC Client Samples Overview Source: https://docs.duendesoftware.com/identitymodel-oidcclient/samples This snippet provides an overview of the IdentityModel.OidcClient samples, detailing the platforms and UI tools supported, such as .NET MAUI, WPF, WinForms, and Console Applications. It mentions the use of a demo Duende IdentityServer instance and provides login credentials. ```text Samples of IdentityModel.OidcClient are available on GitHub. Our samples show how to use an OidcClient with a variety of platforms and UI tools, including: * .NET MAUI * WPF with the system browser * WPF with an embedded browser * WinForms with an embedded browser * Cross Platform Console Applications (relies on kestrel for processing the callback) * Windows Console Applications (relies on an HttpListener - a wrapper around the windows HTTP.sys driver) * Windows Console Applications using custom uri schemes All samples use a demo instance of Duende IdentityServer as their OIDC Provider. You can see its source code on GitHub. You can log in with _alice/alice_ or _bob/bob_ ``` -------------------------------- ### Install Duende.AccessTokenManagement.OpenIdConnect NuGet Package Source: https://docs.duendesoftware.com/accesstokenmanagement Installs the Duende.AccessTokenManagement.OpenIdConnect NuGet package for managing access token lifetimes using a refresh token for API calls on behalf of a logged-in user. ```bash dotnet add package Duende.AccessTokenManagement.OpenIdConnect ``` -------------------------------- ### JavaScript Client Setup for IdentityServer Source: https://docs.duendesoftware.com/identityserver/quickstarts/javascript-clients/js-without-backend This section details the steps to set up a JavaScript client application to register with IdentityServer. It covers modifying hosting, adding static file middleware, referencing the 'oidc-client' library, and adding HTML and JavaScript files for the client. ```JavaScript // Reference oidc-client // Add HTML and JavaScript Files // Example: index.html and app.js ``` -------------------------------- ### Install Duende.AccessTokenManagement NuGet Package Source: https://docs.duendesoftware.com/accesstokenmanagement Installs the Duende.AccessTokenManagement NuGet package for machine-to-machine token management. This package is essential for acquiring and managing client credentials based access tokens. ```bash dotnet add package Duende.AccessTokenManagement ``` -------------------------------- ### Create Duende BFF Project (Local API) Source: https://docs.duendesoftware.com/bff/architecture/ui-hosting This command creates a new Duende BFF project configured to use a local API. This is suitable for simpler applications or development environments where the API is co-located. ```bash dotnet new duende-bff-localapi ``` -------------------------------- ### Install Entity Framework Core Design Tools Source: https://docs.duendesoftware.com/identityserver/quickstarts/4-entity-framework Installs the global Entity Framework Core CLI tool and the Microsoft.EntityFrameworkCore.Design NuGet package. These are necessary for generating and managing database migrations. ```bash dotnet tool install --global dotnet-ef dotnet add package Microsoft.EntityFrameworkCore.Design ``` -------------------------------- ### Configure Pipeline to Initialize Database (C#) Source: https://docs.duendesoftware.com/identityserver/quickstarts/4-entity-framework This C# method demonstrates how to integrate the database initialization logic into the application's pipeline. It calls the `InitializeDatabase` method within the `ConfigurePipeline` method, ensuring the database is set up when the application starts, particularly in development environments. ```csharp publicstatic WebApplication ConfigurePipeline(this WebApplication app) { app.UseSerilogRequestLogging(); if (app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } InitializeDatabase(app); //... } ``` -------------------------------- ### CIBA Endpoint Request Example Source: https://docs.duendesoftware.com/identityserver/reference/endpoints/ciba This snippet shows an example HTTP POST request to the /connect/ciba endpoint for initiating a CIBA authentication flow. It includes common parameters like client_id, scope, and login_hint. ```HTTP POST /connect/ciba client_id=client1& client_secret=secret& scope=openid api1& login_hint=alice ``` -------------------------------- ### Create ASP.NET Web Application Source: https://docs.duendesoftware.com/identityserver/quickstarts/2-interactive Creates a new ASP.NET web application project named 'WebClient' and adds it to the solution file. ```bash dotnet new webapp -n WebClient cd .. dotnet sln add ./src/WebClient ``` -------------------------------- ### Install Entity Framework Core Sqlite Package Source: https://docs.duendesoftware.com/identityserver/quickstarts/4-entity-framework Installs the Microsoft.EntityFrameworkCore.Sqlite NuGet package to enable Sqlite support for Duende IdentityServer's Entity Framework stores. This is a prerequisite for using Sqlite as the database provider. ```bash dotnet add package Microsoft.EntityFrameworkCore.Sqlite ```