From f1262d49ebb5b071d1917d55612539ec7b63702b Mon Sep 17 00:00:00 2001 From: Joe DeCock Date: Mon, 22 Jan 2024 16:16:01 -0600 Subject: [PATCH] DCR\Permissions - Use IdentityModel 7.0 --- .../ConsoleDcrClient/ConsoleDcrClient.csproj | 2 +- .../Permissions/ConsoleDcrClient/Program.cs | 17 +++-------------- .../IdentityServer/IdentityServer.csproj | 2 +- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/IdentityServer/v7/Configuration/Permissions/ConsoleDcrClient/ConsoleDcrClient.csproj b/IdentityServer/v7/Configuration/Permissions/ConsoleDcrClient/ConsoleDcrClient.csproj index ffcf0104..83ab3e7d 100644 --- a/IdentityServer/v7/Configuration/Permissions/ConsoleDcrClient/ConsoleDcrClient.csproj +++ b/IdentityServer/v7/Configuration/Permissions/ConsoleDcrClient/ConsoleDcrClient.csproj @@ -7,7 +7,7 @@ - + diff --git a/IdentityServer/v7/Configuration/Permissions/ConsoleDcrClient/Program.cs b/IdentityServer/v7/Configuration/Permissions/ConsoleDcrClient/Program.cs index 7fc36fee..871d993d 100644 --- a/IdentityServer/v7/Configuration/Permissions/ConsoleDcrClient/Program.cs +++ b/IdentityServer/v7/Configuration/Permissions/ConsoleDcrClient/Program.cs @@ -49,19 +49,6 @@ static async Task RegisterClient(string acces var client = new HttpClient(); client.SetBearerToken(accessToken); - // var request = new DynamicClientRegistrationRequest - // { - // Address = "https://localhost:5001/connect/dcr", - // Document = JsonSerializer.Deserialize( - // """ - // { - // "grant_types": [ "client_credentials" ], - // "scope": "SimpleApi", - // "client_secret": "hunter2" - // } - // """) - // }; - var request = new DynamicClientRegistrationRequest { Address = "https://localhost:5002/connect/dcr", @@ -73,7 +60,7 @@ static async Task RegisterClient(string acces } }; - request.Document.Extensions.Add("client_secret", "hunter2"); + request.Document.Extensions.Add("client_secret", AsJsonElement("hunter2")); var response = await client.RegisterClientAsync(request); @@ -123,3 +110,5 @@ static async Task CallServiceAsync(string token) "\n\nService claims:".ConsoleGreen(); Console.WriteLine(response.PrettyPrintJson()); } + +static JsonElement AsJsonElement(string s) => JsonDocument.Parse($"\"{s}\"").RootElement; \ No newline at end of file diff --git a/IdentityServer/v7/Configuration/Permissions/IdentityServer/IdentityServer.csproj b/IdentityServer/v7/Configuration/Permissions/IdentityServer/IdentityServer.csproj index 4200c589..3f7d5a5a 100644 --- a/IdentityServer/v7/Configuration/Permissions/IdentityServer/IdentityServer.csproj +++ b/IdentityServer/v7/Configuration/Permissions/IdentityServer/IdentityServer.csproj @@ -7,7 +7,7 @@ - +