Skip to content

Commit f00f482

Browse files
authored
YAML... (part 2)
1 parent 1ca2692 commit f00f482

File tree

1 file changed

+134
-134
lines changed

1 file changed

+134
-134
lines changed

src/content/docs/identityserver/upgrades/identityserver4-to-duende-identityserver-v7.mdx

Lines changed: 134 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ You can determine the version of IdentityServer4 by running the `dotnet list` co
1717

1818
{/* prettier-ignore */}
1919
<Tabs syncKey="operatingSystem">
20-
<TabItem label="Windows">
21-
<Code
22-
code={'dotnet list package | sls "IdentityServer4"'}
23-
lang="bash"
24-
title="Terminal"
25-
/>
26-
</TabItem>
27-
<TabItem label="macOS / Linux">
28-
<Code
29-
code={"dotnet list package | grep IdentityServer4"}
30-
lang="bash"
31-
title="Terminal"
32-
/>
33-
</TabItem>
20+
<TabItem label="Windows">
21+
<Code
22+
code={'dotnet list package | sls "IdentityServer4"'}
23+
lang="bash"
24+
title="Terminal"
25+
/>
26+
</TabItem>
27+
<TabItem label="macOS / Linux">
28+
<Code
29+
code={"dotnet list package | grep IdentityServer4"}
30+
lang="bash"
31+
title="Terminal"
32+
/>
33+
</TabItem>
3434
</Tabs>
3535

3636
This command will print a list of packages you are using in your solution, along with their version.
@@ -57,11 +57,11 @@ Between IdentityServer4 v3.x and v4.x, the configuration object model was update
5757

5858
- The relation between `ApiResources` and `ApiScopes` was changed from parent-child to many-to-many.
5959
- A number of configuration types were renamed:
60-
- `ApiProperties` to `ApiResourceProperties`
61-
- `ApiSecrets` to `ApiResourceSecrets`
62-
- `IdentityClaims` to `IdentityResourceClaims`
63-
- `IdentityProperties` to `IdentityResourceProperties`
64-
- `ApiScopes` to `ApiResourceScopes`
60+
- `ApiProperties` to `ApiResourceProperties`
61+
- `ApiSecrets` to `ApiResourceSecrets`
62+
- `IdentityClaims` to `IdentityResourceClaims`
63+
- `IdentityProperties` to `IdentityResourceProperties`
64+
- `ApiScopes` to `ApiResourceScopes`
6565

6666
IdentityServer4 projects that use the `IdentityServer4.EntityFramework` package or implement their own stores will need to update their code and/or database to reflect these changes.
6767

@@ -94,63 +94,63 @@ A couple of compilation errors and required changes you may encounter:
9494
- The `IIdentityServerInteractionService.GetAllUserConsentsAsync` method was renamed to `IIdentityServerInteractionService.GetAllUserGrantsAsync`
9595
- `ConsentResponse.Denied` was removed. Use the `DenyAuthorizationAsync` instead:
9696

97-
```diff lang="csharp" title="*.cs"
98-
- await _interaction.GrantConsentAsync(context, ConsentResponse.Denied);
99-
+ await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
97+
```diff lang="csharp" title="*.cs"
98+
- await _interaction.GrantConsentAsync(context, ConsentResponse.Denied);
99+
+ await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
100100
```
101101

102102
- No overload method `SignInAsync` takes N arguments. The `HttpContext.SignInAsync` signature changed:
103103

104-
```diff lang="csharp" title="*.cs"
105-
// issue authentication cookie with subject ID and username
106-
- await HttpContext.SignInAsync(user.SubjectId, user.Username, props);
107-
+ var isuser = new IdentityServerUser(user.SubjectId)
108-
+ {
109-
+ DisplayName = user.Username
110-
+ };
111-
+
112-
+ await HttpContext.SignInAsync(isuser);
104+
```diff lang="csharp" title="*.cs"
105+
// issue authentication cookie with subject ID and username
106+
- await HttpContext.SignInAsync(user.SubjectId, user.Username, props);
107+
+ var isuser = new IdentityServerUser(user.SubjectId)
108+
+ {
109+
+ DisplayName = user.Username
110+
+ };
111+
+
112+
+ await HttpContext.SignInAsync(isuser);
113113
```
114114

115115
* `AuthorizationRequest` doesn't contain definition for `ClientId`:
116116

117-
```diff lang="csharp" title="*.cs"
118-
- var client = await _clientStore.FindEnabledClientByIdAsync(request.ClientId);
119-
+ var client = await _clientStore.FindEnabledClientByIdAsync(request.Client.ClientId);
117+
```diff lang="csharp" title="*.cs"
118+
- var client = await _clientStore.FindEnabledClientByIdAsync(request.ClientId);
119+
+ var client = await _clientStore.FindEnabledClientByIdAsync(request.Client.ClientId);
120120
```
121121

122122
* `AuthorizationRequest` doesn't contain definition for `ScopesRequested`:
123123

124-
```diff lang="csharp" title="*.cs"
125-
- var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ScopesRequested);
126-
+ var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ValidatedResources.RawScopeValues);
124+
```diff lang="csharp" title="*.cs"
125+
- var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ScopesRequested);
126+
+ var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ValidatedResources.RawScopeValues);
127127
```
128128

129129
* `IClientStore` doesn't contain definition for `IsPkceClientAsync`:
130130

131-
```diff lang="csharp" title="*.cs"
132-
- if (await _clientStore.IsPkceClientAsync(context.ClientId))
133-
+ if (context.IsNativeClient())
131+
```diff lang="csharp" title="*.cs"
132+
- if (await _clientStore.IsPkceClientAsync(context.ClientId))
133+
+ if (context.IsNativeClient())
134134
```
135135

136136
* The name `ProcessLoginCallbackForOidc` does not exist in the current context:
137137

138-
```diff lang="csharp" title="*.cs"
139-
- ProcessLoginCallbackForOidc(result, additionalLocalClaims, localSignInProps);
140-
- ProcessLoginCallbackForWsFed(result, additionalLocalClaims, localSignInProps);
141-
- ProcessLoginCallbackForSaml2p(result, additionalLocalClaims, localSignInProps);
142-
+ ProcessLoginCallback(result, additionalLocalClaims, localSignInProps);
138+
```diff lang="csharp" title="*.cs"
139+
- ProcessLoginCallbackForOidc(result, additionalLocalClaims, localSignInProps);
140+
- ProcessLoginCallbackForWsFed(result, additionalLocalClaims, localSignInProps);
141+
- ProcessLoginCallbackForSaml2p(result, additionalLocalClaims, localSignInProps);
142+
+ ProcessLoginCallback(result, additionalLocalClaims, localSignInProps);
143143
```
144144

145145
* `ConsentResponse` does not contain a definition for `ScopesConsented`:
146146

147-
```diff lang="csharp" title="*.cs"
148-
grantedConsent = new ConsentResponse
149-
{
150-
RememberConsent = model.RememberConsent,
151-
- ScopesConsented = scopes.ToArray()
152-
+ ScopesValuesConsented = scopes.ToArray()
153-
};
147+
```diff lang="csharp" title="*.cs"
148+
grantedConsent = new ConsentResponse
149+
{
150+
RememberConsent = model.RememberConsent,
151+
- ScopesConsented = scopes.ToArray()
152+
+ ScopesValuesConsented = scopes.ToArray()
153+
};
154154
```
155155

156156
### Step 3: Update Database Schema
@@ -168,17 +168,17 @@ For the operational data, you can create and apply an Entity Framework Core migr
168168
{/* prettier-ignore */}
169169
<Steps>
170170

171-
1. Create the migration:
171+
1. Create the migration:
172172

173-
```bash title="Terminal"
174-
dotnet ef migrations add Grants_v4 -c PersistedGrantDbContext -o Migrations/PersistedGrantDb
175-
```
173+
```bash title="Terminal"
174+
dotnet ef migrations add Grants_v4 -c PersistedGrantDbContext -o Migrations/PersistedGrantDb
175+
```
176176

177-
2. Apply the migration to your database:
177+
2. Apply the migration to your database:
178178

179-
```bash title="Terminal"
180-
dotnet ef database update -c PersistedGrantDbContext
181-
```
179+
```bash title="Terminal"
180+
dotnet ef database update -c PersistedGrantDbContext
181+
```
182182

183183
</Steps>
184184

@@ -188,66 +188,66 @@ We'll start with creating a migration that targets the `ConfigurationDbContext`
188188
{/* prettier-ignore */}
189189
<Steps>
190190

191-
1. Create the migration:
191+
1. Create the migration:
192192

193-
```bash title="Terminal"
194-
dotnet ef migrations add Config_v4 -c ConfigurationDbContext -o Migrations/ConfigurationDb
195-
```
193+
```bash title="Terminal"
194+
dotnet ef migrations add Config_v4 -c ConfigurationDbContext -o Migrations/ConfigurationDb
195+
```
196196

197-
You will see a message _"An operation was scaffolded that may result in the loss of data. Please review the migration for accuracy."_ in the output.
198-
To avoid data loss, the migration will need to be updated.
197+
You will see a message _"An operation was scaffolded that may result in the loss of data. Please review the migration for accuracy."_ in the output.
198+
To avoid data loss, the migration will need to be updated.
199199

200-
2. To ensure no data is lost, make sure to include the [`ConfigurationDb_v4_delta.sql`](https://github.com/DuendeArchive/UpgradeSample-IdentityServer4-v3/blob/main/IdentityServerMigrationSample/ConfigurationDb_v4_delta.sql)
201-
script in your project.
200+
2. To ensure no data is lost, make sure to include the [`ConfigurationDb_v4_delta.sql`](https://github.com/DuendeArchive/UpgradeSample-IdentityServer4-v3/blob/main/IdentityServerMigrationSample/ConfigurationDb_v4_delta.sql)
201+
script in your project.
202202

203-
You can add the script as an embedded resource by updating the `.csproj` file:
203+
You can add the script as an embedded resource by updating the `.csproj` file:
204204

205-
```xml title=".csproj"
206-
<ItemGroup>
207-
<EmbeddedResource Include="ConfigurationDb_v4_delta.sql" />
208-
</ItemGroup>
209-
```
205+
```xml title=".csproj"
206+
<ItemGroup>
207+
<EmbeddedResource Include="ConfigurationDb_v4_delta.sql" />
208+
</ItemGroup>
209+
```
210210

211-
:::note[Update the SQL script for your database type]
212-
The `ConfigurationDb_v4_delta.sql` file assumes you are using SQL Server. If a different database server type is used for your IdentityServer host, you'll need to update the SQL script to use the correct syntax.
213-
:::
214-
215-
3. Modify the migration class that was just created and replace it with the following code:
216-
217-
```csharp title="Config_v4.cs"
218-
using System.IO;
219-
using Microsoft.EntityFrameworkCore.Migrations;
220-
221-
namespace IdentityServerMigrationSample.Migrations.ConfigurationDb
222-
{
223-
public partial class Config_v4 : Migration
224-
{
225-
protected override void Up(MigrationBuilder migrationBuilder)
226-
{
227-
var assembly = typeof(Program).Assembly;
228-
229-
using (var s = assembly.GetManifestResourceStream("IdentityServerMigrationSample.ConfigurationDb_v4_delta.sql"))
230-
{
231-
using (StreamReader sr = new StreamReader(s))
232-
{
233-
var sql = sr.ReadToEnd();
234-
migrationBuilder.Sql(sql);
235-
}
236-
}
237-
}
238-
239-
protected override void Down(MigrationBuilder migrationBuilder)
240-
{
241-
}
242-
}
243-
}
244-
```
211+
:::note[Update the SQL script for your database type]
212+
The `ConfigurationDb_v4_delta.sql` file assumes you are using SQL Server. If a different database server type is used for your IdentityServer host, you'll need to update the SQL script to use the correct syntax.
213+
:::
245214

246-
4. Apply the migration to your database:
215+
3. Modify the migration class that was just created and replace it with the following code:
247216

248-
```bash title="Terminal"
249-
dotnet ef database update -c ConfigurationDbContext
250-
```
217+
```csharp title="Config_v4.cs"
218+
using System.IO;
219+
using Microsoft.EntityFrameworkCore.Migrations;
220+
221+
namespace IdentityServerMigrationSample.Migrations.ConfigurationDb
222+
{
223+
public partial class Config_v4 : Migration
224+
{
225+
protected override void Up(MigrationBuilder migrationBuilder)
226+
{
227+
var assembly = typeof(Program).Assembly;
228+
229+
using (var s = assembly.GetManifestResourceStream("IdentityServerMigrationSample.ConfigurationDb_v4_delta.sql"))
230+
{
231+
using (StreamReader sr = new StreamReader(s))
232+
{
233+
var sql = sr.ReadToEnd();
234+
migrationBuilder.Sql(sql);
235+
}
236+
}
237+
}
238+
239+
protected override void Down(MigrationBuilder migrationBuilder)
240+
{
241+
}
242+
}
243+
}
244+
```
245+
246+
4. Apply the migration to your database:
247+
248+
```bash title="Terminal"
249+
dotnet ef database update -c ConfigurationDbContext
250+
```
251251

252252
</Steps>
253253

@@ -405,15 +405,15 @@ In this section, we'll look at updating the database schema based on the stores
405405
- Improve primary keys on the persisted grants table ([more details](https://github.com/DuendeSoftware/products/pull/793)).
406406
- Add new properties to the [`Duende.IdentityServer.Models.Client` model](/identityserver/reference/models/client):
407407

408-
- `InitiateLoginUri` is a nullable string used for Third Party Initiated Login.
409-
- `RequireDPoP` is a non-nullable boolean flag that controls if a client is required to use [DPoP](../../tokens/pop).
410-
- `DPoPValidationMode` is a non-nullable column that controls the DPoP validation mechanism. Existing clients that are not using DPoP can set its value to `0`.
411-
- `DPoPClockSkew` is a non-nullable timespan that controls how much clock skew is allowed for a particular DPoP client. Existing clients that are not using DPoP can set its value to a timespan of length ``0.
408+
- `InitiateLoginUri` is a nullable string used for Third Party Initiated Login.
409+
- `RequireDPoP` is a non-nullable boolean flag that controls if a client is required to use [DPoP](../../tokens/pop).
410+
- `DPoPValidationMode` is a non-nullable column that controls the DPoP validation mechanism. Existing clients that are not using DPoP can set its value to `0`.
411+
- `DPoPClockSkew` is a non-nullable timespan that controls how much clock skew is allowed for a particular DPoP client. Existing clients that are not using DPoP can set its value to a timespan of length ``0.
412412

413413
- Two new properties have been added to the `Client` model:
414-
- `Client.RequirePushedAuthorization` is a new boolean property that controls if this client requires [pushed authorization requests (PAR)](../../tokens/par). It is safe to initialize this column to `false` for existing clients, which will mean that the global PAR configuration will be used.
415-
- `Client.PushedAuthorizationLifetime` is a new nullable integer property that controls the lifetime of pushed
416-
authorization requests (in seconds) for a client. It is safe to initialize this column to `null` for existing clients, which means the global value is used.
414+
- `Client.RequirePushedAuthorization` is a new boolean property that controls if this client requires [pushed authorization requests (PAR)](../../tokens/par). It is safe to initialize this column to `false` for existing clients, which will mean that the global PAR configuration will be used.
415+
- `Client.PushedAuthorizationLifetime` is a new nullable integer property that controls the lifetime of pushed
416+
authorization requests (in seconds) for a client. It is safe to initialize this column to `null` for existing clients, which means the global value is used.
417417
- A new `PushedAuthorizationRequest` table has been added to store pushed authorization requests.
418418

419419
You'll need to create two database migrations that update the database schema: one that targets the `PersistedGrantDbContext` (for operational data), and one that targets the `ConfigurationDbContext` (for configuration data).
@@ -422,25 +422,25 @@ Note that you may want to change the database migration paths in the examples be
422422
{/* prettier-ignore */}
423423
<Steps>
424424

425-
1. Create the migrations for the operational and configuration database context:
425+
1. Create the migrations for the operational and configuration database context:
426426

427-
```bash title="Terminal"
428-
dotnet ef migrations add UpdateToDuende_v7_0 -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb
429-
dotnet ef migrations add UpdateToDuende_v7_0 -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb
430-
```
427+
```bash title="Terminal"
428+
dotnet ef migrations add UpdateToDuende_v7_0 -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb
429+
dotnet ef migrations add UpdateToDuende_v7_0 -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb
430+
```
431431

432-
:::note
433-
You may see a warning _"An operation was scaffolded that may result in the loss of data. Please review the migration for accuracy."_.
434-
The column length for redirect URIs (for both login and logout) was reduced from 2000 to 400 to overcome database index size limits.
435-
Unless you are using redirect URIs greater than 400 characters, this should not affect you.
436-
:::
432+
:::note
433+
You may see a warning _"An operation was scaffolded that may result in the loss of data. Please review the migration for accuracy."_.
434+
The column length for redirect URIs (for both login and logout) was reduced from 2000 to 400 to overcome database index size limits.
435+
Unless you are using redirect URIs greater than 400 characters, this should not affect you.
436+
:::
437437

438-
2. Apply the migrations to your database:
438+
2. Apply the migrations to your database:
439439

440-
```bash title="Terminal"
441-
dotnet ef database update -c PersistedGrantDbContext
442-
dotnet ef database update -c ConfigurationDbContext
443-
```
440+
```bash title="Terminal"
441+
dotnet ef database update -c PersistedGrantDbContext
442+
dotnet ef database update -c ConfigurationDbContext
443+
```
444444

445445
</Steps>
446446

0 commit comments

Comments
 (0)