mirror of https://github.com/abpframework/abp.git
1194 changed files with 30942 additions and 8604 deletions
@ -1,165 +1,89 @@ |
|||
GNU LESSER GENERAL PUBLIC LICENSE |
|||
Version 3, 29 June 2007 |
|||
|
|||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
|||
Everyone is permitted to copy and distribute verbatim copies |
|||
of this license document, but changing it is not allowed. |
|||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
|||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. |
|||
|
|||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public. |
|||
The license is supplemented by the additional permissions listed below. |
|||
|
|||
This version of the GNU Lesser General Public License incorporates |
|||
the terms and conditions of version 3 of the GNU General Public |
|||
License, supplemented by the additional permissions listed below. |
|||
|
|||
0. Additional Definitions. |
|||
|
|||
As used herein, "this License" refers to version 3 of the GNU Lesser |
|||
General Public License, and the "GNU GPL" refers to version 3 of the GNU |
|||
General Public License. |
|||
**0. Additional Definitions.** |
|||
|
|||
As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. |
|||
|
|||
"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. |
|||
|
|||
An "Application" is any work that makes use of an interface provided by the Library but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. |
|||
|
|||
A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". |
|||
|
|||
The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application and not on the Linked Version. |
|||
|
|||
The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. |
|||
|
|||
|
|||
|
|||
**1. Exception to Section 3 of the GNU GPL.** |
|||
|
|||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. |
|||
|
|||
|
|||
|
|||
**2. Conveying Modified Versions.** |
|||
|
|||
If you modify a copy of the Library and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: |
|||
|
|||
**a)** under this License, provided that you make a good-faith effort to ensure that, in the event an Application does not supply the |
|||
function or data, the facility still operates and performs whatever part of its purpose remains meaningful, or |
|||
|
|||
**b)** under the GNU GPL, with none of the additional permissions of this License is applicable to that copy. |
|||
|
|||
|
|||
|
|||
**3. Object Code Incorporating Material from Library Header Files.** |
|||
|
|||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such an object code under terms of your choice, provided that if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: |
|||
|
|||
**a)** Give prominent notice with each copy of the object code that the Library is used in it, and the Library and its use are covered by this License. |
|||
|
|||
**b)** Accompany the object code with a copy of the GNU GPL and this license document. |
|||
|
|||
|
|||
|
|||
**4. Combined Works.** |
|||
|
|||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: |
|||
|
|||
**a)** Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. |
|||
|
|||
**b)** Accompany the Combined Work with a copy of the GNU GPL and this license document. |
|||
|
|||
**c)** For a Combined Work that displays copyright notices during execution, including the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. |
|||
|
|||
**d)** Do one of the following: |
|||
|
|||
0) Convey the Minimal Corresponding Source under the terms of this License and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. |
|||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. |
|||
|
|||
**e)** Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying the Corresponding Source.) |
|||
|
|||
|
|||
"The Library" refers to a covered work governed by this License, |
|||
other than an Application or a Combined Work as defined below. |
|||
|
|||
An "Application" is any work that makes use of an interface provided |
|||
by the Library, but which is not otherwise based on the Library. |
|||
Defining a subclass of a class defined by the Library is deemed a mode |
|||
of using an interface provided by the Library. |
|||
|
|||
A "Combined Work" is a work produced by combining or linking an |
|||
Application with the Library. The particular version of the Library |
|||
with which the Combined Work was made is also called the "Linked |
|||
Version". |
|||
|
|||
The "Minimal Corresponding Source" for a Combined Work means the |
|||
Corresponding Source for the Combined Work, excluding any source code |
|||
for portions of the Combined Work that, considered in isolation, are |
|||
based on the Application, and not on the Linked Version. |
|||
|
|||
The "Corresponding Application Code" for a Combined Work means the |
|||
object code and/or source code for the Application, including any data |
|||
and utility programs needed for reproducing the Combined Work from the |
|||
Application, but excluding the System Libraries of the Combined Work. |
|||
|
|||
1. Exception to Section 3 of the GNU GPL. |
|||
|
|||
You may convey a covered work under sections 3 and 4 of this License |
|||
without being bound by section 3 of the GNU GPL. |
|||
|
|||
2. Conveying Modified Versions. |
|||
|
|||
If you modify a copy of the Library, and, in your modifications, a |
|||
facility refers to a function or data to be supplied by an Application |
|||
that uses the facility (other than as an argument passed when the |
|||
facility is invoked), then you may convey a copy of the modified |
|||
version: |
|||
|
|||
a) under this License, provided that you make a good faith effort to |
|||
ensure that, in the event an Application does not supply the |
|||
function or data, the facility still operates, and performs |
|||
whatever part of its purpose remains meaningful, or |
|||
|
|||
b) under the GNU GPL, with none of the additional permissions of |
|||
this License applicable to that copy. |
|||
|
|||
3. Object Code Incorporating Material from Library Header Files. |
|||
|
|||
The object code form of an Application may incorporate material from |
|||
a header file that is part of the Library. You may convey such object |
|||
code under terms of your choice, provided that, if the incorporated |
|||
material is not limited to numerical parameters, data structure |
|||
layouts and accessors, or small macros, inline functions and templates |
|||
(ten or fewer lines in length), you do both of the following: |
|||
|
|||
a) Give prominent notice with each copy of the object code that the |
|||
Library is used in it and that the Library and its use are |
|||
covered by this License. |
|||
|
|||
b) Accompany the object code with a copy of the GNU GPL and this license |
|||
document. |
|||
|
|||
4. Combined Works. |
|||
|
|||
You may convey a Combined Work under terms of your choice that, |
|||
taken together, effectively do not restrict modification of the |
|||
portions of the Library contained in the Combined Work and reverse |
|||
engineering for debugging such modifications, if you also do each of |
|||
the following: |
|||
|
|||
a) Give prominent notice with each copy of the Combined Work that |
|||
the Library is used in it and that the Library and its use are |
|||
covered by this License. |
|||
|
|||
b) Accompany the Combined Work with a copy of the GNU GPL and this license |
|||
document. |
|||
|
|||
c) For a Combined Work that displays copyright notices during |
|||
execution, include the copyright notice for the Library among |
|||
these notices, as well as a reference directing the user to the |
|||
copies of the GNU GPL and this license document. |
|||
|
|||
d) Do one of the following: |
|||
|
|||
0) Convey the Minimal Corresponding Source under the terms of this |
|||
License, and the Corresponding Application Code in a form |
|||
suitable for, and under terms that permit, the user to |
|||
recombine or relink the Application with a modified version of |
|||
the Linked Version to produce a modified Combined Work, in the |
|||
manner specified by section 6 of the GNU GPL for conveying |
|||
Corresponding Source. |
|||
|
|||
1) Use a suitable shared library mechanism for linking with the |
|||
Library. A suitable mechanism is one that (a) uses at run time |
|||
a copy of the Library already present on the user's computer |
|||
system, and (b) will operate properly with a modified version |
|||
of the Library that is interface-compatible with the Linked |
|||
Version. |
|||
|
|||
e) Provide Installation Information, but only if you would otherwise |
|||
be required to provide such information under section 6 of the |
|||
GNU GPL, and only to the extent that such information is |
|||
necessary to install and execute a modified version of the |
|||
Combined Work produced by recombining or relinking the |
|||
Application with a modified version of the Linked Version. (If |
|||
you use option 4d0, the Installation Information must accompany |
|||
the Minimal Corresponding Source and Corresponding Application |
|||
Code. If you use option 4d1, you must provide the Installation |
|||
Information in the manner specified by section 6 of the GNU GPL |
|||
for conveying Corresponding Source.) |
|||
|
|||
5. Combined Libraries. |
|||
|
|||
You may place library facilities that are a work based on the |
|||
Library side by side in a single library together with other library |
|||
facilities that are not Applications and are not covered by this |
|||
License, and convey such a combined library under terms of your |
|||
choice, if you do both of the following: |
|||
|
|||
a) Accompany the combined library with a copy of the same work based |
|||
on the Library, uncombined with any other library facilities, |
|||
conveyed under the terms of this License. |
|||
|
|||
b) Give prominent notice with the combined library that part of it |
|||
is a work based on the Library, and explaining where to find the |
|||
accompanying uncombined form of the same work. |
|||
|
|||
6. Revised Versions of the GNU Lesser General Public License. |
|||
|
|||
The Free Software Foundation may publish revised and/or new versions |
|||
of the GNU Lesser General Public License from time to time. Such new |
|||
versions will be similar in spirit to the present version, but may |
|||
differ in detail to address new problems or concerns. |
|||
|
|||
Each version is given a distinguishing version number. If the |
|||
Library as you received it specifies that a certain numbered version |
|||
of the GNU Lesser General Public License "or any later version" |
|||
applies to it, you have the option of following the terms and |
|||
conditions either of that published version or of any later version |
|||
published by the Free Software Foundation. If the Library as you |
|||
received it does not specify a version number of the GNU Lesser |
|||
General Public License, you may choose any version of the GNU Lesser |
|||
General Public License ever published by the Free Software Foundation. |
|||
|
|||
If the Library as you received it specifies that a proxy can decide |
|||
whether future versions of the GNU Lesser General Public License shall |
|||
apply, that proxy's public statement of acceptance of any version is |
|||
permanent authorization for you to choose that version for the |
|||
Library. |
|||
You may place library facilities that are work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License and convey such a combined library under the terms of your choice if you do both of the following: |
|||
|
|||
**a)** Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. |
|||
|
|||
**b)** Give prominent notice with the combined library that part of it is a work based on the Library and explains where to find the accompanying uncombined form of the same work. |
|||
|
|||
|
|||
|
|||
**6. Revised Versions of the GNU Lesser General Public License.** |
|||
|
|||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version but may differ in detail to address new problems or concerns. |
|||
|
|||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received, it does not specify a version number of the GNU Lesser |
|||
General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. |
|||
|
|||
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
@ -0,0 +1,123 @@ |
|||
# CMS Kit: Marked Item System |
|||
|
|||
CMS kit provides a marking system to mark any kind of resource, like a blog post or a product, as a favorite, starred, flagged, or bookmarked. |
|||
|
|||
Marked toggling component allows users to mark your items via pre-defined icons/emojis. Here how the marked toggling components may look like: |
|||
|
|||
 |
|||
|
|||
|
|||
you can also customize the marking icons shown in the toggling components. |
|||
|
|||
## Enabling the Marked Item Feature |
|||
|
|||
By default, CMS Kit features are disabled. Therefore, you need to enable the features you want, before starting to use it. You can use the [Global Feature](../../Global-Features.md) system to enable/disable CMS Kit features on development time. Alternatively, you can use the ABP Framework's [Feature System](https://docs.abp.io/en/abp/latest/Features) to disable a CMS Kit feature on runtime. |
|||
|
|||
> Check the ["How to Install" section of the CMS Kit Module documentation](Index.md#how-to-install) to see how to enable/disable CMS Kit features on development time. |
|||
|
|||
## Options |
|||
|
|||
Marking system provides a simple approach to define your entity type with mark types like favorite or starred. For example, if you want to use the marking system for products, you need to define an entity type named `product` with the icon name. |
|||
|
|||
`CmsKitMarkedItemOptions` can be configured in YourModule.cs, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example: |
|||
|
|||
```csharp |
|||
Configure<CmsKitMarkedItemOptions>(options => |
|||
{ |
|||
options.EntityTypes.Add( |
|||
new MarkedItemEntityTypeDefinition( |
|||
"product", |
|||
StandardMarkedItems.Favorite |
|||
) |
|||
); |
|||
}); |
|||
``` |
|||
|
|||
`CmsKitMarkedItemOptions` properties: |
|||
|
|||
- `EntityTypes`: List of defined entity types (`CmsKitMarkedItemOptions`) in the marking system. |
|||
|
|||
`MarkedItemEntityTypeDefinition` properties: |
|||
|
|||
- `EntityType`: Name of the entity type. |
|||
- `IconName`: The name of the icon. |
|||
|
|||
## The Marked Item widget |
|||
|
|||
The marking system provides a toggle widget to allow users to add/remove the marks from an item. You can place the widget with the item as shown below: |
|||
|
|||
``` csharp |
|||
@await Component.InvokeAsync(typeof (MarkedItemToggleViewComponent), new |
|||
{ |
|||
entityId = "...", |
|||
entityType = "product", |
|||
needsConfirmation = true // (optional) |
|||
}) |
|||
``` |
|||
* `entityType` was explained in the previous section. |
|||
* `entityId` should be the unique id of the product, in this example. If you have a Product entity, you can use its Id here. |
|||
* `needsConfirmation` An optional parameter to let the user confirm when removing the mark. |
|||
|
|||
# Internals |
|||
|
|||
## Domain Layer |
|||
|
|||
#### Aggregates |
|||
|
|||
This module follows the [Entity Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Entities) guide. |
|||
|
|||
##### UserMarkedItem |
|||
|
|||
A user markedItem represents a user has marking on the item. |
|||
|
|||
- `UserMarkedItem` (aggregate root): Represents a marked item in the system. |
|||
|
|||
#### Repositories |
|||
|
|||
This module follows the [Repository Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Repositories) guide. |
|||
|
|||
Following custom repositories are defined for this feature: |
|||
|
|||
- `IUserMarkedItemRepository` |
|||
|
|||
|
|||
#### Domain services |
|||
|
|||
This module follows the [Domain Services Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Domain-Services) guide. |
|||
|
|||
##### Marked Item Manager |
|||
|
|||
`MarkedItemManager` is used to perform some operations for the `UserMarkedItem` aggregate root. |
|||
|
|||
### Application layer |
|||
|
|||
#### Application services |
|||
|
|||
- `MarkedItemPublicAppService` (implements `IMarkedItemPublicAppService`): Implements the use cases of marking system. |
|||
|
|||
### Database providers |
|||
|
|||
#### Common |
|||
|
|||
##### Table / collection prefix & schema |
|||
|
|||
All tables/collections use the `Cms` prefix by default. Set static properties on the `CmsKitDbProperties` class if you need to change the table prefix or set a schema name (if supported by your database provider). |
|||
|
|||
##### Connection string |
|||
|
|||
This module uses `CmsKit` for the connection string name. If you don't define a connection string with this name, it fallbacks to the `Default` connection string. |
|||
|
|||
See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-Strings) documentation for details. |
|||
|
|||
#### Entity Framework Core |
|||
|
|||
##### Tables |
|||
|
|||
- CmsUserMarkedItems |
|||
|
|||
#### MongoDB |
|||
|
|||
##### Collections |
|||
|
|||
- **CmsUserMarkedItems** |
|||
|
|||
@ -0,0 +1,68 @@ |
|||
# ABP Version 8.3 Migration Guide |
|||
|
|||
This document is a guide for upgrading ABP v8.x solutions to ABP v8.3. There are some changes in this version that may affect your applications, please read it carefully and apply the necessary changes to your application. |
|||
|
|||
## Open-Source (Framework) |
|||
|
|||
### Added `AdminUserName` parameter to `IIdentityDataSeeder.SeedAsync` method |
|||
|
|||
Prior to this version, `IIdentityDataSeeder.SeedAsync` was used to seed the initial user data with the `admin` as the username, to be able to easily test all applications with all permissions granted. |
|||
|
|||
In this version on, we allow you to set the default **adminUserName**. So, you can set the default user name to any name you want or leave it as it is and let the username be `admin` as before. |
|||
|
|||
For example, in the `MyProjectNameDbMigrationService.SeedDataAsync` method (under the domain project's **Data** folder), you can pass the username as below: |
|||
|
|||
```diff |
|||
private async Task SeedDataAsync(Tenant? tenant = null) |
|||
{ |
|||
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
|||
|
|||
await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id) |
|||
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue) |
|||
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue) |
|||
+ .WithProperty(IdentityDataSeedContributor.AdminUserNamePropertyName, "your-admin-user-name") |
|||
); |
|||
} |
|||
``` |
|||
|
|||
Normally, you don't need to make any changes in your code related to this change. However, if you used the `IIdentityDataSeeder.SeedAsync` method in your application, now also gets additional (and optional) `adminUserName` parameter that you can pass the value on. |
|||
|
|||
See the PR for more info: https://github.com/abpframework/abp/pull/20131/ |
|||
|
|||
### Docs Module: Improvements & Single Project Mode Support |
|||
|
|||
In this version, we made some improvements in the [Docs Module](../../modules/docs.md) and introduced single project mode, which allows you to use a single project name for all of your documents. |
|||
|
|||
While implementing this new feature, we made some small changes to the existing classes. For example, the constructor methods of the following classes have been changed, and need to be updated in your code, if you use them: |
|||
|
|||
* `TreeTagHelper.cs`: https://github.com/abpframework/abp/pull/19419/files#diff-e0fb91c1b564d61dedf9dfc60d08e7e0af57b433797fcb3bd664f3fd4768ea0d |
|||
|
|||
* `MarkdownDocumentToHtmlConverter.cs`: https://github.com/abpframework/abp/pull/19419/files#diff-948e25b2d8851576888f8053b5f2c9416e23576aff95a88ef8ec8ca2841b3622 |
|||
|
|||
See the PR for more info: https://github.com/abpframework/abp/pull/19419 |
|||
|
|||
### Updated `datatables.net` to 2.0.2 |
|||
|
|||
In this version, the `datatables.net` library version was updated from v1.11.4 to v2.0.2. We made all related changes at the framework level and updated the dependency and its resource mapping configurations. Also, we made it backward compatible so it should not directly affect your application. |
|||
|
|||
However, notice this package is used by the `@abp/aspnetcore.mvc.ui.theme.shared` package, which is used by the official themes. Therefore, if you used any methods from the **datatables.net** library it might be already deprecated or removed. |
|||
|
|||
See the PR for more info: https://github.com/abpframework/abp/pull/19340 |
|||
|
|||
### Angular UI |
|||
|
|||
We wish to formally inform you that ABP version 8.3 has been upgraded to incorporate Angular version 18. Consequently, we recommend migrating your application to [Angular v18](https://angular.dev/update-guide) to ensure compatibility. |
|||
|
|||
## PRO |
|||
|
|||
> Please check the **Open-Source (Framework)** section before reading this section. The listed topics might affect your application and you might need to take care of them. |
|||
|
|||
If you are a paid-license owner and using the ABP's paid version, then please follow the following sections to get informed about the breaking changes and apply the necessary ones: |
|||
|
|||
### Added RegEx Support to CMS Kit's (PRO) URL Forwarding System |
|||
|
|||
ABP provides a [URL Forwarding System](../../modules/cms-kit-pro/url-forwarding.md), which allows you to create URLs that redirect to other pages or external websites. Prior to this version, the URL Forwarding System was only working for static URLs and didn't support RegEx. In this version, we introduced the RegEx support for the URL Forwarding System and now you can pass regular expressions for not static URLs. |
|||
|
|||
Since a new property has been added to the `CmsShortenedUrl` entity, you should create a new migration and apply it to your database. |
|||
|
|||
> After creating a new migration and applying it to your database, typically you don't need to make any changes, however, if you have overridden a page/method or class related to the URL Forwarding System, you might need to update it accordingly. For this purpose, you can get the source code of the [CMS Kit Module's](../../modules/cms-kit-pro/index.md) and update the related parts in your application. |
|||
|
After Width: | Height: | Size: 54 KiB |
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Authentication; |
|||
|
|||
public class AbpAspNetCoreTokenUnauthorizedErrorInfo : IScopedDependency |
|||
{ |
|||
public string? Error { get; set; } |
|||
|
|||
public string? ErrorDescription { get; set; } |
|||
|
|||
public string? ErrorUri { get; set; } |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.Libs; |
|||
|
|||
public class AbpMvcLibsOptions |
|||
{ |
|||
public bool CheckLibs { get; set; } |
|||
} |
|||
@ -0,0 +1,93 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using Microsoft.Extensions.FileProviders; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Libs; |
|||
|
|||
public class AbpMvcLibsService : IAbpMvcLibsService, ITransientDependency |
|||
{ |
|||
private Task<bool>? _checkLibsTask; |
|||
|
|||
public virtual void CheckLibs(ApplicationInitializationContext context) |
|||
{ |
|||
var options = context.ServiceProvider.GetRequiredService<IOptions<AbpMvcLibsOptions>>().Value; |
|||
if (options.CheckLibs) |
|||
{ |
|||
var app = context.GetApplicationBuilderOrNull(); |
|||
if (app == null) |
|||
{ |
|||
var logger = context.ServiceProvider.GetRequiredService<ILogger<AbpMvcLibsService>>(); |
|||
logger.LogWarning($"The {nameof(IApplicationBuilder)} is not available. The 'CheckLibs' feature is disabled!"); |
|||
return; |
|||
} |
|||
|
|||
app.Use(async (httpContext, next) => |
|||
{ |
|||
if (!await CheckLibsAsyncOnceAsync(httpContext)) |
|||
{ |
|||
httpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; |
|||
httpContext.Response.ContentType = "text/html"; |
|||
await httpContext.Response.WriteAsync( |
|||
"<html>" + |
|||
" <head>" + |
|||
" <title>Error - The Libs folder is missing!</title>" + |
|||
" </head>" + |
|||
" <body>" + |
|||
" <h1> ⚠️ The Libs folder under the <code style='background-color: #e7e7e7;'>wwwroot/libs</code> directory is empty!</h1>" + |
|||
" <p>The Libs folder contains mandatory NPM Packages for running the project.</p>" + |
|||
" <p>Make sure you run the <code style='background-color: #e7e7e7;'>abp install-libs</code> CLI tool command.</p>" + |
|||
" <p>For more information, check out the <a href='https://abp.io/docs/latest/CLI#install-libs'>ABP CLI documentation</a></p>" + |
|||
" </body>" + |
|||
"</html>", |
|||
Encoding.UTF8 |
|||
); |
|||
return; |
|||
} |
|||
|
|||
await next(httpContext); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
protected virtual Task<bool> CheckLibsAsyncOnceAsync(HttpContext httpContext) |
|||
{ |
|||
if (_checkLibsTask == null) |
|||
{ |
|||
_checkLibsTask = CheckLibsAsync(httpContext); |
|||
} |
|||
|
|||
return _checkLibsTask; |
|||
} |
|||
|
|||
protected virtual Task<bool> CheckLibsAsync(HttpContext httpContext) |
|||
{ |
|||
var logger = httpContext.RequestServices.GetRequiredService<ILogger<AbpMvcLibsService>>(); |
|||
try |
|||
{ |
|||
var fileProvider = new PhysicalFileProvider(httpContext.RequestServices.GetRequiredService<IWebHostEnvironment>().WebRootPath); |
|||
var libsFolder = fileProvider.GetDirectoryContents("/libs"); |
|||
if (!libsFolder.Exists || !libsFolder.Any()) |
|||
{ |
|||
logger.LogError("The 'wwwroot/libs' folder does not exist or empty!"); |
|||
return Task.FromResult(false); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// In case of any exception, log it and return true to prevent crashing the application.
|
|||
logger.LogError(e, "An error occurred while checking the libs folder!"); |
|||
} |
|||
|
|||
return Task.FromResult(true); |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.Libs; |
|||
|
|||
public interface IAbpMvcLibsService |
|||
{ |
|||
void CheckLibs(ApplicationInitializationContext context); |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System.Linq; |
|||
using System.Security.Claims; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authentication; |
|||
using Microsoft.Extensions.Options; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Security.Claims; |
|||
|
|||
public class AbpClaimsTransformation : IClaimsTransformation |
|||
{ |
|||
protected IOptions<AbpClaimsMapOptions> AbpClaimsMapOptions { get; } |
|||
|
|||
public AbpClaimsTransformation(IOptions<AbpClaimsMapOptions> abpClaimsMapOptions) |
|||
{ |
|||
AbpClaimsMapOptions = abpClaimsMapOptions; |
|||
} |
|||
|
|||
public virtual Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal) |
|||
{ |
|||
var mapClaims = principal.Claims.Where(claim => AbpClaimsMapOptions.Value.Maps.Keys.Contains(claim.Type)); |
|||
|
|||
principal.AddIdentity(new ClaimsIdentity(mapClaims.Select( |
|||
claim => new Claim( |
|||
AbpClaimsMapOptions.Value.Maps[claim.Type](), |
|||
claim.Value, |
|||
claim.ValueType, |
|||
claim.Issuer |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
return Task.FromResult(principal); |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue