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

Expand private key jwt test client with an ECDSA key #1528

Merged
merged 1 commit into from
Mar 12, 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
24 changes: 23 additions & 1 deletion clients/src/ConsolePrivateKeyJwtClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,20 @@ public class Program
"qi":"pG6J4dcUDrDndMxa-ee1yG4KjZqqyCQcmPAfqklI2LmnpRIjcK78scclvpboI3JQyg6RCEKVMwAhVtQM6cBcIO3JrHgqeYDblp5wXHjto70HVW6Z8kBruNx1AH9E8LzNvSRL-JVTFzBkJuNgzKQfD0G77tQRgJ-Ri7qu3_9o1M4"
}
""";


private static string ecKey =
"""
{
"kty":"EC",
"crv":"P-256",
"x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
"y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
"d":"870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE",
"use":"enc",
"kid":"1"
}
""";

public static async Task Main()
{
Console.Title = "Console Client Credentials Flow with JWT Assertion";
Expand All @@ -51,6 +64,15 @@ public static async Task Main()

Console.ReadLine();
await CallServiceAsync(response.AccessToken);

// EC JsonWebKey
jwk = new JsonWebKey(ecKey);
response = await RequestTokenAsync(new SigningCredentials(jwk, "ES256"));
response.Show();

Console.ReadLine();
await CallServiceAsync(response.AccessToken);

}

static async Task<TokenResponse> RequestTokenAsync(SigningCredentials credential)
Expand Down
15 changes: 15 additions & 0 deletions hosts/Config/ClientsConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ public static IEnumerable<Client> Get()
"n":"wWwQFtSzeRjjerpEM5Rmqz_DsNaZ9S1Bw6UbZkDLowuuTCjBWUax0vBMMxdy6XjEEK4Oq9lKMvx9JzjmeJf1knoqSNrox3Ka0rnxXpNAz6sATvme8p9mTXyp0cX4lF4U2J54xa2_S9NF5QWvpXvBeC4GAJx7QaSw4zrUkrc6XyaAiFnLhQEwKJCwUw4NOqIuYvYp_IXhw-5Ti_icDlZS-282PcccnBeOcX7vc21pozibIdmZJKqXNsL1Ibx5Nkx1F1jLnekJAmdaACDjYRLL_6n3W4wUp19UvzB1lGtXcJKLLkqB6YDiZNu16OSiSprfmrRXvYmvD8m6Fnl5aetgKw"
}
"""
},
new Secret
{
Type = IdentityServerConstants.SecretTypes.JsonWebKey,
Value =
"""
{
"kty":"EC",
"crv":"P-256",
"x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
"y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
"use":"enc",
"kid":"1"
}
"""
}
},
AllowedGrantTypes = GrantTypes.ClientCredentials,
Expand Down
Loading