Merge pull request #13539 from abpframework/auto-merge/rel-6-0/1237

Merge branch dev with rel-6.0
pull/13548/head
Enis Necipoglu 3 years ago committed by GitHub
commit 82d53070c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,7 +20,9 @@ LeptonX Lite is now being introduced and you can follow the guides below to migr
## Migrating to OpenIddict
After the [announcement of plan to replace the IdentityServer](https://github.com/abpframework/abp/issues/11989), we have successfully implemented [Openiddict](https://github.com/openiddict/openiddict-core) as a replacement for IdentityServer4 as OpenID-Provider. You can follow [Migrating Identity Server to OpenIddict guide](./IdentityServer_To_OpenIddict.md).
After the [announcement of plan to replace the IdentityServer](https://github.com/abpframework/abp/issues/11989), we have successfully implemented [Openiddict](https://github.com/openiddict/openiddict-core) as a replacement for IdentityServer4 as an OpenID-Provider.
You can follow the [IdentityServer to OpenIddict Step by Step Guide](OpenIddict-Step-by-Step.md) for migrating your existing application in detail with a sample projects.
## See Also

@ -0,0 +1,170 @@
# OpenIddict Angular UI Migration Guide
## Angular Project
- In `environment.ts` and `environment.prod.ts` **add a trailing slash at the end of the issuer**:
```typescript
oAuthConfig: {
issuer: 'https://localhost:44377/',
...
},
```
## Http.Api.Host (Non-Separated IdentityServer)
- In **MyApplication.HttpApi.Host.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="6.0.0-rc.1" />
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" />
```
- In the **MyApplicationHttpApiHostModule.cs** replace usings and **module dependencies**:
```csharp
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
...
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAccountWebIdentityServerModule),
```
with
```csharp
using OpenIddict.Validation.AspNetCore;
...
typeof(AbpAccountWebOpenIddictModule),
```
- In the **MyApplicationHttpApiHostModule.cs** add `PreConfigureServices` like below with your application name as the audience:
```csharp
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("MyApplication"); // Replace with your application name
options.UseLocalServer();
options.UseAspNetCore();
});
});
}
```
- In the **MyApplicationHttpApiHostModule.cs** `ConfigureServices` method, **replace the method call**:
From `ConfigureAuthentication(context, configuration);` to `ConfigureAuthentication(context);` and update the method as:
```csharp
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
}
```
- In the **MyApplicationHttpApiHostModule.cs** `OnApplicationInitialization` method, **replace the midware**:
```csharp
app.UseJwtTokenMiddleware();
app.UseIdentityServer();
```
with
```csharp
app.UseAbpOpenIddictValidation();
```
- In the **MyApplicationHttpApiHostModule.cs** `OnApplicationInitialization` method, delete `c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` in `app.UseAbpSwaggerUI` options configurations which is no longer needed.
- In `appsettings.json` delete **SwaggerClientSecret** from the *AuthServer* section like below:
```json
"AuthServer": {
"Authority": "https://localhost:44345",
"RequireHttpsMetadata": "false",
"SwaggerClientId": "MyApplication_Swagger"
},
```
## Http.Api.Host (Separated IdentityServer)
- In the **MyApplicationHttpApiHostModule.cs** `OnApplicationInitialization` method, delete `c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` in `app.UseAbpSwaggerUI` options configurations which is no longer needed.
- In `appsettings.json` delete **SwaggerClientSecret** from the *AuthServer* section like below:
```json
"AuthServer": {
"Authority": "https://localhost:44345",
"RequireHttpsMetadata": "false",
"SwaggerClientId": "MyApplication_Swagger"
},
```
## IdentityServer
This project is renamed to **AuthServer** after v6.0.0-rc1. You can also refactor and rename your project to *AuthServer* for easier updates in the future.
- In **MyApplication.IdentityServer.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" />
```
- In the **MyApplicationIdentityServerModule.cs** replace usings and **module dependencies**:
```csharp
typeof(AbpAccountWebIdentityServerModule),
```
with
```csharp
typeof(AbpAccountWebOpenIddictModule),
```
- In the **MyApplicationIdentityServerModule.cs** add `PreConfigureServices` like below with your application name as the audience:
```csharp
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("MyApplication"); // Replace with your application name
options.UseLocalServer();
options.UseAspNetCore();
});
});
}
```
- In the **MyApplicationIdentityServerModule.cs** `OnApplicationInitialization` method, **remove the midware**:
```csharp
app.UseIdentityServer();
```
- To use the new AuthServer page, replace **Index.cshtml.cs** with [AuthServer Index.cshtml.cs](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.IdentityServer/Pages/Index.cshtml) and **Index.cshtml** file with [AuthServer Index.cshtml](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.IdentityServer/Pages/Index.cshtml.cs) and rename **Ids2OpenId** with your application namespace.
> Note: It can be found under the *Pages* folder.
## See Also
* [OpenIddict Step-by-Step Guide](OpenIddict-Step-by-Step.md)

@ -0,0 +1,175 @@
# OpenIddict Blazor-Server UI Migration Guide
## Blazor Project (Non-Tiered Solution)
- In the **MyApplication.Blazor.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="6.0.0-rc.1" />
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" />
```
- In the **MyApplicationBlazorModule.cs** replace usings and **module dependencies**:
```csharp
using System;
using System.Net.Http;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
...
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAccountWebIdentityServerModule),
```
with
```csharp
using OpenIddict.Validation.AspNetCore;
...
typeof(AbpAccountWebOpenIddictModule),
```
- In the **MyApplicationBlazorModule.cs** add `PreConfigureServices` like below with your application name as the audience:
```csharp
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("MyApplication"); // Replace with your application name
options.UseLocalServer();
options.UseAspNetCore();
});
});
}
```
- In the **MyApplicationBlazorModule.cs** `ConfigureServices` method, **replace the method call**:
From `ConfigureAuthentication(context, configuration);` to `ConfigureAuthentication(context);` and update the method as:
```csharp
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
}
```
- In the **MyApplicationBlazorModule.cs** `OnApplicationInitialization` method, **replace the midware**:
```csharp
app.UseJwtTokenMiddleware();
app.UseIdentityServer();
```
with
```csharp
app.UseAbpOpenIddictValidation();
```
## Blazor Project (Tiered Solution)
- In the **MyApplicationWebModule.cs** update the `AddAbpOpenIdConnect` configurations:
```csharp
.AddAbpOpenIdConnect("oidc", options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("roles"); // Replace "role" with "roles"
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("MyApplication");
});
```
Replace **role** scope with **roles**.
## IdentityServer
This project is renamed to **AuthServer** after v6.0.0-rc1. You can also refactor and rename your project to *AuthServer* for easier updates in the future.
- In **MyApplication.IdentityServer.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" />
```
- In **MyApplicationIdentityServerModule.cs** replace usings and **module dependencies**:
```csharp
typeof(AbpAccountWebIdentityServerModule),
```
with
```csharp
typeof(AbpAccountWebOpenIddictModule),
```
- In the **MyApplicationIdentityServerModule.cs** add `PreConfigureServices` like below with your application name as the audience:
```csharp
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("MyApplication"); // Replace with your application name
options.UseLocalServer();
options.UseAspNetCore();
});
});
}
```
- In **MyApplicationIdentityServerModule.cs** `OnApplicationInitialization` method **remove IdentityServer midware**:
```csharp
app.UseIdentityServer();
```
## Http.Api.Host
- In the **MyApplicationHttpApiHostModule.cs** `OnApplicationInitialization` method, delete `c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` in `app.UseAbpSwaggerUI` options configurations which is no longer needed.
- In `appsettings.json` delete **SwaggerClientSecret** from the *AuthServer* section like below:
```json
"AuthServer": {
"Authority": "https://localhost:44345",
"RequireHttpsMetadata": "false",
"SwaggerClientId": "MyApplication_Swagger"
},
```
- To use the new AuthServer page, replace **Index.cshtml.cs** with [AuthServer Index.cshtml.cs](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.IdentityServer/Pages/Index.cshtml) and **Index.cshtml** file with [AuthServer Index.cshtml](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.IdentityServer/Pages/Index.cshtml.cs) and rename **Ids2OpenId** with your application namespace.
> Note: It can be found under the *Pages* folder.
## See Also
* [OpenIddict Step-by-Step Guide](OpenIddict-Step-by-Step.md)

@ -0,0 +1,189 @@
# OpenIddict Blazor Wasm UI Migration Guide
## Blazor Project
- In the **MyApplicationBlazorModule.cs** update the `ConfigureAuthentication` method:
```csharp
builder.Services.AddOidcAuthentication(options =>
{
...
options.UserOptions.RoleClaim = JwtClaimTypes.Role;
options.ProviderOptions.DefaultScopes.Add("role");
...
});
```
Update **UserOptions** and **role scope** as below
```csharp
builder.Services.AddOidcAuthentication(options =>
{
...
options.UserOptions.NameClaim = OpenIddictConstants.Claims.Name;
options.UserOptions.RoleClaim = OpenIddictConstants.Claims.Role;
options.ProviderOptions.DefaultScopes.Add("roles");
...
});
```
## Http.Api.Host (Non-Separated IdentityServer)
- In the **MyApplication.HttpApi.Host.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="6.0.0-rc.1" />
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" />
```
- In the **MyApplicationHttpApiHostModule.cs** replace usings and **module dependencies**:
```csharp
using System.Net.Http;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
...
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAccountWebIdentityServerModule),
```
with
```csharp
using OpenIddict.Validation.AspNetCore;
...
typeof(AbpAccountWebOpenIddictModule),
```
- In the **MyApplicationBlazorModule.cs** add `PreConfigureServices` like below with your application name as the audience:
```csharp
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("MyApplication"); // Replace with your application name
options.UseLocalServer();
options.UseAspNetCore();
});
});
}
```
- In the **MyApplicationBlazorModule.cs** `ConfigureServices` method, **replace the method call**:
From `ConfigureAuthentication(context, configuration);` to `ConfigureAuthentication(context);` and update the method as:
```csharp
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
}
```
- In the **MyApplicationBlazorModule.cs** `OnApplicationInitialization` method, **replace the midware**:
```csharp
app.UseJwtTokenMiddleware();
app.UseIdentityServer();
```
with
```csharp
app.UseAbpOpenIddictValidation();
```
- Delete `c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` in `app.UseAbpSwaggerUI` options configurations which is no longer needed.
- In `appsettings.json` delete **SwaggerClientSecret** from the *AuthServer* section like below:
```json
"AuthServer": {
"Authority": "https://localhost:44345",
"RequireHttpsMetadata": "false",
"SwaggerClientId": "MyApplication_Swagger"
},
```
## Http.Api.Host (Separated IdentityServer)
- In the **MyApplicationHttpApiHostModule.cs** `OnApplicationInitialization` method, delete `c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` in `app.UseAbpSwaggerUI` options configurations which is no longer needed.
- In `appsettings.json` delete **SwaggerClientSecret** from the *AuthServer* section like below:
```json
"AuthServer": {
"Authority": "https://localhost:44345",
"RequireHttpsMetadata": "false",
"SwaggerClientId": "MyApplication_Swagger"
},
```
## IdentityServer
This project is renamed to **AuthServer** after v6.0.0-rc1. You can also refactor and rename your project to *AuthServer* for easier updates in the future.
- In **MyApplication.IdentityServer.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" />
```
- In the **MyApplicationIdentityServerModule.cs** replace usings and **module dependencies**:
```csharp
typeof(AbpAccountWebIdentityServerModule),
```
with
```csharp
typeof(AbpAccountWebOpenIddictModule),
```
- In the **MyApplicationIdentityServerModule.cs** add `PreConfigureServices` like below with your application name as the audience:
```csharp
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("MyApplication"); // Replace with your application name
options.UseLocalServer();
options.UseAspNetCore();
});
});
}
```
- In the **MyApplicationIdentityServerModule.cs** `OnApplicationInitialization` method, **remove the midware**:
```csharp
app.UseIdentityServer();
```
- To use the new AuthServer page, replace **Index.cshtml.cs** with [AuthServer Index.cshtml.cs](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.IdentityServer/Pages/Index.cshtml) and **Index.cshtml** file with [AuthServer Index.cshtml](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.IdentityServer/Pages/Index.cshtml.cs) and rename **Ids2OpenId** with your application namespace.
> Note: It can be found under the *Pages* folder.
## See Also
* [OpenIddict Step-by-Step Guide](OpenIddict-Step-by-Step.md)

@ -0,0 +1,166 @@
# OpenIddict MVC/Razor UI Migration Guide
## Web Project (Non-Tiered Solution)
- In **MyApplication.Web.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="6.0.0-rc.1" />
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.Account.Web" Version="6.0.0-rc.1" />
```
- In **MyApplicationWebModule.cs** replace usings and **module dependencies**:
```csharp
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
...
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
```
with
```csharp
typeof(AbpAccountWebModule),
```
- In **MyApplicationWebModule.cs** `ConfigureServices` method **update authentication configuration**:
```csharp
ConfigureAuthentication(context, configuration);
```
with
```csharp
ConfigureAuthentication(context);
```
and update the `ConfigureAuthentication` private method to:
```csharp
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
}
```
- In **MyApplicationWebModule.cs** `OnApplicationInitialization` method **replace IdentityServer and JwtToken midwares**:
```csharp
app.UseJwtTokenMiddleware();
app.UseIdentityServer();
```
with
```csharp
app.UseAbpOpenIddictValidation();
```
## Web Project (Tiered Solution)
- In the **MyApplicationWebModule.cs** update the `AddAbpOpenIdConnect` configurations:
```csharp
.AddAbpOpenIdConnect("oidc", options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.UsePkce = true; // Add this line
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true
options.Scope.Add("roles"); // Replace "role" with "roles"
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("MyApplication");
});
```
Replace role scope to **roles** and add **UsePkce** and **SignoutScheme** options.
## IdentityServer
This project is renamed to **AuthServer** after v6.0.0-rc1. You can also refactor and rename your project to *AuthServer* for easier updates in the future.
- In **MyApplication.IdentityServer.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="6.0.0-rc.1" />
```
- In **MyApplicationIdentityServerModule.cs** replace usings and **module dependencies**:
```csharp
typeof(AbpAccountWebIdentityServerModule),
```
with
```csharp
typeof(AbpAccountWebOpenIddictModule),
```
- In the **MyApplicationIdentityServerModule.cs** add `PreConfigureServices` like below with your application name as the audience:
```csharp
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("MyApplication"); // Replace with your application name
options.UseLocalServer();
options.UseAspNetCore();
});
});
}
```
- In **MyApplicationIdentityServerModule.cs** `OnApplicationInitialization` method **remove IdentityServer midware**:
```csharp
app.UseIdentityServer();
```
- To use the new AuthServer page, replace **Index.cshtml.cs** with [AuthServer Index.cshtml.cs](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.IdentityServer/Pages/Index.cshtml) and **Index.cshtml** file with [AuthServer Index.cshtml](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.IdentityServer/Pages/Index.cshtml.cs) and rename **Ids2OpenId** with your application namespace.
> Note: It can be found under the *Pages* folder.
## Http.Api.Host
- In the **MyApplicationHttpApiHostModule.cs** `OnApplicationInitialization` method, delete `c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` in `app.UseAbpSwaggerUI` options configurations which is no longer needed.
- In `appsettings.json` delete **SwaggerClientSecret** from the *AuthServer* section like below:
```json
"AuthServer": {
"Authority": "https://localhost:44345",
"RequireHttpsMetadata": "false",
"SwaggerClientId": "MyApplication_Swagger"
},
```
## See Also
* [OpenIddict Step-by-Step Guide](OpenIddict-Step-by-Step.md)

@ -0,0 +1,229 @@
# Migrating from IdentityServer to OpenIddict Step by Step Guide
This guide provides layer-by-layer guidance for migrating your existing application to [OpenIddict](https://github.com/openiddict/openiddict-core) from IdentityServer. ABP startup templates use `OpenIddict` OpenId provider from v6.0.0-rc1 by default and `IdentityServer` projects are renamed to `AuthServer` in tiered/separated solutions. Since OpenIddict is only available with ABP v6.0, you will need to update your existing application in order to apply OpenIddict changes.
## History
We are not removing Identity Server packages and we will continue to release new versions of IdentityServer-related NuGet/NPM packages. That means you won't have an issue while upgrading to v6.0 when the stable version releases. We will continue to fix bugs in our packages for a while. ABP 7.0 will be based on .NET 7. If Identity Server continues to work with .NET 7, we will also continue to ship NuGet packages for our IDS integration.
On the other hand, Identity Server ends support for the open-source Identity Server at the end of 2022. The Identity Server team has decided to move to Duende IDS and ABP will not be migrated to the commercial Duende IDS. You can see the Duende Identity Server announcement from [this link](https://blog.duendesoftware.com/posts/20220111_fair_trade).
## OpenIddict Migration Steps
Use the `abp update` command to update your existing application. See [Upgrading docs](../Upgrading.md) for more info. Apply required migrations by following the [Migration Guides](Index.md) based on your application version.
### Domain.Shared Layer
- In **MyApplication.Domain.Shared.csproj** replace **project reference**:
```csharp
<PackageReference Include="Volo.Abp.IdentityServer.Domain.Shared" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.OpenIddict.Domain.Shared" Version="6.0.0-rc.1" />
```
- In **MyApplicationDomainSharedModule.cs** replace usings and **module dependencies:**
```csharp
using Volo.Abp.IdentityServer;
...
typeof(AbpIdentityServerDomainSharedModule)
```
with
```csharp
using Volo.Abp.OpenIddict;
...
typeof(AbpOpenIddictDomainSharedModule)
### Domain Layer
- In **MyApplication.Domain.csproj** replace **project references**:
```csharp
<PackageReference Include="Volo.Abp.IdentityServer.Domain" Version="6.0.0-rc.1" />
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.IdentityServer" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.OpenIddict.Domain" Version="6.0.0-rc.1" />
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.OpenIddict" Version="6.0.0-rc.1" />
```
- In **MyApplicationDomainModule.cs** replace usings and **module dependencies**:
```csharp
using Volo.Abp.IdentityServer;
using Volo.Abp.PermissionManagement.IdentityServer;
...
typeof(AbpIdentityServerDomainModule),
typeof(AbpPermissionManagementDomainIdentityServerModule),
```
with
```csharp
using Volo.Abp.OpenIddict;
using Volo.Abp.PermissionManagement.OpenIddict;
...
typeof(AbpOpenIddictDomainModule),
typeof(AbpPermissionManagementDomainOpenIddictModule),
```
#### OpenIddictDataSeedContributor
- Create a folder named *OpenIddict* under the Domain project and copy the [OpenIddictDataSeedContributor.cs](https://github.com/abpframework/abp-samples/blob/master/Ids2OpenId/src/Ids2OpenId.Domain/OpenIddict/OpenIddictDataSeedContributor.cs) under this folder. Rename all the `Ids2OpenId` with your project name.
- Delete *IdentityServer* folder that contains `IdentityServerDataSeedContributor.cs` which is no longer needed.
### EntityFrameworkCore Layer
If you are using MongoDB, skip this step and check the *MongoDB* layer section.
- In **MyApplication.EntityFrameworkCore.csproj** replace **project reference**:
```csharp
<PackageReference Include="Volo.Abp.IdentityServer.EntityFrameworkCore" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="6.0.0-rc.1" />
```
- In **MyApplicationEntityFrameworkCoreModule.cs** replace usings and **module dependencies**:
```csharp
using Volo.Abp.IdentityServer.EntityFrameworkCore;
...
typeof(AbpIdentityServerEntityFrameworkCoreModule),
```
with
```csharp
using Volo.Abp.OpenIddict.EntityFrameworkCore;
...
typeof(AbpOpenIddictEntityFrameworkCoreModule),
```
- In **MyApplicationDbContext.cs** replace usings and **fluent api configurations**:
```csharp
using Volo.Abp.IdentityServer.EntityFrameworkCore;
...
using Volo.Abp.OpenIddict.EntityFrameworkCore;
...
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
/* Include modules to your migration db context */
...
builder.ConfigureIdentityServer();
```
with
```csharp
using Volo.Abp.OpenIddict.EntityFrameworkCore;
...
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
/* Include modules to your migration db context */
...
builder.ConfigureOpenIddict();
```
### MongoDB Layer
If you are using EntityFrameworkCore, skip this step and check the *EntityFrameworkCore* layer section.
- In **MyApplication.MongoDB.csproj** replace **project reference**:
```csharp
<PackageReference Include="Volo.Abp.IdentityServer.MongoDB" Version="6.0.0-rc.1" />
```
with
```csharp
<PackageReference Include="Volo.Abp.OpenIddict.MongoDB" Version="6.0.0-rc.1" />
```
- In **MyApplicationMongoDbModule.cs** replace usings and **module dependencies**:
```csharp
using Volo.Abp.IdentityServer.MongoDB;
...
typeof(AbpIdentityServerMongoDbModule),
```
with
```csharp
using Volo.Abp.OpenIddict.MongoDB;
...
typeof(AbpOpenIddictMongoDbModule),
```
### DbMigrator Project
- In **MyApplication.DbMigrator.csproj** **add project reference**:
```csharp
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
```
for creating the host builder.
- In `appsettings.json` **replace IdentityServer section with OpenIddict:**
```json
"OpenIddict": {
"Applications": {
"MyApplication_Web": {
"ClientId": "MyApplication_Web",
"ClientSecret": "1q2w3e*",
"RootUrl": "https://localhost:44384"
},
"MyApplication_App": {
"ClientId": "MyApplication_App",
"RootUrl": "http://localhost:4200"
},
"MyApplication_BlazorServerTiered": {
"ClientId": "MyApplication_BlazorServerTiered",
"ClientSecret": "1q2w3e*",
"RootUrl": "https://localhost:44346"
},
"MyApplication_Swagger": {
"ClientId": "MyApplication_Swagger",
"RootUrl": "https://localhost:44391"
}
}
}
```
Replace **MyApplication** with your application name.
### UI Layer
- [Angular UI Migration](OpenIddict-Angular.md)
- [MVC/Razor UI Migration](OpenIddict-Mvc.md)
- [Blazor-Server UI Migration](OpenIddict-Blazor-Server.md)
- [Blazor-Wasm UI Migration](OpenIddict-Blazor.md)
## Source code of samples and module
* [Open source tiered & separate auth server application migrate Identity Server to OpenIddct](https://github.com/abpframework/abp-samples/tree/master/Ids2OpenId)
* [OpenIddict module document](https://docs.abp.io/en/abp/6.0/Modules/OpenIddict)
* [OpenIddict module source code](https://github.com/abpframework/abp/tree/rel-6.0/modules/openiddict)
## See Also
* [ABP Version 6.0 Migration Guide](Abp-6_0.md)

@ -9,7 +9,7 @@ While you can continue to use the standard [Bootstrap way](https://getbootstrap.
ABP Framework provides the following benefits for such a modal with a form inside it;
* **Lazy loads** the modal HTML into the page and **removes** it from the DOM once its closed. This makes easy to consume a reusable modal dialog. Also, every time you open the modal, it will be a fresh new modal, so you don't have to deal with resetting the modal content.
* **Auto-focuses** the first input of the form once the modal has been opened.
* **Auto-focuses** the first input of the form once the modal has been opened. You can also specify it using a `function` or `jquery selector`.
* Automatically determines the **form** inside a modal and posts the form via **AJAX** instead of normal page post.
* Automatically checks if the form inside the modal **has changed, but not saved**. It warns the user in this case.
* Automatically **disables the modal buttons** (save & cancel) until the AJAX operation completes.
@ -429,6 +429,7 @@ Here, the list of all available options;
* `viewUrl` (required, `string`): The URL to lazy load the HTML of the modal.
* `scriptUrl` (optional, `string`): A URL to lazy load a JavaScript file. It is loaded only once, when the modal first opened.
* `modalClass` (optional, `string`): A JavaScript class defined in the `abp.modals` namespace that can be used to execute code related to the modal.
* `focusElement` (optional, `function or string`): Specifies the element that gets focus.
### Functions

@ -1322,6 +1322,12 @@
},
{
"text": "OpenIddict",
"items": [
{
"text": "OpenIddict Migration Guide",
"path": "Migration-Guides/OpenIddict-Step-by-Step.md"
}
],
"path": "Modules/OpenIddict.md"
},
{

@ -96,21 +96,28 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f
});
_$modal.on('shown.bs.modal', function () {
//focuses first element if it's a typeable input.
var $firstVisibleInput = _$modal.find('input:not([type=hidden]):first');
if (!options.focusElement) {
//focuses first element if it's a typeable input.
var $firstVisibleInput = _$modal.find('input:not([type=hidden]):first');
_onOpenCallbacks.triggerAll(_publicApi);
_onOpenCallbacks.triggerAll(_publicApi);
if ($firstVisibleInput.hasClass("datepicker")) {
return; //don't pop-up date pickers...
}
if ($firstVisibleInput.hasClass("datepicker")) {
return; //don't pop-up date pickers...
}
var focusableInputs = ["text", "password", "email", "number", "search", "tel", "url"];
if (!focusableInputs.includes($firstVisibleInput.prop("type"))) {
return;
}
var focusableInputs = ["text", "password", "email", "number", "search", "tel", "url"];
if (!focusableInputs.includes($firstVisibleInput.prop("type"))) {
return;
}
$firstVisibleInput.focus();
$firstVisibleInput.focus();
} else if (typeof options.focusElement === 'function') {
var focusElement = options.focusElement();
focusElement.focus();
} else if (typeof options.focusElement === 'string') {
$(options.focusElement).focus();
}
});
var modalClass = abp.modals[options.modalClass];

@ -1,5 +1,6 @@
using System.IO;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using NuGet.Versioning;
using Volo.Abp.Cli.Utils;
@ -9,13 +10,13 @@ namespace Volo.Abp.Cli.ProjectModification;
public class SolutionPackageVersionFinder : ITransientDependency
{
public string Find(string solutionFile, string packagePrefix = "Volo.Abp")
public string Find(string solutionFile, string packagePrefix = "Volo.Abp", string excludedKeywords = "LeptonX")
{
var projectFilesUnderSrc = GetProjectFilesOfSolution(solutionFile);
foreach (var projectFile in projectFilesUnderSrc)
{
var content = File.ReadAllText(projectFile);
if (TryParseVersionFromCsprojViaXmlDocument(content, out var s, packagePrefix))
if (TryParseVersionFromCsprojViaXmlDocument(content, out var s, packagePrefix, excludedKeywords))
{
return s;
}
@ -24,14 +25,35 @@ public class SolutionPackageVersionFinder : ITransientDependency
return null;
}
private static bool TryParseVersionFromCsprojViaXmlDocument(string content, out string version, string packagePrefix)
private static bool TryParseVersionFromCsprojViaXmlDocument(string content, out string version, string packagePrefix, string excludedKeywords)
{
var doc = new XmlDocument() { PreserveWhitespace = true };
using (var stream = StreamHelper.GenerateStreamFromString(content))
{
doc.Load(stream);
var nodes = doc.SelectNodes($"/Project/ItemGroup/PackageReference[starts-with(@Include, '{packagePrefix}')]");
var value = nodes?[0]?.Attributes?["Version"]?.Value;
var targetNodes = new List<XmlNode>();
foreach (XmlNode node in nodes!)
{
var packageId = node!.Attributes["Include"]?.Value;
if (excludedKeywords.Split(',').Any(ek => packageId!.Contains(ek)))
{
continue;
}
targetNodes.Add(node);
}
if (!targetNodes.Any())
{
version = null;
return false;
}
var value = targetNodes.First().Attributes?["Version"]?.Value;
if (value == null)
{
version = null;
@ -43,40 +65,17 @@ public class SolutionPackageVersionFinder : ITransientDependency
}
}
public static bool TryParseVersionFromCsprojFile(string csprojContent, out string version, string packagePrefix = "Volo.Abp")
public static bool TryParseVersionFromCsprojFile(string csprojContent, out string version, string packagePrefix = "Volo.Abp", string excludedKeywords = "LeptonX")
{
try
{
var matches = Regex.Matches(csprojContent,
@"PackageReference\s*Include\s*=\s*\""" + packagePrefix + @"(.*?)\""\s*Version\s*=\s*\""(.*?)\""",
RegexOptions.IgnoreCase |
RegexOptions.IgnorePatternWhitespace |
RegexOptions.Singleline | RegexOptions.Multiline);
foreach (Match match in matches)
{
if (match.Groups.Count > 2)
{
version = match.Groups[2].Value;
return true;
}
}
}
catch
{
//ignored
}
version = null;
return false;
return TryParseVersionFromCsprojViaXmlDocument(csprojContent, out version, packagePrefix, excludedKeywords);
}
public static bool TryParseSemanticVersionFromCsprojFile(string csprojContent, out SemanticVersion version, string packagePrefix = "Volo.Abp")
public static bool TryParseSemanticVersionFromCsprojFile(string csprojContent, out SemanticVersion version, string packagePrefix = "Volo.Abp", string excludedKeywords = "LeptonX")
{
try
{
if (TryParseVersionFromCsprojFile(csprojContent, out var versionText, packagePrefix))
if (TryParseVersionFromCsprojViaXmlDocument(csprojContent, out var versionText, packagePrefix, excludedKeywords))
{
return SemanticVersion.TryParse(versionText, out version);
}
@ -90,51 +89,6 @@ public class SolutionPackageVersionFinder : ITransientDependency
return false;
}
public static bool TryFind(string solutionFile, out string version, string packagePrefix = "Volo.Abp")
{
var projectFiles = GetProjectFilesOfSolution(solutionFile);
foreach (var projectFile in projectFiles)
{
var csprojContent = File.ReadAllText(projectFile);
if (TryParseVersionFromCsprojFile(csprojContent, out var parsedVersion, packagePrefix))
{
version = parsedVersion;
return true;
}
}
version = null;
return false;
}
public static bool TryFindSemanticVersion(string solutionFile, out SemanticVersion version, string packagePrefix = "Volo.Abp")
{
var projectFiles = GetProjectFilesOfSolution(solutionFile);
foreach (var projectFile in projectFiles)
{
var csprojContent = File.ReadAllText(projectFile);
if (TryParseSemanticVersionFromCsprojFile(csprojContent, out var parsedVersion, packagePrefix))
{
version = parsedVersion;
return true;
}
}
version = null;
return false;
}
//public static bool TryFindSemanticVersion(string solutionFile, out SemanticVersion version)
//{
// if (TryFind(solutionFile, out var versionText))
// {
// return SemanticVersion.TryParse(versionText, out version);
// }
// version = null;
// return false;
//}
private static string[] GetProjectFilesOfSolution(string solutionFile)
{
var solutionDirectory = Path.GetDirectoryName(solutionFile);

@ -183,11 +183,18 @@ public class VoloNugetPackagesVersionUpdater : ITransientDependency
var versionAttribute = package.Attributes["Version"];
var currentVersion = versionAttribute.Value;
var currentSemanticVersion = SemanticVersion.Parse(currentVersion);
var isLeptonXPackage = packageId.Contains("LeptonX");
Logger.LogDebug("Checking package: \"{0}\" - Current version: {1}", packageId, currentSemanticVersion);
if (!specifiedVersion.IsNullOrWhiteSpace())
{
if (isLeptonXPackage)
{
continue;
}
if (await SpecifiedVersionExists(specifiedVersion, packageId))
{
var specifiedSemanticVersion = SemanticVersion.Parse(specifiedVersion);
@ -210,7 +217,8 @@ public class VoloNugetPackagesVersionUpdater : ITransientDependency
{
if ((includeNightlyPreviews || (currentVersion.Contains("-preview") && !switchToStable)) && !includeReleaseCandidates)
{
var latestVersion = latestMyGetVersion ?? await GetLatestVersionFromMyGet(packageId);
var latestVersion = latestMyGetVersion == null || isLeptonXPackage ?
await GetLatestVersionFromMyGet(packageId) : latestMyGetVersion;
if (currentVersion != latestVersion)
{
@ -227,11 +235,13 @@ public class VoloNugetPackagesVersionUpdater : ITransientDependency
SemanticVersion latestVersion;
if (currentSemanticVersion.IsPrerelease && !switchToStable)
{
latestVersion = latestNugetReleaseCandidateVersion ?? await _nuGetService.GetLatestVersionOrNullAsync(packageId, includeReleaseCandidates: true);
latestVersion = latestNugetReleaseCandidateVersion == null || isLeptonXPackage ?
await _nuGetService.GetLatestVersionOrNullAsync(packageId, includeReleaseCandidates: true) : latestNugetReleaseCandidateVersion;
}
else
{
latestVersion = latestNugetVersion ?? await _nuGetService.GetLatestVersionOrNullAsync(packageId, includeReleaseCandidates: includeReleaseCandidates);
latestVersion = latestNugetVersion == null || isLeptonXPackage ?
await _nuGetService.GetLatestVersionOrNullAsync(packageId, includeReleaseCandidates: includeReleaseCandidates) : latestNugetVersion;
}
if (latestVersion != null && (currentSemanticVersion < latestVersion || (currentSemanticVersion.IsPrerelease && switchToStable)))

@ -1,4 +1,6 @@
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using NuGet.Versioning;
using Volo.Abp.DependencyInjection;
@ -19,15 +21,30 @@ public class NpmHelper : ITransientDependency
public bool IsNpmInstalled()
{
var output = CmdHelper.RunCmdAndGetOutput("npm -v").Trim();
return SemanticVersion.TryParse(output, out _);
var outputLines = output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
return outputLines.Any(ol => SemanticVersion.TryParse(ol, out _));
}
public bool IsYarnAvailable()
{
var output = CmdHelper.RunCmdAndGetOutput("yarn -v").Trim();
if (!SemanticVersion.TryParse(output, out var version)){
var outputLines = output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
SemanticVersion version = null;
foreach (var outputLine in outputLines)
{
if (SemanticVersion.TryParse(outputLine, out version))
{
break;
}
}
if (version == null)
{
return false;
}
return version > SemanticVersion.Parse("1.20.0");
}

@ -19,8 +19,8 @@ public class ProjectVersionParse_Tests
"<ProjectReference Include=\"..\\Blazoor.EfCore07062034.Domain.Shared\\Blazoor.EfCore07062034.Domain.Shared.csproj\" />" +
"</ItemGroup>" +
"<ItemGroup>" +
"< PackageReference Include = \"Volo.Abp.Emailing\" Version = \"4.4.0-rc.1\" />" +
"<PackageReference Include= \"Volo.Abp.PermissionManagement.Domain.Identity\" Version= \"4.4.0-rc.1\" />" +
"<PackageReference Include=\"Volo.Abp.Emailing\" Version=\"4.4.0-rc.1\" />" +
"<PackageReference Include=\"Volo.Abp.PermissionManagement.Domain.Identity\" Version=\"4.4.0-rc.1\" />" +
"<PackageReference Include=\"Volo.Abp.IdentityServer.Domain\" Version=\"4.4.0-rc.1\" />" +
"<PackageReference Include=\"Volo.Abp.PermissionManagement.Domain.IdentityServer\" Version=\"4.4.0-rc.1\" />" +
"<PackageReference Include=\"Volo.Abp.BackgroundJobs.Domain\" Version=\"4.4.0-rc.1\" />" +
@ -54,7 +54,7 @@ public class ProjectVersionParse_Tests
"<ProjectReference Include=\"..\\Blazoor.EfCore07062034.Domain.Shared\\Blazoor.EfCore07062034.Domain.Shared.csproj\" />" +
"</ItemGroup>" +
"<ItemGroup>" +
"< PackageReference Include = \"Volo.Abp.Emailing\" Version= \"12.8.3-beta.1\" />" +
"<PackageReference Include=\"Volo.Abp.Emailing\" Version=\"12.8.3-beta.1\" />" +
"</ItemGroup>" +
"</Project>";

@ -4,5 +4,5 @@ namespace Volo.CmsKit.Web.Renderers;
public interface IMarkdownToHtmlRenderer
{
Task<string> RenderAsync(string rawMarkdown, bool preventXSS = true);
Task<string> RenderAsync(string rawMarkdown, bool allowHtmlTags = true, bool preventXSS = true);
}

@ -20,9 +20,9 @@ public class MarkdownToHtmlRenderer : IMarkdownToHtmlRenderer, ITransientDepende
_htmlSanitizer = new HtmlSanitizer();
}
public async Task<string> RenderAsync(string rawMarkdown, bool preventXSS = false)
public async Task<string> RenderAsync(string rawMarkdown, bool allowHtmlTags = true, bool preventXSS = true)
{
if (preventXSS)
if (!allowHtmlTags)
{
rawMarkdown = EncodeHtmlTags(rawMarkdown, true);
}

@ -25,7 +25,7 @@ public class EfCorePageRepository : EfCoreRepository<ICmsKitDbContext, Page, Gui
return await (await GetDbSetAsync()).WhereIf(
!filter.IsNullOrWhiteSpace(),
x =>
x.Title.Contains(filter)
x.Title.ToLower().Contains(filter.ToLower()) || x.Slug.Contains(filter)
).CountAsync(GetCancellationToken(cancellationToken));
}
@ -39,7 +39,7 @@ public class EfCorePageRepository : EfCoreRepository<ICmsKitDbContext, Page, Gui
return await (await GetDbSetAsync()).WhereIf(
!filter.IsNullOrWhiteSpace(),
x =>
x.Title.Contains(filter))
x.Title.ToLower().Contains(filter.ToLower()) || x.Slug.Contains(filter))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(Page.Title) : sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));

@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using JetBrains.Annotations;
using MongoDB.Driver;
using Volo.Abp;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.CmsKit.Pages;
@ -30,7 +30,7 @@ public class MongoPageRepository : MongoDbRepository<ICmsKitMongoDbContext, Page
.WhereIf<Page, IMongoQueryable<Page>>(
!filter.IsNullOrWhiteSpace(),
u =>
u.Title.Contains(filter)
u.Title.ToLower().Contains(filter) || u.Slug.Contains(filter)
).CountAsync(cancellation);
}
@ -46,9 +46,7 @@ public class MongoPageRepository : MongoDbRepository<ICmsKitMongoDbContext, Page
return await (await GetMongoQueryableAsync(cancellation))
.WhereIf<Page, IMongoQueryable<Page>>(
!filter.IsNullOrWhiteSpace(),
u =>
u.Title.Contains(filter)
)
u => u.Title.ToLower().Contains(filter) || u.Slug.Contains(filter))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(Page.Title) : sorting)
.As<IMongoQueryable<Page>>()
.PageBy<Page, IMongoQueryable<Page>>(skipCount, maxResultCount)

@ -65,12 +65,12 @@ public class CommentingViewComponent : AbpViewComponent
foreach (var comment in viewModel.Comments)
{
viewModel.RawCommentTexts.Add(comment.Id, comment.Text);
comment.Text = await MarkdownToHtmlRenderer.RenderAsync(comment.Text, true);
comment.Text = await MarkdownToHtmlRenderer.RenderAsync(comment.Text, allowHtmlTags: false, preventXSS: true);
foreach (var reply in comment.Replies)
{
viewModel.RawCommentTexts.Add(reply.Id, reply.Text);
reply.Text = await MarkdownToHtmlRenderer.RenderAsync(reply.Text, true);
reply.Text = await MarkdownToHtmlRenderer.RenderAsync(reply.Text, allowHtmlTags: false, preventXSS: true);
}
}
}

Loading…
Cancel
Save