You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Disable default account verification when Account.RegisterConfirmation has been scaffolded
1
+
### Disable default account verification when Account.RegisterConfirmation is scaffolded
3
2
4
-
This section only applies when `Account.RegisterConfirmation` is scaffolded. Skip this section if you have not scaffolded `Account.RegisterConfirmation`.
3
+
If `Account.RegisterConfirmation` is scaffolded, complete the instructions in this section.
5
4
6
-
The user is redirected to the `Account.RegisterConfirmation` where they can select a link to have the account confirmed. The default `Account.RegisterConfirmation` is used ***only*** for testing, automatic account verification should be disabled in a production app.
5
+
> [!IMPORTANT]
6
+
> If `Account.RegisterConfirmation` is **not** scaffolded, skip the following instructions and continue to the next section.
7
7
8
-
To require a confirmed account and prevent immediate login at registration, set `DisplayConfirmAccountLink = false` in the scaffolded `/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs` file:
8
+
The user is redirected to the `/Identity/Account/RegisterConfirmation` page where they can select a link to have the account confirmed. The default `Account.RegisterConfirmation` is used ***only*** for testing. Automatic account verification should be disabled in a production app.
9
+
10
+
To require a confirmed account and prevent immediate sign in at registration, set `DisplayConfirmAccountLink = false` in the scaffolded _/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs_ file:
This step is only necessary when `Account.RegisterConfirmation` is scaffolded. The non-scaffolded [RegisterConfirmation](https://github.com/dotnet/aspnetcore/blob/1dcf7acfacf0fe154adcc23270cb0da11ff44ace/src/Identity/UI/src/Areas/Identity/Pages/V4/Account/RegisterConfirmation.cshtml.cs#L74-L87) automatically detects when an [IEmailSender](https://github.com/dotnet/aspnetcore/blob/1dcf7acfacf0fe154adcc23270cb0da11ff44ace/src/Identity/UI/src/Areas/Identity/Services/EmailSender.cs) has been implemented and registered with the [dependency injection container](xref:fundamentals/dependency-injection).
14
+
This step is necessary only when `Account.RegisterConfirmation` is scaffolded.
15
+
16
+
The non-scaffolded [RegisterConfirmation](https://github.com/dotnet/aspnetcore/blob/1dcf7acfacf0fe154adcc23270cb0da11ff44ace/src/Identity/UI/src/Areas/Identity/Pages/V4/Account/RegisterConfirmation.cshtml.cs#L74-L87) automatically detects when an [IEmailSender](https://github.com/dotnet/aspnetcore/blob/1dcf7acfacf0fe154adcc23270cb0da11ff44ace/src/Identity/UI/src/Areas/Identity/Services/EmailSender.cs) is implemented and registered with the [dependency injection container](xref:fundamentals/dependency-injection).
> By default the architecture of the .NET binaries to install represents the currently running OS architecture. To specify a different OS architecture, see [dotnet tool install, --arch option](/dotnet/core/tools/dotnet-tool-install#options).
3
-
> For more information, see GitHub issue [dotnet/AspNetCore.Docs #29262](https://github.com/dotnet/AspNetCore.Docs/issues/29262).
2
+
> By default, the architecture of the .NET binaries to install represents the currently running operating system architecture.
3
+
> To specify a different architecture, review how to use the `dotnet tool install` command with the ['--arch' option](/dotnet/core/tools/dotnet-tool-install#options).
4
+
> For more information, see [GitHub dotnet/aspnetcore.docs issue #29262](https://github.com/dotnet/AspNetCore.Docs/issues/29262) - _Add '-a arm64' on Apple Silicon_.
description: Learn how to set up manage JSON Web Tokens in development with dotnet user-jwts
4
+
description: Learn how to generate and manage JSON Web Tokens in development with the dotnet user-jwts command.
5
5
monikerRange: '>= aspnetcore-7.0'
6
6
ms.author: tdykstra
7
-
ms.date: 09/22/2018
7
+
ms.date: 05/11/2026
8
8
ms.custom: mvc
9
9
uid: security/authentication/jwt
10
+
11
+
# customer intent: As an ASP.NET developer, I want to use the dotnet user-jwts command, so I can generate and manage JSON Web Tokens in development.
10
12
---
11
13
12
14
# Manage JSON Web Tokens in development with dotnet user-jwts
13
15
14
16
By [Rick Anderson](https://twitter.com/RickAndMSFT)
15
17
16
-
The `dotnet user-jwts` command line tool can create and manage app specific local [JSON Web Tokens](https://jwt.io/introduction) (JWTs).
18
+
The `dotnet user-jwts` command line tool can create and manage app specific local [JSON Web Tokens](https://www.jwt.io/introduction#what-is-json-web-token) (JWTs).
19
+
20
+
This article provides syntax details for the command and examples.
17
21
18
22
## Synopsis
19
23
@@ -30,9 +34,9 @@ Creates and manages project specific local JSON Web Tokens.
30
34
31
35
`PROJECT | SOLUTION`
32
36
33
-
The MSBuild project to apply a command on. If a project is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in *proj* and uses that file.
37
+
The MSBuild project to apply a command on. If a project isn't specified, MSBuild searches the current working directory for a file that has a file extension that ends in *proj*. It then uses that file to obtain the project information for the command.
34
38
35
-
<!--Once solutions are supported delete the preceding and uncomment this section
39
+
<!--When solutions are supported, delete the preceding and uncomment this section
36
40
37
41
```dotnetcli
38
42
dotnet user-jwts [<PROJECT>|<SOLUTION>] [command]
@@ -54,33 +58,33 @@ The MSBuild project or solution to apply a command on. If a project or solution
54
58
## Commands
55
59
56
60
| Command | Description |
57
-
| -------------|------------- |
58
-
| clear | Delete all issued JWTs for a project. |
59
-
| create | Issue a new JSON Web Token. |
60
-
| remove | Delete a given JWT. |
61
-
| key | Display or reset the signing key used to issue JWTs. |
62
-
| list| Lists the JWTs issued for the project. |
63
-
| print | Display the details of a given JWT. |
61
+
| -------- | ----------- |
62
+
|`clear`| Delete all issued JWTs for a project. |
63
+
|`create`| Issue a new JSON Web Token. |
64
+
|`remove`| Delete a given JWT. |
65
+
|`key`| Display or reset the signing key used to issue JWTs. |
66
+
|`list`| List the JWTs issued for the project. |
67
+
|`print`| Display the details of a given JWT. |
64
68
65
-
### Create
69
+
### Options for the create command
66
70
67
71
Usage: `dotnet user-jwts create [options]`
68
72
69
73
| Option | Description |
70
-
| -------------|------------- |
71
-
|-p \| --project | The path of the project to operate on. Defaults to the project in the current directory. |
72
-
| --scheme| The scheme name to use for the generated token. Defaults to 'Bearer'. |
73
-
| -n \| --name | The name of the user to create the JWT for. Defaults to the current environment user. |
74
-
| --audience| The audiences to create the JWT for. Defaults to the URLs configured in the project's launchSettings.json. |
75
-
| --issuer| The issuer of the JWT. Defaults to 'dotnet-user-jwts'. |
76
-
| --scope | A scope claim to add to the JWT. Specify once for each scope. |
77
-
| --role | A role claim to add to the JWT. Specify once for each role. |
78
-
| --claim| Claims to add to the JWT. Specify once for each claim in the format "name=value". |
79
-
| --not-before| The UTC date & time the JWT should not be valid before in the format 'yyyy-MM-dd [[HH:mm[[:ss]]]]'. Defaults to the date & time the JWT is created. |
80
-
| --expires-on| The UTC date & time the JWT should expire in the format 'yyyy-MM-dd [[[[HH:mm]]:ss]]'. Defaults to 6 months after the --not-before date. Do not use this option in conjunction with the --valid-for option. |
81
-
| --valid-for| The period the JWT should expire after. Specify using a number followed by duration type like 'd' for days, 'h' for hours, 'm' for minutes, and 's' for seconds, for example 365d'. Do not use this option in conjunction with the --expires-on option. |
82
-
| -o \| --output| The format to use for displaying output from the command. Can be one of 'default', 'token', or 'json'. |
83
-
| -h \| --help| Show help information |
74
+
| ------- | ----------- |
75
+
|`-p \| --project`| The path of the project to operate on. Defaults to the project in the current directory. |
76
+
|`--scheme`| The scheme name to use for the generated token. Defaults to `Bearer`. |
77
+
|`-n \| --name`| The name of the user to create the JWT for. Defaults to the current environment user. |
78
+
|`--audience`| The audiences to create the JWT for. Defaults to the URLs configured in the project's _launchSettings.json_ file. |
79
+
|`--issuer`| The issuer of the JWT. Defaults to `dotnet-user-jwts`. |
80
+
|`--scope`| A scope claim to add to the JWT. Specify once for each scope. |
81
+
|`--role`| A role claim to add to the JWT. Specify once for each role. |
82
+
|`--claim`| Claims to add to the JWT. Specify once for each claim in the format `name=value`. |
83
+
|`--not-before`| The UTC date and time at which the JWT becomes valid, in the format `yyyy-MM-dd [[HH:mm[[:ss]]]]`. Defaults to the date and time the JWT is created. |
84
+
|`--expires-on`| The UTC date and time at which the JWT expires, in the format `yyyy-MM-dd [[[ [HH:mm]]:ss]]`. Defaults to six months after the `--not-before` date. Don't use this option with the `--valid-for` option. |
85
+
|`--valid-for`| The amount of time the JWT remains valid. When the time is reached, the JWT expires. Specify a number followed by the duration type (`d`days, `h`hours, `m`minutes, `s`seconds), such as `365d`. Don't use this option with the `--expires-on` option. |
86
+
|`-o \| --output`| The format to use for displaying output from the command: `default`, `token`, or `json`. |
87
+
|`-h \| --help`| Show help information for the command.|
In the preceding code, a GET request to `/secret` returns an `401 Unauthorized` error. A production app might get the JWT from a [Security token service](/azure/active-directory/develop/security-tokens) (STS), perhaps in response to logging in via a set of credentials. For the purpose of working with the API during local development, the `dotnet user-jwts` command line tool can be used to create and manage app-specific local JWTs.
100
-
101
-
The `user-jwts` tool is similar in concept to the [user-secrets](xref:security/app-secrets) tool, it can be used to manage values for the app that are only valid for the developer on the local machine. In fact, the user-jwts tool utilizes the `user-secrets` infrastructure to manage the key that the JWTs are signed with, ensuring it’s stored safely in the user profile.
103
+
In the preceding code, a GET request to the `/secret` endpoint returns a `401 Unauthorized` error. A production app might get the JWT from a [Security token service](/entra/identity-platform/security-tokens), perhaps in response to signing in with credentials. When you use the API during local development, the `dotnet user-jwts` command line tool can be used to create and manage app-specific local JWTs.
102
104
103
-
The `user-jwts` tool hides implementation details, such as where and how the values are stored. The tool can be used without knowing the implementation details. The values are stored in a JSON file in the local machine's user profile folder:
105
+
The `user-jwts` tool is similar in concept to the [user-secrets](xref:security/app-secrets) tool. It can be used to manage values for the app that are valid only for the developer on the local machine. In fact, the `user-jwts`tool utilizes the `user-secrets` infrastructure to manage the key that the JWTs are signed with. This approach ensures the key is stored safely in the user profile.
104
106
105
-
# [Windows](#tab/windows)
107
+
The `user-jwts` tool hides implementation details, such as where and how the values are stored. The tool can be used without knowing the implementation details.
106
108
107
-
File system path:
109
+
The values are stored in a JSON file in the local machine's user profile folder:
Copy the JWT and the `ID` created in the preceding command. Use a tool like Curl to test `/secret`:
127
+
Copy the JWT and the `ID` created in the preceding command. Use a tool like Curl to test the `/secret` endpoint, where `{token}` is the previously generated JWT:
See [Create](#create) in this topic for supported create options.
150
-
151
-
The following command creates a JWT for a user named `MyTestUser`:
143
+
The following command creates a JWT for a user named `MyTestUser`. For the supported `create` options, see the [Options for the create command](#options-for-the-create-command) section.
Copy file name to clipboardExpand all lines: aspnetcore/security/authentication/scaffold-identity.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Although the scaffolder generates most of the necessary code, you need to update
36
36
37
37
We recommend using a source control system that shows file differences and allows you to back out of changes. Inspect the changes after running the Identity scaffolder.
38
38
39
-
Services are required when using [Two Factor Authentication](xref:security/authentication/identity-enable-qrcodes), [Account confirmation and password recovery](xref:security/authentication/accconfirm), and other security features with Identity. Services or service stubs aren't generated when scaffolding Identity. Services to enable these features must be added manually. For example, see [Require Email Confirmation](xref:security/authentication/accconfirm#require-email-confirmation).
39
+
Services are required when using [Two Factor Authentication](xref:security/authentication/identity-enable-qrcodes), [Account confirmation and password recovery](xref:security/authentication/accconfirm), and other security features with Identity. Services or service stubs aren't generated when scaffolding Identity. Services to enable these features must be added manually. For example, see [Configure an email provider](xref:security/authentication/accconfirm#configure-an-email-provider) so the app can require email confirmation.
40
40
41
41
Typically, apps created with individual accounts should ***not*** create a new data context.
0 commit comments