@chill-sharp/ui-core 1.1.12 → 1.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -103
- package/fesm2022/chill-sharp-ui-core.mjs +2446 -2446
- package/fesm2022/chill-sharp-ui-core.mjs.map +1 -1
- package/lib/lib/chill-form.component.d.ts +1 -1
- package/package.json +3 -3
- package/service-worker/chill-sharp-service-worker.js +166 -166
- package/styles/core-theme.scss +1235 -1235
- package/.agents/skills/chillsharp-current-user-preferences/SKILL.md +0 -70
- package/.agents/skills/chillsharp-ui-template/SKILL.md +0 -18
- package/doc/AIAssistedDevelopment/README.md +0 -185
- package/doc/AttachmentModel/README.md +0 -173
- package/doc/AuthenticationModel/README.md +0 -213
- package/doc/AuthenticationModel/how-to-integreate-auth-minimal-api.md +0 -293
- package/doc/ChillSharpClient.md +0 -464
- package/doc/ClientGeneration/README.md +0 -172
- package/doc/ComplianceGuide/README.md +0 -178
- package/doc/Configuration/README.md +0 -94
- package/doc/CurrentUserPreferences.md +0 -114
- package/doc/DateTimePolicy/README.md +0 -154
- package/doc/DateTimeSerialization.md +0 -423
- package/doc/Endpoints.md +0 -260
- package/doc/HowTo/01-simple-blog-sqlite.md +0 -153
- package/doc/HowTo/02-blog-schema-labels.md +0 -140
- package/doc/HowTo/03-authentication.md +0 -218
- package/doc/HowTo/04-blog-posts-one-to-many.md +0 -194
- package/doc/HowTo/05-docker-env-variables.md +0 -274
- package/doc/HowTo/06-chunk-transactions-autocomplete.md +0 -196
- package/doc/Mcp/ChatGPT.md +0 -291
- package/doc/Mcp/README.md +0 -799
- package/doc/MenuGuide/README.md +0 -49
- package/doc/ModelPreparation.md +0 -255
- package/doc/PermissionModel/README.md +0 -277
- package/doc/README.md +0 -228
- package/doc/ReferenceExistence.md +0 -130
- package/doc/RegisterContext.md +0 -217
- package/doc/UiCore/CRUD.md +0 -170
- package/doc/UiCore/README.md +0 -13
- package/doc/ValidationModel/README.md +0 -117
- package/doc/it/AIAssistedDevelopment/README.md +0 -185
- package/doc/it/AttachmentModel/README.md +0 -173
- package/doc/it/AuthenticationModel/README.md +0 -171
- package/doc/it/AuthenticationModel/how-to-integreate-auth-minimal-api.md +0 -292
- package/doc/it/ChillSharpClient.md +0 -464
- package/doc/it/ClientGeneration/README.md +0 -152
- package/doc/it/ComplianceGuide/README.md +0 -178
- package/doc/it/Configuration/README.md +0 -94
- package/doc/it/CurrentUserPreferences.md +0 -114
- package/doc/it/DateTimePolicy/README.md +0 -154
- package/doc/it/DateTimeSerialization.md +0 -423
- package/doc/it/Endpoints.md +0 -260
- package/doc/it/HowTo/01-simple-blog-sqlite.md +0 -152
- package/doc/it/HowTo/02-blog-schema-labels.md +0 -139
- package/doc/it/HowTo/03-authentication.md +0 -221
- package/doc/it/HowTo/04-blog-posts-one-to-many.md +0 -193
- package/doc/it/HowTo/05-docker-env-variables.md +0 -268
- package/doc/it/HowTo/06-chunk-transactions-autocomplete.md +0 -196
- package/doc/it/Mcp/ChatGPT.md +0 -291
- package/doc/it/Mcp/README.md +0 -799
- package/doc/it/MenuGuide/README.md +0 -49
- package/doc/it/ModelPreparation.md +0 -254
- package/doc/it/PermissionModel/README.md +0 -190
- package/doc/it/README.md +0 -172
- package/doc/it/ReferenceExistence.md +0 -130
- package/doc/it/RegisterContext.md +0 -218
- package/doc/it/UiCore/CRUD.md +0 -170
- package/doc/it/UiCore/README.md +0 -13
- package/doc/it/ValidationModel/README.md +0 -117
- package/template-customization/upgrade.ps1.template +0 -342
- package/template-customization/upgrade.sh.template +0 -271
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
# Autenticazione E Autorizzazione ChillSharp
|
|
2
|
-
|
|
3
|
-
Versione originale in inglese: [English](../../AuthenticationModel/README.md)
|
|
4
|
-
|
|
5
|
-
Questo documento copre il modulo auth a livello di riferimento. Per una configurazione guidata, continua a usare [doc/HowTo/03-authentication.md](../HowTo/03-authentication.md).
|
|
6
|
-
|
|
7
|
-
## Separazione Del Modulo
|
|
8
|
-
|
|
9
|
-
`ChillSharp.Auth` espone due aree correlate ma distinte:
|
|
10
|
-
|
|
11
|
-
- autenticazione account
|
|
12
|
-
Flussi di register, login, refresh, cambio password e reset password basati su ASP.NET Core Identity
|
|
13
|
-
|
|
14
|
-
- gestione autorizzazione
|
|
15
|
-
utenti auth, ruoli, assegnazioni ruolo, regole di permesso e valutazione dei permessi
|
|
16
|
-
|
|
17
|
-
## Endpoint Account
|
|
18
|
-
|
|
19
|
-
Registrati tramite:
|
|
20
|
-
|
|
21
|
-
```csharp
|
|
22
|
-
builder.Services.AddChillAuthIdentityApi<AppDbContext, IdentityUser>();
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Route tipiche:
|
|
26
|
-
|
|
27
|
-
- `/api/chill-auth/account/register`
|
|
28
|
-
- `/api/chill-auth/account/login`
|
|
29
|
-
- `/api/chill-auth/account/refresh`
|
|
30
|
-
- `/api/chill-auth/account/change-password`
|
|
31
|
-
- `/api/chill-auth/account/request-password-reset`
|
|
32
|
-
- `/api/chill-auth/account/reset-password`
|
|
33
|
-
|
|
34
|
-
Queste sono le route usate internamente da `ChillSharpClient`.
|
|
35
|
-
|
|
36
|
-
`RegisterAuthIdentityRequest` supporta anche:
|
|
37
|
-
|
|
38
|
-
- `DisplayName`
|
|
39
|
-
- `DisplayCultureName`
|
|
40
|
-
- `CreateChillAuthUser`
|
|
41
|
-
|
|
42
|
-
Quando `CreateChillAuthUser` e abilitato e viene fornito `DisplayCultureName`, il relativo `AuthUser` viene preimpostato automaticamente con:
|
|
43
|
-
|
|
44
|
-
- `DisplayCultureName`
|
|
45
|
-
- `DisplayTimeZone`
|
|
46
|
-
- `DisplayDateFormat`
|
|
47
|
-
- `DisplayNumberFormat`
|
|
48
|
-
|
|
49
|
-
Il server ricava questi valori dalla cultura selezionata usando una mappatura best effort del fuso orario piu i separatori di data e numeri della cultura.
|
|
50
|
-
|
|
51
|
-
## Endpoint Di Gestione Autorizzazione
|
|
52
|
-
|
|
53
|
-
Registrati tramite:
|
|
54
|
-
|
|
55
|
-
```csharp
|
|
56
|
-
builder.Services.AddChillAuthApi<AppDbContext>();
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Gruppi di route tipici:
|
|
60
|
-
|
|
61
|
-
- `/api/chill-auth/users`
|
|
62
|
-
- `/api/chill-auth/roles`
|
|
63
|
-
- `/api/chill-auth/permissions`
|
|
64
|
-
|
|
65
|
-
Questi endpoint gestiscono:
|
|
66
|
-
|
|
67
|
-
- `AuthUser`
|
|
68
|
-
- `AuthRole`
|
|
69
|
-
- `AuthUserRole`
|
|
70
|
-
- `AuthPermissionRule`
|
|
71
|
-
- risultati di valutazione dei permessi
|
|
72
|
-
|
|
73
|
-
`AuthUser` ora include anche preferenze di visualizzazione opzionali per la UI:
|
|
74
|
-
|
|
75
|
-
- `DisplayCultureName`
|
|
76
|
-
- `DisplayTimeZone`
|
|
77
|
-
- `DisplayDateFormat`
|
|
78
|
-
- `DisplayNumberFormat`
|
|
79
|
-
|
|
80
|
-
## Requisiti Del Contesto
|
|
81
|
-
|
|
82
|
-
Il contesto host deve:
|
|
83
|
-
|
|
84
|
-
- implementare `IChillAuthDbContext`
|
|
85
|
-
- includere `modelBuilder.AddChillAuthModel()`
|
|
86
|
-
|
|
87
|
-
Per account basati su Identity, il contesto deve anche essere uno store EF valido per ASP.NET Core Identity, tipicamente:
|
|
88
|
-
|
|
89
|
-
```csharp
|
|
90
|
-
public class AppDbContext : IdentityDbContext<IdentityUser>, IChillContext, IChillAuthDbContext
|
|
91
|
-
{
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Bootstrap Dell'Utente Root
|
|
96
|
-
|
|
97
|
-
`AddChillAuthIdentityApi(...)` puo inizializzare un account root all'avvio.
|
|
98
|
-
|
|
99
|
-
Configurazioni supportate:
|
|
100
|
-
|
|
101
|
-
- opzioni dirette nel codice
|
|
102
|
-
- variabili d'ambiente
|
|
103
|
-
|
|
104
|
-
Variabili d'ambiente predefinite:
|
|
105
|
-
|
|
106
|
-
- `CHILLSHARP_AUTH_ROOT_USERNAME`
|
|
107
|
-
- `CHILLSHARP_AUTH_ROOT_PASSWORD`
|
|
108
|
-
- `CHILLSHARP_AUTH_ROOT_EMAIL`
|
|
109
|
-
- `CHILLSHARP_AUTH_ROOT_DISPLAY_NAME`
|
|
110
|
-
|
|
111
|
-
Quando abilitato, il flusso di bootstrap puo creare anche il collegato `AuthUser` ChillSharp con accesso alla gestione permessi.
|
|
112
|
-
|
|
113
|
-
## Accesso Alla Gestione Permessi
|
|
114
|
-
|
|
115
|
-
Essere autenticati non basta per gestire il modulo auth.
|
|
116
|
-
|
|
117
|
-
Gli endpoint di gestione auth richiedono un utente auth ChillSharp con diritti di gestione permessi, tipicamente:
|
|
118
|
-
|
|
119
|
-
- `CanManagePermissions = true`
|
|
120
|
-
|
|
121
|
-
Questo e il problema critico di bootstrap in un database pulito:
|
|
122
|
-
|
|
123
|
-
- il primo utente Identity registrato puo esistere
|
|
124
|
-
- il relativo `AuthUser` puo esistere
|
|
125
|
-
- ma nessuno puo ancora avere i diritti per gestire ruoli e permessi
|
|
126
|
-
|
|
127
|
-
Per questo il bootstrap root o un altro percorso di setup trusted e importante.
|
|
128
|
-
|
|
129
|
-
## Uso Del Client
|
|
130
|
-
|
|
131
|
-
Usa il normale Chill base URL:
|
|
132
|
-
|
|
133
|
-
```csharp
|
|
134
|
-
var client = new ChillSharpClient("http://localhost:5000/api/chill");
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
`ChillSharpClient` passa automaticamente a `/api/chill-auth/...` per i metodi auth.
|
|
138
|
-
|
|
139
|
-
Esempi:
|
|
140
|
-
|
|
141
|
-
- `RegisterAuthAccount`
|
|
142
|
-
- `LoginAuthAccount`
|
|
143
|
-
- `RefreshAuthAccount`
|
|
144
|
-
- `ChangeAuthPassword`
|
|
145
|
-
- `CreateAuthRole`
|
|
146
|
-
- `CreateAuthPermissionRule`
|
|
147
|
-
- `EvaluateAuthEntityPermission`
|
|
148
|
-
|
|
149
|
-
I payload di lista utente e dettaglio utente espongono anche:
|
|
150
|
-
|
|
151
|
-
- `DisplayCultureName`
|
|
152
|
-
- `DisplayTimeZone`
|
|
153
|
-
- `DisplayDateFormat`
|
|
154
|
-
- `DisplayNumberFormat`
|
|
155
|
-
|
|
156
|
-
## Gestione Dei Token
|
|
157
|
-
|
|
158
|
-
`ChillSharpClient` conserva:
|
|
159
|
-
|
|
160
|
-
- access token
|
|
161
|
-
- refresh token
|
|
162
|
-
|
|
163
|
-
Se e presente un refresh token, il client puo rinnovare automaticamente l'access token durante chiamate autenticate successive.
|
|
164
|
-
|
|
165
|
-
## Relazione Con Il Modello Permessi
|
|
166
|
-
|
|
167
|
-
Le regole esatte di risoluzione permessi sono documentate separatamente in:
|
|
168
|
-
|
|
169
|
-
- [PermissionModel/README.md](../PermissionModel/README.md)
|
|
170
|
-
|
|
171
|
-
Usa quel documento per il modello di precedenza e scope. Usa questo per registrazione e flusso auth runtime.
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
Versione originale in inglese: [English](../../AuthenticationModel/how-to-integreate-auth-minimal-api.md)
|
|
2
|
-
|
|
3
|
-
Certo. Qui trovi la versione aggiornata, corretta e moderna della configurazione con **Microsoft.IdentityModel.JsonWebTokens**, perche Microsoft ha deciso che la vecchia libreria JWT dovesse diventare "legacy".
|
|
4
|
-
|
|
5
|
-
Questo e il modo pulito per avere:
|
|
6
|
-
|
|
7
|
-
✅ store utenti Identity
|
|
8
|
-
✅ login/register Minimal API
|
|
9
|
-
✅ token JWT Bearer
|
|
10
|
-
✅ niente cookie
|
|
11
|
-
✅ niente UI
|
|
12
|
-
✅ niente `JwtSecurityTokenHandler` obsoleto
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
# ✅ Minimal Identity API ASP.NET Core + JWT (JsonWebTokenHandler moderno)
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
# ✅ 1. Installare I Pacchetti
|
|
21
|
-
|
|
22
|
-
Esegui:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|
26
|
-
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer
|
|
27
|
-
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
|
|
28
|
-
dotnet add package Microsoft.IdentityModel.JsonWebTokens
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Niente `System.IdentityModel.Tokens.Jwt`.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
# ✅ 2. Creare L'Identity DbContext
|
|
36
|
-
|
|
37
|
-
```csharp
|
|
38
|
-
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
39
|
-
using Microsoft.EntityFrameworkCore;
|
|
40
|
-
|
|
41
|
-
public class AppDbContext : IdentityDbContext
|
|
42
|
-
{
|
|
43
|
-
public AppDbContext(DbContextOptions<AppDbContext> options)
|
|
44
|
-
: base(options) { }
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
# ✅ 3. Configurare Database + IdentityCore
|
|
51
|
-
|
|
52
|
-
In `Program.cs`:
|
|
53
|
-
|
|
54
|
-
```csharp
|
|
55
|
-
builder.Services.AddDbContext<AppDbContext>(options =>
|
|
56
|
-
options.UseSqlServer(builder.Configuration.GetConnectionString("Default")));
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Poi aggiungi Identity:
|
|
60
|
-
|
|
61
|
-
```csharp
|
|
62
|
-
builder.Services.AddIdentityCore<IdentityUser>()
|
|
63
|
-
.AddEntityFrameworkStores<AppDbContext>()
|
|
64
|
-
.AddDefaultTokenProviders();
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
✅ Niente UI
|
|
68
|
-
✅ Niente Razor
|
|
69
|
-
✅ Niente circo dei cookie
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
# ✅ 4. Configurare L'Autenticazione JWT (Bearer)
|
|
74
|
-
|
|
75
|
-
Aggiungi gli import:
|
|
76
|
-
|
|
77
|
-
```csharp
|
|
78
|
-
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
79
|
-
using Microsoft.IdentityModel.Tokens;
|
|
80
|
-
using System.Text;
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Poi:
|
|
84
|
-
|
|
85
|
-
```csharp
|
|
86
|
-
var jwtKey = builder.Configuration["Jwt:Key"]!;
|
|
87
|
-
var jwtIssuer = builder.Configuration["Jwt:Issuer"]!;
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Ora configura:
|
|
91
|
-
|
|
92
|
-
```csharp
|
|
93
|
-
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
94
|
-
.AddJwtBearer(options =>
|
|
95
|
-
{
|
|
96
|
-
options.TokenValidationParameters = new TokenValidationParameters
|
|
97
|
-
{
|
|
98
|
-
ValidateIssuer = true,
|
|
99
|
-
ValidIssuer = jwtIssuer,
|
|
100
|
-
|
|
101
|
-
ValidateAudience = false,
|
|
102
|
-
|
|
103
|
-
ValidateIssuerSigningKey = true,
|
|
104
|
-
IssuerSigningKey = new SymmetricSecurityKey(
|
|
105
|
-
Encoding.UTF8.GetBytes(jwtKey)),
|
|
106
|
-
|
|
107
|
-
ValidateLifetime = true
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
---
|
|
113
|
-
|
|
114
|
-
# ✅ 5. Abilitare L'Autorizzazione
|
|
115
|
-
|
|
116
|
-
```csharp
|
|
117
|
-
builder.Services.AddAuthorization();
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
# ✅ 6. Aggiungere Il Middleware
|
|
123
|
-
|
|
124
|
-
Dopo `var app = builder.Build();`
|
|
125
|
-
|
|
126
|
-
```csharp
|
|
127
|
-
app.UseAuthentication();
|
|
128
|
-
app.UseAuthorization();
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Se salti questo passaggio, non funziona niente.
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
# ✅ 7. Generare Un Token JWT (JsonWebTokenHandler moderno)
|
|
136
|
-
|
|
137
|
-
Aggiungi gli import:
|
|
138
|
-
|
|
139
|
-
```csharp
|
|
140
|
-
using Microsoft.IdentityModel.JsonWebTokens;
|
|
141
|
-
using System.Security.Claims;
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Poi definisci:
|
|
145
|
-
|
|
146
|
-
```csharp
|
|
147
|
-
string GenerateJwtToken(IdentityUser user)
|
|
148
|
-
{
|
|
149
|
-
var claims = new List<Claim>
|
|
150
|
-
{
|
|
151
|
-
new Claim(JwtRegisteredClaimNames.Sub, user.Id),
|
|
152
|
-
new Claim(JwtRegisteredClaimNames.Email, user.Email!)
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
var key = new SymmetricSecurityKey(
|
|
156
|
-
Encoding.UTF8.GetBytes(jwtKey));
|
|
157
|
-
|
|
158
|
-
var creds = new SigningCredentials(
|
|
159
|
-
key,
|
|
160
|
-
SecurityAlgorithms.HmacSha256);
|
|
161
|
-
|
|
162
|
-
var tokenDescriptor = new SecurityTokenDescriptor
|
|
163
|
-
{
|
|
164
|
-
Subject = new ClaimsIdentity(claims),
|
|
165
|
-
Expires = DateTime.UtcNow.AddHours(2),
|
|
166
|
-
Issuer = jwtIssuer,
|
|
167
|
-
SigningCredentials = creds
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
var handler = new JsonWebTokenHandler();
|
|
171
|
-
|
|
172
|
-
return handler.CreateToken(tokenDescriptor);
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
✅ Questo sostituisce il vecchio `JwtSecurityTokenHandler`.
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
# ✅ 8. Endpoint Di Registrazione (Minimal API)
|
|
181
|
-
|
|
182
|
-
```csharp
|
|
183
|
-
app.MapPost("/register", async (
|
|
184
|
-
UserManager<IdentityUser> userManager,
|
|
185
|
-
RegisterRequest request) =>
|
|
186
|
-
{
|
|
187
|
-
var user = new IdentityUser
|
|
188
|
-
{
|
|
189
|
-
UserName = request.Email,
|
|
190
|
-
Email = request.Email
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
var result = await userManager.CreateAsync(user, request.Password);
|
|
194
|
-
|
|
195
|
-
if (!result.Succeeded)
|
|
196
|
-
return Results.BadRequest(result.Errors);
|
|
197
|
-
|
|
198
|
-
return Results.Ok("User registered");
|
|
199
|
-
});
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
# ✅ 9. Endpoint Di Login (ritorna JWT)
|
|
205
|
-
|
|
206
|
-
```csharp
|
|
207
|
-
app.MapPost("/login", async (
|
|
208
|
-
UserManager<IdentityUser> userManager,
|
|
209
|
-
LoginRequest request) =>
|
|
210
|
-
{
|
|
211
|
-
var user = await userManager.FindByEmailAsync(request.Email);
|
|
212
|
-
|
|
213
|
-
if (user == null)
|
|
214
|
-
return Results.Unauthorized();
|
|
215
|
-
|
|
216
|
-
var valid = await userManager.CheckPasswordAsync(user, request.Password);
|
|
217
|
-
|
|
218
|
-
if (!valid)
|
|
219
|
-
return Results.Unauthorized();
|
|
220
|
-
|
|
221
|
-
var token = GenerateJwtToken(user);
|
|
222
|
-
|
|
223
|
-
return Results.Ok(new { token });
|
|
224
|
-
});
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
# ✅ 10. Proteggere Un Endpoint
|
|
230
|
-
|
|
231
|
-
```csharp
|
|
232
|
-
app.MapGet("/me", (ClaimsPrincipal user) =>
|
|
233
|
-
{
|
|
234
|
-
var email = user.FindFirst(ClaimTypes.Email)?.Value;
|
|
235
|
-
|
|
236
|
-
return Results.Ok(new { email });
|
|
237
|
-
})
|
|
238
|
-
.RequireAuthorization();
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
---
|
|
242
|
-
|
|
243
|
-
# ✅ 11. Aggiungere I Modelli Request
|
|
244
|
-
|
|
245
|
-
```csharp
|
|
246
|
-
public record RegisterRequest(string Email, string Password);
|
|
247
|
-
|
|
248
|
-
public record LoginRequest(string Email, string Password);
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
---
|
|
252
|
-
|
|
253
|
-
# ✅ 12. Configurare `appsettings.json`
|
|
254
|
-
|
|
255
|
-
```json
|
|
256
|
-
"Jwt": {
|
|
257
|
-
"Key": "REPLACE_WITH_A_REAL_SECRET_32+_CHARS",
|
|
258
|
-
"Issuer": "MyApiAuthServer"
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
Usa una chiave lunga e casuale.
|
|
263
|
-
|
|
264
|
-
---
|
|
265
|
-
|
|
266
|
-
# ✅ Risultato
|
|
267
|
-
|
|
268
|
-
Ora hai:
|
|
269
|
-
|
|
270
|
-
✅ `/register`
|
|
271
|
-
✅ `/login` -> ritorna JWT
|
|
272
|
-
✅ endpoint protetti con Bearer token
|
|
273
|
-
✅ store utenti Identity in SQL
|
|
274
|
-
✅ niente cookie
|
|
275
|
-
✅ niente UI
|
|
276
|
-
✅ niente handler JWT legacy
|
|
277
|
-
|
|
278
|
-
---
|
|
279
|
-
|
|
280
|
-
# Se Vuoi Gli Step Successivi
|
|
281
|
-
|
|
282
|
-
Quando vorrai:
|
|
283
|
-
|
|
284
|
-
* refresh token
|
|
285
|
-
* ruoli + claim
|
|
286
|
-
* endpoint per reset password
|
|
287
|
-
* conferma email
|
|
288
|
-
* `/logout` con invalidazione JWT
|
|
289
|
-
|
|
290
|
-
allora l'autenticazione diventa un sistema vero, non una demo.
|
|
291
|
-
|
|
292
|
-
Resta comunque una base pulita e moderna.
|