Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all Configuration API (DCR) samples to .NET 8 #167

Merged
merged 1 commit into from
Jan 23, 2024
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
19 changes: 15 additions & 4 deletions IdentityServer/v7/Configuration/Permissions/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
{
"version": "0.2.0",
"compounds": [
{
"name": "Run all",
"configurations": ["Identity Server", "Configuration", "API", "ConsoleDcrClient"],
"presentation": {
"hidden": false,
"group": "10-compounds",
"order": 1
}
}
],
"configurations": [
{
"name": "Identity Server",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-identity-server",
"program": "${workspaceFolder}/IdentityServer/bin/Debug/net6.0/IdentityServer.dll",
"program": "${workspaceFolder}/IdentityServer/bin/Debug/net8.0/IdentityServer.dll",
"args": [],
"cwd": "${workspaceFolder}/IdentityServer",
"serverReadyAction": {
Expand All @@ -23,7 +34,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-api",
"program": "${workspaceFolder}/SimpleApi/bin/Debug/net6.0/SimpleApi.dll",
"program": "${workspaceFolder}/SimpleApi/bin/Debug/net8.0/SimpleApi.dll",
"args": [],
"cwd": "${workspaceFolder}/SimpleApi",
"env": {
Expand All @@ -36,7 +47,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-configuration",
"program": "${workspaceFolder}/Configuration/bin/Debug/net6.0/Configuration.dll",
"program": "${workspaceFolder}/Configuration/bin/Debug/net8.0/Configuration.dll",
"args": [],
"cwd": "${workspaceFolder}/Configuration",
"env": {
Expand All @@ -49,7 +60,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-console-dcr-client",
"program": "${workspaceFolder}/ConsoleDcrClient/bin/Debug/net6.0/ConsoleDcrClient.dll",
"program": "${workspaceFolder}/ConsoleDcrClient/bin/Debug/net8.0/ConsoleDcrClient.dll",
"args": [],
"cwd": "${workspaceFolder}/ConsoleDcrClient",
"console": "externalTerminal",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer.Configuration" Version="6.3.3" />
<PackageReference Include="Duende.IdentityServer.Configuration.EntityFramework" Version="6.3.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.16" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.16" />
<PackageReference Include="Duende.IdentityServer.Configuration" Version="7.0.0-rc.2" />
<PackageReference Include="Duende.IdentityServer.Configuration.EntityFramework" Version="7.0.0-rc.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System;
using System.Net.Http;
using System.Reflection.Metadata;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using ConsoleDcrClient;
using IdentityModel.Client;


Console.Title = "Dynamic Client Registration - Client Credentials Flow";
Console.Title = "DCR Client";

"Obtaining initial access token (which does not allow setting client ids)".ConsoleYellow();
"Obtaining initial access token (which does not allow setting client secrets)".ConsoleYellow();
var badTokenResponse = await RequestTokenAsync(scope: "IdentityServer.Configuration");
badTokenResponse.Show();
Console.ReadLine();
Expand All @@ -24,7 +25,7 @@
badDynamicClientToken.Show();
Console.ReadLine();

"Obtaining a new access token (which does allow setting client ids)".ConsoleYellow();
"Obtaining a new access token (which does allow setting client secret)".ConsoleYellow();
var goodTokenResponse = await RequestTokenAsync(scope: "IdentityServer.Configuration IdentityServer.Configuration:SetClientSecret");
goodTokenResponse.Show();
Console.ReadLine();
Expand All @@ -48,6 +49,19 @@ static async Task<DynamicClientRegistrationResponse> RegisterClient(string acces
var client = new HttpClient();
client.SetBearerToken(accessToken);

// var request = new DynamicClientRegistrationRequest
// {
// Address = "https://localhost:5001/connect/dcr",
// Document = JsonSerializer.Deserialize<DynamicClientRegistrationDocument>(
// """
// {
// "grant_types": [ "client_credentials" ],
// "scope": "SimpleApi",
// "client_secret": "hunter2"
// }
// """)
// };

var request = new DynamicClientRegistrationRequest
{
Address = "https://localhost:5002/connect/dcr",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer.EntityFramework" Version="6.3.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="6.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0" />
<PackageReference Include="Duende.IdentityServer.EntityFramework" Version="7.0.0-rc.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ CREATE TABLE "Clients" (
"Created" TEXT NOT NULL,
"Updated" TEXT NULL,
"LastAccessed" TEXT NULL,
"NonEditable" INTEGER NOT NULL
"NonEditable" INTEGER NOT NULL,
"PushedAuthorizationLifetime" INTEGER NULL,
"RequirePushedAuthorization" INTEGER NOT NULL
);

CREATE TABLE "IdentityProviders" (
Expand Down Expand Up @@ -293,7 +295,7 @@ CREATE UNIQUE INDEX "IX_IdentityResourceProperties_IdentityResourceId_Key" ON "I
CREATE UNIQUE INDEX "IX_IdentityResources_Name" ON "IdentityResources" ("Name");

INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20230509053624_Configuration', '6.0.0');
VALUES ('20240120040116_Configuration', '8.0.1');

COMMIT;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

namespace IdentityServer.Migrations.ConfigurationDb
{
/// <inheritdoc />
public partial class Configuration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
Expand Down Expand Up @@ -110,7 +112,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
Created = table.Column<DateTime>(type: "TEXT", nullable: false),
Updated = table.Column<DateTime>(type: "TEXT", nullable: true),
LastAccessed = table.Column<DateTime>(type: "TEXT", nullable: true),
NonEditable = table.Column<bool>(type: "INTEGER", nullable: false)
NonEditable = table.Column<bool>(type: "INTEGER", nullable: false),
PushedAuthorizationLifetime = table.Column<int>(type: "INTEGER", nullable: true),
RequirePushedAuthorization = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
Expand Down Expand Up @@ -644,6 +648,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
unique: true);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ partial class ConfigurationDbContextModelSnapshot : ModelSnapshot
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.0");
modelBuilder.HasAnnotation("ProductVersion", "8.0.1");

modelBuilder.Entity("Duende.IdentityServer.EntityFramework.Entities.ApiResource", b =>
{
Expand Down Expand Up @@ -410,6 +410,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(200)
.HasColumnType("TEXT");

b.Property<int?>("PushedAuthorizationLifetime")
.HasColumnType("INTEGER");

b.Property<int>("RefreshTokenExpiration")
.HasColumnType("INTEGER");

Expand All @@ -428,6 +431,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool>("RequirePkce")
.HasColumnType("INTEGER");

b.Property<bool>("RequirePushedAuthorization")
.HasColumnType("INTEGER");

b.Property<bool>("RequireRequestObject")
.HasColumnType("INTEGER");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ CREATE TABLE "PersistedGrants" (
"Data" TEXT NOT NULL
);

CREATE TABLE "PushedAuthorizationRequests" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_PushedAuthorizationRequests" PRIMARY KEY AUTOINCREMENT,
"ReferenceValueHash" TEXT NOT NULL,
"ExpiresAtUtc" TEXT NOT NULL,
"Parameters" TEXT NOT NULL
);

CREATE TABLE "ServerSideSessions" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_ServerSideSessions" PRIMARY KEY AUTOINCREMENT,
"Key" TEXT NOT NULL,
Expand Down Expand Up @@ -71,6 +78,10 @@ CREATE INDEX "IX_PersistedGrants_SubjectId_ClientId_Type" ON "PersistedGrants" (

CREATE INDEX "IX_PersistedGrants_SubjectId_SessionId_Type" ON "PersistedGrants" ("SubjectId", "SessionId", "Type");

CREATE INDEX "IX_PushedAuthorizationRequests_ExpiresAtUtc" ON "PushedAuthorizationRequests" ("ExpiresAtUtc");

CREATE UNIQUE INDEX "IX_PushedAuthorizationRequests_ReferenceValueHash" ON "PushedAuthorizationRequests" ("ReferenceValueHash");

CREATE INDEX "IX_ServerSideSessions_DisplayName" ON "ServerSideSessions" ("DisplayName");

CREATE INDEX "IX_ServerSideSessions_Expires" ON "ServerSideSessions" ("Expires");
Expand All @@ -82,7 +93,7 @@ CREATE INDEX "IX_ServerSideSessions_SessionId" ON "ServerSideSessions" ("Session
CREATE INDEX "IX_ServerSideSessions_SubjectId" ON "ServerSideSessions" ("SubjectId");

INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20230509053621_Grants', '6.0.0');
VALUES ('20240120040109_Grants', '8.0.1');

COMMIT;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading