Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:5325",
"environmentVariables": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.4.2" />
<Sdk Name="Aspire.AppHost.Sdk" Version="13.1.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -15,9 +15,4 @@
<ProjectReference Include="..\IdentityServer\IdentityServer.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="9.4.2" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.4.2" />
</ItemGroup>

</Project>
14 changes: 10 additions & 4 deletions IdentityServer/v7/Diagnostics/Aspire/Aspire.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
var builder = DistributedApplication.CreateBuilder(args);

var apiService = builder.AddProject<Projects.Aspire_ApiService>("apiservice");
var identityServer = builder.AddProject<Projects.IdentityServer>("identityserver")
.WithExternalHttpEndpoints();

builder.AddProject<Projects.Aspire_Web>("webfrontend")
.WithReference(apiService);
var apiService = builder.AddProject<Projects.Aspire_ApiService>("apiservice")
.WithReference(identityServer);

builder.AddProject<Projects.IdentityServer>("identityserver");
var webFrontend = builder.AddProject<Projects.Aspire_Web>("webfrontend")
.WithReference(apiService)
.WithReference(identityServer)
.WithExternalHttpEndpoints();

identityServer.WithReference(webFrontend);

builder.Build().Run();
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.9.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.4.2" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.1.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="10.1.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.14.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.14.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.14.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.9.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.14.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.14.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.AccessTokenManagement.OpenIdConnect" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.0" />
<PackageReference Include="Duende.AccessTokenManagement.OpenIdConnect" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion IdentityServer/v7/Diagnostics/Aspire/Aspire.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Aspire.Web;
using Duende.AccessTokenManagement.OpenIdConnect;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;

Expand All @@ -15,7 +16,7 @@
.AddCookie()
.AddOpenIdConnect(opt =>
{
opt.Authority = "https://localhost:5001";
opt.Authority = builder.Configuration["services:identityserver:https:0"];
opt.ClientId = "web";
opt.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5014",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
14 changes: 9 additions & 5 deletions IdentityServer/v7/Diagnostics/Aspire/IdentityServer/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ public static class Config
new ApiScope("weather"),
];

public static IEnumerable<Client> Clients =>
public static IEnumerable<Client> GetClients(string? webUrl = "https://localhost:5014")
{
return
[
// interactive client using code flow + pkce
new Client
{
ClientId = "web",
ClientSecrets = { new Secret("49C1A7E1-0C79-4A89-A3D6-A37998FB86B0".Sha256()) },

AllowedGrantTypes = GrantTypes.Code,

RedirectUris = { "https://localhost:5014/signin-oidc" },
FrontChannelLogoutUri = "https://localhost:5014/signout-oidc",
PostLogoutRedirectUris = { "https://localhost:5014/signout-callback-oidc" },
RedirectUris = { $"{webUrl}/signin-oidc" },
FrontChannelLogoutUri = $"{webUrl}/signout-oidc",
PostLogoutRedirectUris = { $"{webUrl}/signout-callback-oidc" },

AllowOfflineAccess = true,
AllowedScopes = { "openid", "profile", "weather" },
Expand All @@ -38,4 +40,6 @@ public static class Config
AccessTokenLifetime = 70
},
];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde
// in-memory, code config
isBuilder.AddInMemoryIdentityResources(Config.IdentityResources);
isBuilder.AddInMemoryApiScopes(Config.ApiScopes);
isBuilder.AddInMemoryClients(Config.Clients);

var webUrl = builder.Configuration["services:webfrontend:https:0"];
isBuilder.AddInMemoryClients(Config.GetClients(webUrl));


// if you want to use server-side sessions: https://blog.duendesoftware.com/posts/20220406_session_management/
Expand Down Expand Up @@ -67,6 +69,8 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde

public static WebApplication ConfigurePipeline(this WebApplication app)
{
app.MapDefaultEndpoints();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer" Version="7.3.2"/>
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Duende.IdentityServer" Version="7.4.4" />
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.

using System.Buffers.Text;
using Duende.IdentityModel;
using Microsoft.AspNetCore.Authentication;
using System.Text;
Expand All @@ -18,7 +19,7 @@ public ViewModel(AuthenticateResult result)
{
if (encoded != null)
{
var bytes = Base64Url.Decode(encoded);
var bytes = Base64Url.DecodeFromChars(encoded);
var value = Encoding.UTF8.GetString(bytes);
Clients = JsonSerializer.Deserialize<string[]>(value) ?? Enumerable.Empty<string>();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"SelfHost": {
"commandName": "Project",
"launchBrowser": true,
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
Expand Down
Loading