dotnet / dotnet/aspnetcore

JSON Web Key Sets (JWKS) for Blazor WebAssembly App with Individual Accounts and ASP.NET Core Hosted

Open
#46,474 10 comments 0 reactions 0 assignees View on GitHub
area-blazor bug feature-blazor-wasm
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I have a `Blazor WebAssembly App` created with `Microsoft Visual Studio` with these specifications: `Target Framework .NET 7.0`, `Authentication Type Individual Accounts` and `ASP.NET Core Hosted` (Duende IdentityServer):

If I start this project and visit https://localhost:1234/.well-known/openid-configuration/jwks I can see the following values:

```
{
"keys": [
{
"alg": "RS256",
"e": "AQAB",
"kid": "BAE012345",
"kty": "RSA",
"n": "1234567890abc...",
"use": "sig"
},
{
"alg": "RS256",
"e": "AQAB",
"kid": "Development",
"kty": "RSA",
"n": "1234567890abc...",
"use": "sig"
}
]
}
```

The `Development` key is probably generated via `appsettings.Development.json` and the following value:

```
"IdentityServer": {
"Key": {
"Type": "Development"
}
}
```

What is the extra key that I can see there and how is it generated?

If I then put this in production and use a cert instead I can see the following values:

```
{
"keys": [
{
"alg": "RS256",
"e": "AQAB",
"kid": "44A512345",
"kty": "RSA",
"n": "1234567890abc...",
"use": "sig"
},
{
"alg": "RS256",
"e": "AQAB",
"kid": "A60912345",
"kty": "RSA",
"n": "1234567890abc...",
"use": "sig"
},
{
"alg": "RS256",
"e": "AQAB",
"kid": "77C012345",
"kty": "RSA",
"n": "1234567890abc...",
"use": "sig",
"x5c": [
"1234567890abc..."
],
"x5t": "1234567890abc..."
}
]
}
```

Config:

```
"IdentityServer": {
"Key": {
"Type": "Store",
"StoreName": "My",
"StoreLocation": "CurrentUser",
"Name": "CN=blazortest123"
}
},
```

The last value is my certificate, 77C012345. The other two keys are not generated by me, What is their functionality and how can I disable them?

If I install Duende IdentityServer Templates like this:

`dotnet new --install Duende.IdentityServer.Templates`

https://docs.duendesoftware.com/identityserver/v5/quickstarts/0_overview/

Then create a new project with template: "Duende IdentityServer with ASP.NET Core Identity (Duende Software)". If I then start the project and visit the `jwks` endpoint I can see one key as expected.

https://localhost:5001/.well-known/openid-configuration/jwks

```
{
"keys": [
{
"alg": "RS256",
"e": "AQAB",
"kid": "5BFB12345",
"kty": "RSA",
"n": "1234567890abc...",
"use": "sig"
}
]
}
```

The key that I can see is located in the folder `keys` and named `is-signing-key-5BFB12345.json` with value:

```
{
"Algorithm": "RS256",
"Created": "2023-02-06T10:47:05.0718361Z",
"Data": "1234567890abc...",
"DataProtected": true,
"Id": "5BFB12345",
"IsX509Certificate": false,
"Version": 1
}
```

### Describe the solution you'd like

If there are extra keys generated, that are used to verify the signature of a signed JWT that the programmer by default has no control over, these should be removed immediately imao.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.