mirror of https://github.com/abpframework/abp.git
committed by
GitHub
63 changed files with 834 additions and 343 deletions
@ -0,0 +1,108 @@ |
|||
# OpenIddict 4.x to 5.x Migration Guide |
|||
|
|||
The 5.0 release of OpenIddict is a major release that introduces breaking changes. |
|||
|
|||
Check this blog [Introducing native applications, per-client token lifetimes and client assertions support in OpenIddict 5.0 preview1](https://kevinchalet.com/2023/10/20/introducing-native-applications-per-client-token-lifetimes-and-client-assertions-support-in-openiddict-5-0-preview1/) for the new features introduced in OpenIddict 5.0. |
|||
|
|||
I will show the changes you need to make to do the migration. |
|||
|
|||
> Please backup your database before doing the migration. |
|||
|
|||
## OpenIddictApplication changes |
|||
|
|||
1. The `Type(string)` of the `OpenIddictApplication` has been renamed to `ClientType(string)`. |
|||
2. The `ApplicationType(string)` has been added to the `OpenIddictApplication` entity. |
|||
3. The `JsonWebKeySet(string)` has been added to the `OpenIddictApplication` entity. |
|||
4. The `Settings(string)` has been added to the `OpenIddictApplication` entity. |
|||
|
|||
The new migration looks like this: |
|||
|
|||
````csharp |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace OpenIddict.Demo.Server.Migrations |
|||
{ |
|||
/// <inheritdoc /> |
|||
public partial class openiddict5 : Migration |
|||
{ |
|||
/// <inheritdoc /> |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.RenameColumn( |
|||
name: "Type", |
|||
table: "OpenIddictApplications", |
|||
newName: "ClientType"); |
|||
|
|||
migrationBuilder.AddColumn<string>( |
|||
name: "ApplicationType", |
|||
table: "OpenIddictApplications", |
|||
type: "nvarchar(50)", |
|||
maxLength: 50, |
|||
nullable: true); |
|||
|
|||
migrationBuilder.AddColumn<string>( |
|||
name: "JsonWebKeySet", |
|||
table: "OpenIddictApplications", |
|||
type: "nvarchar(max)", |
|||
nullable: true); |
|||
|
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Settings", |
|||
table: "OpenIddictApplications", |
|||
type: "nvarchar(max)", |
|||
nullable: true); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "ApplicationType", |
|||
table: "OpenIddictApplications"); |
|||
|
|||
migrationBuilder.DropColumn( |
|||
name: "JsonWebKeySet", |
|||
table: "OpenIddictApplications"); |
|||
|
|||
migrationBuilder.DropColumn( |
|||
name: "Settings", |
|||
table: "OpenIddictApplications"); |
|||
|
|||
migrationBuilder.RenameColumn( |
|||
name: "ClientType", |
|||
table: "OpenIddictApplications", |
|||
newName: "Type"); |
|||
} |
|||
} |
|||
} |
|||
```` |
|||
|
|||
## OpenIddictApplicationModel changes |
|||
|
|||
1. The `Type(string)` of the `OpenIddictApplicationModel` has been renamed to `ClientType(string)`. |
|||
2. The `ApplicationType(string)` has been added to the `OpenIddictApplicationModel` entity. |
|||
3. The `JsonWebKeySet`([JsonWebKeySet](https://learn.microsoft.com/en-us/dotnet/api/microsoft.identitymodel.tokens.jsonwebkeyset)) has been added to the `OpenIddictApplicationModel` entity. |
|||
4. The `Settings(string)` has been added to the `OpenIddictApplicationModel` entity. |
|||
|
|||
## OpenIddictApplicationDescriptor changes |
|||
|
|||
You have to change the `Type` to `ClientType` when creating a new `AbpApplicationDescriptor` or `OpenIddictApplicationDescriptor`. |
|||
|
|||
````csharp |
|||
var application = new AbpApplicationDescriptor { |
|||
ClientId = name, |
|||
- Type = type, |
|||
+ ClientType = type, |
|||
ClientSecret = secret, |
|||
ConsentType = consentType, |
|||
DisplayName = displayName, |
|||
```` |
|||
|
|||
## OpenIddict Pro module UI changes |
|||
|
|||
You can change the `ApplicationType` when creating/editing a OpenIddict's application, also set time life of the tokens for each application. |
|||
|
|||
 |
|||
 |
|||
|
After Width: | Height: | Size: 291 KiB |
|
After Width: | Height: | Size: 203 KiB |
@ -1,45 +1,58 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Logging.Abstractions; |
|||
using Microsoft.Extensions.Options; |
|||
using OpenIddict.Server; |
|||
using Volo.Abp.Text.Formatting; |
|||
|
|||
namespace Volo.Abp.OpenIddict.WildcardDomains; |
|||
|
|||
public abstract class AbpOpenIddictWildcardDomainBase<THandler, TContext> : IOpenIddictServerHandler<TContext> |
|||
public abstract class AbpOpenIddictWildcardDomainBase<THandler, TOriginalHandler, TContext> : IOpenIddictServerHandler<TContext> |
|||
where THandler : class |
|||
where TOriginalHandler : class |
|||
where TContext : OpenIddictServerEvents.BaseContext |
|||
{ |
|||
protected THandler Handler { get; set; } |
|||
public ILogger<THandler> Logger { get; set; } |
|||
protected TOriginalHandler OriginalHandler { get; set; } |
|||
protected AbpOpenIddictWildcardDomainOptions WildcardDomainOptions { get; } |
|||
|
|||
protected AbpOpenIddictWildcardDomainBase(IOptions<AbpOpenIddictWildcardDomainOptions> wildcardDomainOptions, THandler handler) |
|||
protected AbpOpenIddictWildcardDomainBase(IOptions<AbpOpenIddictWildcardDomainOptions> wildcardDomainOptions, TOriginalHandler originalHandler) |
|||
{ |
|||
WildcardDomainOptions = wildcardDomainOptions.Value; |
|||
Handler = handler; |
|||
OriginalHandler = originalHandler; |
|||
|
|||
Logger = NullLogger<THandler>.Instance; |
|||
} |
|||
|
|||
public abstract ValueTask HandleAsync(TContext context); |
|||
|
|||
protected virtual Task<bool> CheckWildcardDomainAsync(string url) |
|||
{ |
|||
Logger.LogDebug("Checking wildcard domain for url: {url}", url); |
|||
|
|||
foreach (var domainFormat in WildcardDomainOptions.WildcardDomainsFormat) |
|||
{ |
|||
Logger.LogDebug("Checking wildcard domain format: {domainFormat}", domainFormat); |
|||
var extractResult = FormattedStringValueExtracter.Extract(url, domainFormat, ignoreCase: true); |
|||
if (extractResult.IsMatch) |
|||
{ |
|||
Logger.LogDebug("Wildcard domain found for url: {url}", url); |
|||
return Task.FromResult(true); |
|||
} |
|||
} |
|||
|
|||
foreach (var domainFormat in WildcardDomainOptions.WildcardDomainsFormat) |
|||
{ |
|||
Logger.LogDebug("Checking wildcard domain format: {domainFormat}", domainFormat); |
|||
if (domainFormat.Replace("{0}.", "").Equals(url, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
Logger.LogDebug("Wildcard domain found for url: {url}", url); |
|||
return Task.FromResult(true); |
|||
} |
|||
} |
|||
|
|||
Logger.LogDebug("Wildcard domain not found for url: {url}", url); |
|||
return Task.FromResult(false); |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue