diff --git a/guide/migration.html b/guide/migration.html new file mode 100644 index 0000000..d803202 --- /dev/null +++ b/guide/migration.html @@ -0,0 +1,333 @@ + + + + + + + + What's new in OpenIddict RC2? + + + + + + + + + + + + + + + +
+
+ +
+
+
+ + + + + +
+
+
+
+ +
+
+
+
+
+ +
+
+
    +
  • +
+
+
+
+
+ +
+ Show / Hide Table of Contents +
+
+
+
+
+
+
+

What's new in OpenIddict RC2?

+ +

The full list of changes can be found here. It includes bug fixes (including a bug fix in the refresh token handling) and new features like application permissions, that allow limiting the OpenID Connect features (endpoints and flows) an application is able to use.

+

Migrate to OpenIddict RC2

+

Migrating to OpenIddict RC2 (1.0.0-rc2-* and 2.0.0-rc2-*) requires making changes in your database: existing properties have been reworked (e.g to work around a MySQL limitation) and new ones have been added to support the new features. This procedure is quite easy and only requires a few minutes.

+

Note: this guide assumes your application uses the OpenIddict Entity Framework Core 2.x stores. If you use a custom store, changes will have to be made manually. A list of added/updated/renamed columns is available at the end of this guide.

+
+

Ensure migrations are correctly enabled for your project

+

Before migrating to OpenIddict RC2, make sure migrations are already enabled for your application. If you have a Migrations folder in your application root folder and an __EFMigrationsHistory table in your database, you're good to go.

+

If you don't have these Entity Framework Core artificats, migrations are likely not enabled. To fix that, add the following entries in your .csproj:

+
<ItemGroup>
+  <PackageReference Include="Microsoft.EntityFrameworkCore.Design"
+                    Version="2.0.0" PrivateAssets="All" />
+</ItemGroup>
+
+<ItemGroup>
+  <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
+                          Version="2.0.0" />
+</ItemGroup>
+

Then, open a new command line and add an initial migration using dotnet ef migrations add InitialMigration (but don't apply it!).

+

Update your packages references

+

For that, simply update your .csproj file to point to the newest OpenIddict packages:

+

ASP.NET Core 1.x

+
<ItemGroup>
+  <PackageReference Include="OpenIddict" Version="1.0.0-rc2-*" />
+  <PackageReference Include="OpenIddict.EntityFrameworkCore" Version="1.0.0-rc2-*" />
+  <PackageReference Include="OpenIddict.Mvc" Version="1.0.0-rc2-*" />
+</ItemGroup>
+

ASP.NET Core 2.x

+
<ItemGroup>
+  <PackageReference Include="OpenIddict" Version="2.0.0-rc2-*" />
+  <PackageReference Include="OpenIddict.EntityFrameworkCore" Version="2.0.0-rc2-*" />
+  <PackageReference Include="OpenIddict.Mvc" Version="2.0.0-rc2-*" />
+</ItemGroup>
+

Add a new migration

+
    +
  1. First, open a new command line and run dotnet ef migrations add MigrateToOpenIddictRc2.
  2. +
  3. If you created an initial migration at step 1, remove it from the Migrations folder.
  4. +
  5. Apply the MigrateToOpenIddictRc2 migration using dotnet ef database update MigrateToOpenIddictRc2.
  6. +
+

Run the migration script to convert columns to the new format

+

For that, add the following snippet to your Startup class:

+
private async Task UpdateOpenIddictTablesAsync(IServiceProvider services)
+{
+    using (var scope = services.GetRequiredService<IServiceScopeFactory>().CreateScope())
+    {
+        // Change ApplicationDbContext to match your context name if you've changed it.
+        var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
+        await context.Database.EnsureCreatedAsync();
+
+        // If you use a different entity type or a custom key,
+        // change this line (e.g OpenIddictApplication<long>).
+        foreach (var application in context.Set<OpenIddictApplication>())
+        {
+            // Convert the space-separated PostLogoutRedirectUris property to JSON.
+            if (!string.IsNullOrEmpty(application.PostLogoutRedirectUris) &&
+                 application.PostLogoutRedirectUris[0] != '[')
+            {
+                var addresses = application.PostLogoutRedirectUris.Split(
+                    new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+
+                application.PostLogoutRedirectUris =
+                    new JArray(addresses).ToString(Formatting.None);
+            }
+
+            // Convert the space-separated RedirectUris property to JSON.
+            if (!string.IsNullOrEmpty(application.RedirectUris) &&
+                 application.RedirectUris[0] != '[')
+            {
+                var addresses = application.RedirectUris.Split(
+                    new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+
+                application.RedirectUris = new JArray(addresses).ToString(Formatting.None);
+            }
+
+            // Grant the application all the permissions. Don't hesitate to update
+            // the list to only grant the permissions really needed by the application.
+            if (string.IsNullOrEmpty(application.Permissions))
+            {
+                var permissions = new[]
+                {
+                    OpenIddictConstants.Permissions.Endpoints.Authorization,
+                    OpenIddictConstants.Permissions.Endpoints.Introspection,
+                    OpenIddictConstants.Permissions.Endpoints.Logout,
+                    OpenIddictConstants.Permissions.Endpoints.Revocation,
+                    OpenIddictConstants.Permissions.Endpoints.Token,
+
+                    OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
+                    OpenIddictConstants.Permissions.GrantTypes.ClientCredentials,
+                    OpenIddictConstants.Permissions.GrantTypes.Implicit,
+                    OpenIddictConstants.Permissions.GrantTypes.Password,
+                    OpenIddictConstants.Permissions.GrantTypes.RefreshToken
+                };
+
+                application.Permissions = new JArray(permissions).ToString(Formatting.None);
+            }
+        }
+
+        // If you use a different entity type or a custom key,
+        // change this line (e.g OpenIddictAuthorization<long>).
+        foreach (var authorization in context.Set<OpenIddictAuthorization>())
+        {
+            // Convert the space-separated Scopes property to JSON.
+            if (!string.IsNullOrEmpty(authorization.Scopes) && authorization.Scopes[0] != '[')
+            {
+                var scopes = authorization.Scopes.Split(
+                    new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+
+                authorization.Scopes = new JArray(scopes).ToString(Formatting.None);
+            }
+        }
+
+        await context.SaveChangesAsync();
+    }
+}
+

Then, at the end of the public void Configure(IApplicationBuilder app) method, add the following line:

+
public void Configure(IApplicationBuilder app)
+{
+    app.UseDeveloperExceptionPage();
+
+    app.UseStaticFiles();
+
+    app.UseStatusCodePagesWithReExecute("/error");
+
+    app.UseAuthentication();
+
+    app.UseMvcWithDefaultRoute();
+
+    // Run the migration script synchronously.
+    UpdateOpenIddictTablesAsync(app.ApplicationServices).GetAwaiter().GetResult();
+}
+

Run your application. Once it's correctly started, stop it and remove the migration script.

+

List of changes (for applications using custom stores)

+

Renamed properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TableOld column nameNew column nameObservations
OpenIddictApplicationsTimestampConcurrencyTokenThe column type was changed to nvarchar to work around a MySQL limitation.
OpenIddictAuthorizationsTimestampConcurrencyTokenThe column type was changed to nvarchar to work around a MySQL limitation.
OpenIddictScopesTimestampConcurrencyTokenThe column type was changed to nvarchar to work around a MySQL limitation.
OpenIddictTokensTimestampConcurrencyTokenThe column type was changed to nvarchar to work around a MySQL limitation.
OpenIddictTokensCiphertextPayload
OpenIddictTokensHashReferenceId
+

Added properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TableColumn nameTypeNullable
OpenIddictApplicationsPropertiesnvarchar(max)Yes
OpenIddictApplicationsPermissionsnvarchar(max)Yes
OpenIddictAuthorizationsPropertiesnvarchar(max)Yes
OpenIddictScopesPropertiesnvarchar(max)Yes
OpenIddictTokensPropertiesnvarchar(max)Yes
+
+
+ +
+
+
+
    +
  • + Improve this Doc +
  • +
+
+
+ +
+
+
+
+
+ +
+
+
+
+ + Back to top + + + Copyright © 2015-2017 Microsoft
Generated by DocFX
+
+
+
+
+ + + + + + diff --git a/guide/toc.html b/guide/toc.html index 851c2dc..ccbe027 100644 --- a/guide/toc.html +++ b/guide/toc.html @@ -78,6 +78,9 @@
  • Getting started
  • +
  • + Migration guide +
  • Samples
  • diff --git a/manifest.json b/manifest.json index 4d44dd1..3aec10e 100644 --- a/manifest.json +++ b/manifest.json @@ -98,6 +98,18 @@ "is_incremental": false, "version": "" }, + { + "type": "Conceptual", + "source_relative_path": "guide/migration.md", + "output": { + ".html": { + "relative_path": "guide/migration.html", + "hash": "CE/SnB1CWsQYD3y5GPuFuA==" + } + }, + "is_incremental": false, + "version": "" + }, { "type": "Conceptual", "source_relative_path": "guide/samples.md", @@ -116,7 +128,7 @@ "output": { ".html": { "relative_path": "guide/toc.html", - "hash": "n9Utc5gSWynwMpfSnaYVPA==" + "hash": "vhNRYjBlHhDAs5rexKkmng==" } }, "is_incremental": false, @@ -140,7 +152,7 @@ "output": { ".html": { "relative_path": "toc.html", - "hash": "bNVS4TxedIkZ+3ds9odx5w==" + "hash": "DXK29jBdtRMjNtYqHIIxxg==" } }, "is_incremental": false, @@ -155,23 +167,23 @@ "incrementalPhase": "build" }, "processors": { + "ResourceDocumentProcessor": { + "can_incremental": false, + "details": "Processor ResourceDocumentProcessor cannot suppport incremental build because the processor doesn't implement ISupportIncrementalDocumentProcessor interface.", + "incrementalPhase": "build" + }, "RestApiDocumentProcessor": { "can_incremental": false, "details": "Processor RestApiDocumentProcessor cannot suppport incremental build because the processor doesn't implement ISupportIncrementalDocumentProcessor interface.", "incrementalPhase": "build" }, - "TocDocumentProcessor": { - "can_incremental": false, - "details": "Processor TocDocumentProcessor cannot suppport incremental build because the processor doesn't implement ISupportIncrementalDocumentProcessor interface.", - "incrementalPhase": "build" - }, "ConceptualDocumentProcessor": { "can_incremental": false, "incrementalPhase": "build" }, - "ResourceDocumentProcessor": { + "TocDocumentProcessor": { "can_incremental": false, - "details": "Processor ResourceDocumentProcessor cannot suppport incremental build because the processor doesn't implement ISupportIncrementalDocumentProcessor interface.", + "details": "Processor TocDocumentProcessor cannot suppport incremental build because the processor doesn't implement ISupportIncrementalDocumentProcessor interface.", "incrementalPhase": "build" }, "ManagedReferenceDocumentProcessor": { diff --git a/toc.html b/toc.html index 64dc63a..41f4dac 100644 --- a/toc.html +++ b/toc.html @@ -75,6 +75,9 @@
  • User guide
  • +
  • + Migration guide +