mirror of https://github.com/abpframework/abp.git
committed by
GitHub
958 changed files with 6414 additions and 3498 deletions
@ -1,11 +1,32 @@ |
|||
## Abp.io platform localization |
|||
## ABP Platform Websites Localization |
|||
|
|||
This project is all localized resources of the abp.io platform. |
|||
This is the localization project of [abp.io platform](https://abp.io). |
|||
All *.abp.io websites are built on top of ABP Framework, and it uses ABP Framework's localization system. |
|||
You can correct a wrong localization text, or you can translate it into your own language. |
|||
By doing so, [abp.io](https://abp.io) websites will be translated into a new language and it will help to expand the ABP Community. |
|||
|
|||
If you like, you can contribute to the localization resources in this project. |
|||
|
|||
For example: `AbpIoLocalization\AbpIoLocalization\Www\Localization\Resources\zh-Hans.json` |
|||
If the file is missing some translations or the translation is wrong, you can add it. |
|||
If the language file is missing (eg `kr.json`), you can also add it. |
|||
|
|||
Please refer to the [Contribution Guide](https://github.com/abpframework/abp/blob/dev/docs/en/Contribution/Index.md) for details. |
|||
## How to Translate abp.io Into Your Language: |
|||
|
|||
1. Install [ABP CLI](https://docs.abp.io/en/abp/latest/CLI) command line tool. |
|||
|
|||
2. Run the following command to generate the localization file. |
|||
For example, for translating from English to French `fr`: |
|||
|
|||
```bash |
|||
abp translate -c fr |
|||
``` |
|||
3. After you fill in the empty localization keys, run the following command to apply it. |
|||
```bash |
|||
abp translate -a |
|||
``` |
|||
4. Send your PR to the team; after the review process, we wil merge it. |
|||
|
|||
--- |
|||
|
|||
|
|||
|
|||
## References: |
|||
* [ABP CLI Translate Command](https://docs.abp.io/en/abp/latest/Contribution/Index#using-the-abp-translate-command) |
|||
* [Contribution Guide](https://github.com/abpframework/abp/blob/dev/docs/en/Contribution/Index.md) |
|||
|
|||
@ -0,0 +1,95 @@ |
|||
# Upgrade Your Existing Projects to .NET 8 & ABP 8.0 |
|||
|
|||
A new .NET version was released on November 14, 2023 and ABP 8.0 RC.1 shipped based on .NET 8.0 just after Microsoft's .NET 8.0 release. Therefore, it's a good time to see what we need to do to upgrade our existing projects to .NET 8.0. |
|||
|
|||
Despite all the related dependency upgrades and changes made on ABP Framework and ABP Commercial sides, we still need to make some changes. Let's see the required actions that need to be taken in the following sections. |
|||
|
|||
## Installing the .NET 8.0 SDK |
|||
|
|||
To get started with ASP.NET Core in .NET 8.0, you need to install the .NET 8 SDK. You can install it at [https://dotnet.microsoft.com/en-us/download/dotnet/8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0). |
|||
|
|||
After installing the SDK & Runtime, you can upgrade your existing ASP.NET Core application to .NET 8.0. |
|||
|
|||
## Updating the Target Framework |
|||
|
|||
First, you need to update all your `*.csproj` files to support .NET 8. Find and replace all your `TargetFramework` definitions in the `*.csproj` files to support .NET 8.0: |
|||
|
|||
```xml |
|||
<TargetFramework>net8.0</TargetFramework> |
|||
``` |
|||
|
|||
> This and all other changes mentioned in this article have already been done in the ABP Framework and ABP Commercial side, so you would not get any problems related to that. |
|||
|
|||
## Updating Microsoft Package Versions |
|||
|
|||
You are probably using some Microsoft packages in your solution, so you need to update them to the latest .NET 8.0 version. Therefore, update all `Microsoft.AspNetCore.*` and `Microsoft.Extensions.*` packages' references to `8.0.0`. |
|||
|
|||
## Checking the Breaking Changes in .NET 8.0 |
|||
|
|||
As I have mentioned earlier in this article, on the ABP Framework & ABP Commercial sides all the related code changes have been made, so you would not get any error related to breaking changes introduced with .NET 8.0. However, you still need to check the [Breaking Changes in .NET 8.0 documentation](https://learn.microsoft.com/en-us/dotnet/core/compatibility/8.0), because the breaking changes listed in this documentation still might affect you. Therefore, read them accordingly and make the related changes in your application, if needed. |
|||
|
|||
## Update Your Global Dotnet CLI Tools (optional) |
|||
|
|||
You can update the global dotnet tools to the latest version by running the `dotnet tool update` command. For example, if you are using EF Core, you can update your `dotnet-ef` CLI tool with the following command: |
|||
|
|||
```bash |
|||
dotnet tool update dotnet-ef --global |
|||
``` |
|||
|
|||
## Installing/Restoring the Workloads (required for Blazor WASM & MAUI apps) |
|||
|
|||
The `dotnet workload restore` command installs the workloads needed for a project or a solution. This command analyzes a project or solution to determine which workloads are needed and if you have a .NET MAUI or Blazor-WASM project, you can update your workloads by running the following command in a terminal: |
|||
|
|||
```bash |
|||
dotnet workload restore |
|||
``` |
|||
|
|||
## Docker Image Updates |
|||
|
|||
If you are using Docker to automate the deployment of applications, you also need to update your images. |
|||
|
|||
For example, you can update the ASP.NET Core image as follows: |
|||
|
|||
```diff |
|||
- FROM mcr.microsoft.com/dotnet/aspnet:7.0-bullseye-slim AS base |
|||
+ FROM mcr.microsoft.com/dotnet/aspnet:8.0-bullseye-slim AS base |
|||
``` |
|||
|
|||
You can check the related images from Docker Hub and update them accordingly: |
|||
|
|||
* [https://hub.docker.com/_/microsoft-dotnet-aspnet/](https://hub.docker.com/_/microsoft-dotnet-aspnet/) |
|||
* [https://hub.docker.com/_/microsoft-dotnet-sdk/](https://hub.docker.com/_/microsoft-dotnet-sdk/) |
|||
* [https://hub.docker.com/_/microsoft-dotnet-runtime/](https://hub.docker.com/_/microsoft-dotnet-runtime/) |
|||
|
|||
## Upgrading Your Existing Projects to ABP 8.0 |
|||
|
|||
Updating your application to ABP 8.0 is pretty straight-forward. You first need to upgrade the ABP CLI to version `8.0.0-rc.1` using a command line terminal: |
|||
|
|||
````bash |
|||
dotnet tool update Volo.Abp.Cli -g --version 8.0.0-rc.1 |
|||
```` |
|||
|
|||
**or install** it if you haven't before: |
|||
|
|||
````bash |
|||
dotnet tool install Volo.Abp.Cli -g --version 8.0.0-rc.1 |
|||
```` |
|||
|
|||
Then, you can use the `abp update` command to update all the ABP related NuGet and NPM packages in your solution: |
|||
|
|||
```bash |
|||
abp update --version 8.0.0-rc.1 |
|||
``` |
|||
|
|||
After that, you need to check the migration guide documents, listed below: |
|||
|
|||
* [ABP Framework 7.x to 8.0 Migration Guide](https://docs.abp.io/en/abp/8.0/Migration-Guides/Abp-8_0) |
|||
* [ABP Commercial 7.x to 8.0 Migration Guide](https://docs.abp.io/en/commercial/8.0/migration-guides/v8_0) |
|||
|
|||
> Check these documents carefully and make the related changes in your solution to prevent errors. |
|||
|
|||
## Final Words |
|||
|
|||
That's it! These were all the related steps that need to be taken to upgrade your application to .NET 8 and ABP 8.0. Now, you can enjoy the .NET 8 & ABP 8.0 and benefit from the performance improvements and new features. |
|||
|
|||
Happy Coding 🤗 |
|||
@ -0,0 +1,92 @@ |
|||
# Dynamic Claims |
|||
|
|||
When a client authenticates and obtains an access token or an authentication cookie, the claims in that token or cookie are not changed unless it re-authenticates. For most of the claims, that may not be a problem since claims are not frequently changing values. However, some claims may be changed and these changes should be reflected to the current session immediately. For example, we can revoke a role from a user and that should be immediately effective, otherwise user will continue to use that role's permissions until re-login to the application. |
|||
|
|||
ABP's dynamic claims feature is used to automatically and dynamically override the configured claim values in the client's authentication token/cookie by the latest values of these claims. |
|||
|
|||
## How to Use |
|||
|
|||
This feature is disabled by default. You should enable it for your application and use the Dynamic Claims middleware. |
|||
|
|||
> **Beginning from the v8.0, all the [startup templates](Startup-Templates/Index.md) are pre-configured and the dynamic claims feature is enabled by default. So, if you have created a solution with v8.0 and above, you don't need to make any configuration. Follow the instructions only if you've upgraded from a version lower than 8.0.** |
|||
|
|||
### Enabling the Dynamic Claims |
|||
|
|||
You can enable it by the following code: |
|||
|
|||
````csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => |
|||
{ |
|||
options.IsDynamicClaimsEnabled = true; |
|||
}); |
|||
} |
|||
```` |
|||
|
|||
This is typically done on the authentication server. In a monolith application, you will typically have a single application, so you can configure it. If you are using the tiered solution structure (where the UI part is hosted in a separate application) you will need to also set the `RemoteRefreshUrl` to the Authentication Server's URL in the UI application. Example: |
|||
|
|||
````csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => |
|||
{ |
|||
options.IsDynamicClaimsEnabled = true; |
|||
options.RemoteRefreshUrl = configuration["AuthServerUrl"] + options.RemoteRefreshUrl; |
|||
}); |
|||
} |
|||
```` |
|||
|
|||
> The `RemoteRefreshUrl` is already configured inside methods `AddAbpOpenIdConnect` and `AddAbpJwtBearer`. |
|||
|
|||
|
|||
### The Dynamic Claims Middleware |
|||
|
|||
Add the `DynamicClaims` middleware to all the applications that performs authentication (including the authentication server): |
|||
|
|||
````csharp |
|||
public override void OnApplicationInitialization( |
|||
ApplicationInitializationContext context) |
|||
{ |
|||
//... |
|||
app.UseDynamicClaims(); // Add this line before UseAuthorization. |
|||
app.UseAuthorization(); |
|||
//... |
|||
} |
|||
```` |
|||
|
|||
## How It Works |
|||
|
|||
The `DynamicClaims` middleware will use `IAbpClaimsPrincipalFactory` to dynamically generate claims for the current user(`HttpContext.User`) in each request. |
|||
|
|||
There are three pre-built implementations of `IAbpDynamicClaimsPrincipalContributor` for different scenarios: |
|||
|
|||
* `IdentityDynamicClaimsPrincipalContributor`: Provided by the [Identity module](Modules/Identity.md) and generates and overrides the actual dynamic claims, and writes to the distributed cache. Typically works in the authentication server in a distributed system. |
|||
* `RemoteDynamicClaimsPrincipalContributor`: For distributed scenarios, this implementation works in the UI application. It tries to get dynamic claim values in the distributed cache. If not found in the distributed cache, it makes an HTTP call to the authentication server and requests filling it by the authentication server. `AbpClaimsPrincipalFactoryOptions.RemoteRefreshUrl` should be properly configure to make it running. |
|||
* `WebRemoteDynamicClaimsPrincipalContributor`: Similar to the `RemoteDynamicClaimsPrincipalContributor` but works in the microservice applications. |
|||
|
|||
### IAbpDynamicClaimsPrincipalContributor |
|||
|
|||
If you want to add your own dynamic claims contributor, you can create a class that implement the `IAbpDynamicClaimsPrincipalContributor` interface (and register it to the [dependency injection](Dependency-Injection.md) system. ABP Framework will call the `ContributeAsync` method to get the claims. It better to use a kind of cache to improve the performance since that is a frequently executed method (in every HTTP request). |
|||
|
|||
## AbpClaimsPrincipalFactoryOptions |
|||
|
|||
`AbpClaimsPrincipalFactoryOptions` is the main options class to configure the behavior of the dynamic claims system. It has the following properties: |
|||
|
|||
* `IsDynamicClaimsEnabled`: Enable or disable the dynamic claims feature. |
|||
* `RemoteRefreshUrl`: The `url ` of the Auth Server to refresh the cache. It will be used by the `RemoteDynamicClaimsPrincipalContributor`. The default value is `/api/account/dynamic-claims/refresh ` and you should provide the full URL in the authentication server, like `http://my-account-server/api/account/dynamic-claims/refresh `. |
|||
* `DynamicClaims`: A list of dynamic claim types. Only the claims in that list will be overridden by the dynamic claims system. |
|||
* `ClaimsMap`: A dictionary to map the claim types. This is used when the claim types are different between the Auth Server and the client. Already set up for common claim types by default. |
|||
|
|||
## WebRemoteDynamicClaimsPrincipalContributorOptions |
|||
|
|||
`WebRemoteDynamicClaimsPrincipalContributorOptions` is the options class to configure the behavior of the `WebRemoteDynamicClaimsPrincipalContributor`. It has the following properties: |
|||
|
|||
* `IsEnabled`: Enable or disable the `WebRemoteDynamicClaimsPrincipalContributor`. `false` by default. |
|||
* `AuthenticationScheme`: The authentication scheme to authenticate the HTTP call to the authentication server. |
|||
|
|||
## See Also |
|||
|
|||
* [Authorization](Authorization.md) |
|||
* [Claims-based authorization in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/security/authorization/claims) |
|||
* [Mapping, customizing, and transforming claims in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/claims) |
|||
@ -1,77 +1,288 @@ |
|||
# ABP Version 8.0 Migration Guide |
|||
|
|||
This document is a guide for upgrading ABP v7.4.x solutions to ABP v8.0.x. |
|||
This document is a guide for upgrading ABP v7.x solutions to ABP v8.0. There are some changes in this version that may affect your applications, please read it carefully and apply the necessary changes to your application. |
|||
|
|||
> ABP Framework upgraded to .NET 8.0, so you need to move your solutions to .NET 8.0 if you want to use the ABP 8.0. You can check the [Migrate from ASP.NET Core 7.0 to 8.0](https://learn.microsoft.com/en-us/aspnet/core/migration/70-80) documentation. |
|||
|
|||
## Injected the `IDistributedEventBus` Dependency into the `IdentityUserManager` |
|||
|
|||
In this version, `IDistributedEventBus` service has been injected to the `IdentityUserManager` service, to publish a distributed event when the email or username is changed for a user, this was needed because sometimes there may be scenarios where the old email/username is needed for the synchronization purposes. |
|||
|
|||
Therefore, you might need to update the `IdentityUserManager`'s constructor if you have overridden the class and are using it. |
|||
|
|||
> See the issue for more information: https://github.com/abpframework/abp/pull/17990 |
|||
|
|||
## Updated Method Signatures in the Bundling System |
|||
|
|||
In this version, ABP Framework introduced the CDN support for bundling. During the development, we have made some improvements on the bundling system and changed some method signatures. |
|||
|
|||
See https://github.com/abpframework/abp/issues/17864 for more information. |
|||
|
|||
## Replaced `IdentityUserLookupAppService` with the `IIdentityUserIntegrationService` |
|||
|
|||
[Integration Services](../Integration-Services.md) are built for module-to-module (or microservice-to-microservice) communication rather than consumed from a UI or a client application as [Application Services](../Application-Services.md) are intended to do. |
|||
|
|||
In that regard, we are discarding the `IIdentityUserLookupAppService` in the Identity Module and moving its functionality to the `IIdentityUserIntegrationService`. Therefore, if you have used that application service directly, use the integration service (`IIdentityUserIntegrationService`) instead. `IIdentityUserLookupAppService` will be removed in thes next versions, so you may need to create a similar service in your application. |
|||
|
|||
> Notice that integration services have no authorization and are not exposed as HTTP API by default. |
|||
Also, if you have overridden the `IdentityUserLookupAppService` and `IdentityUserIntegrationService` classes in your application, you should update these classes' constructors as follows: |
|||
|
|||
*IdentityUserLookupAppService.cs* |
|||
```csharp |
|||
public IdentityUserLookupAppService(IIdentityUserIntegrationService identityUserIntegrationService) |
|||
{ |
|||
IdentityUserIntegrationService = identityUserIntegrationService; |
|||
} |
|||
``` |
|||
|
|||
*IdentityUserIntegrationService.cs* |
|||
|
|||
```diff |
|||
public IdentityUserIntegrationService( |
|||
IUserRoleFinder userRoleFinder, |
|||
+ IdentityUserRepositoryExternalUserLookupServiceProvider userLookupServiceProvider) |
|||
{ |
|||
UserRoleFinder = userRoleFinder; |
|||
+ UserLookupServiceProvider = userLookupServiceProvider; |
|||
} |
|||
``` |
|||
|
|||
## MongoDB Event Bus Enhancements |
|||
|
|||
In this version, we have made some enhancements in the transactional inbox/outbox pattern implementation and defined two new methods: `ConfigureEventInbox` and `ConfigureEventOutbox` for MongoDB Event Box collections. |
|||
|
|||
If you call one of these methods in your DbContext class, then this introduces a breaking-change because if you do it, MongoDB collection names will be changed. Therefore, it should be carefully done since existing (non-processed) event records are not automatically moved to new collection and they will be lost. Existing applications with event records should rename the collection manually while deploying their solutions. |
|||
|
|||
See https://github.com/abpframework/abp/pull/17723 for more information. Also, check the documentation for the related configurations: [Distributed Event Bus](../Distributed-Event-Bus.md) |
|||
|
|||
## Moved the CMS Kit Pages Feature's Routing to a `DynamicRouteValueTransformer` |
|||
|
|||
In this version, we have made some improvements in the [CMS Kit's Pages Feature](../Modules/Cms-Kit/Pages.md), such as moving the routing logic to a `DynamicRouteValueTransformer` and etc... |
|||
|
|||
These enhancements led to some breaking changes as listed below that should be taken care of: |
|||
|
|||
* Page routing has been moved to **DynamicRouteValueTransformer**. If you use `{**slug}` pattern in your routing, it might conflict with new CMS Kit routing. |
|||
* `PageConsts.UrlPrefix` has been removed, instead, the default prefix is *pages* for now. Still `/pages/{slug}` route works for backward compatibility alongside with `/{slug}` route. |
|||
|
|||
* **Endpoints changed:** |
|||
* `api/cms-kit-public/pages/{slug}` endpoint is changed to `api/cms-kit-public/pages/by-slug?slug={slug}`. Now multiple level of page URLs can be used and `/` characters will be transferred as URL Encoded in querysting to the HTTP API. |
|||
* `api/cms-kit-public/pages` changed to `api/cms-kit-public/pages/home` |
|||
|
|||
>_CmsKit Client Proxies are updated. If you don't send a **custom request** to this endpoint, **you don't need to take an action**_ |
|||
|
|||
## Added Integration Postfix for Auto Controllers |
|||
|
|||
With this version on, the `Integration` suffix from controller names while generating [auto controllers](../API/Auto-API-Controllers.md) are not going to be removed, to differ the integration services from application services in the OpenAPI specification: |
|||
|
|||
 |
|||
|
|||
> This should not affect most of the applications since you normally do not depend on the controller names in the client side. |
|||
|
|||
See https://github.com/abpframework/abp/issues/17625 for more information (how to preserve the existing behaviour, etc...). |
|||
|
|||
## Revised the reCaptcha Generator for CMS Kit's Comment Feature |
|||
|
|||
In this version, we have made improvements on the [CMS Kit's Comment Feature](../Modules/Cms-Kit/Comments.md) and revised the reCaptcha generation process, and made a performance improvement. |
|||
|
|||
This introduced some breaking changes that you should aware of: |
|||
|
|||
* Lifetime of the `SimpleMathsCaptchaGenerator` changed from singleton to transient, |
|||
* Changed method signatures for `SimpleMathsCaptchaGenerator` class. (all of its methods are now async) |
|||
|
|||
If you haven't override the comment view component, then you don't need to make any changes, however if you have overriden the component and used the `SimpleMathsCaptchaGenerator` class, then you should make the required changes as described. |
|||
|
|||
## Disabled Logging for `HEAD` HTTP Methods |
|||
|
|||
HTTP GET requests should not make any change in the database normally and audit log system of ABP Framework doesn't save audit log objects for GET requests by default. You can configure the `AbpAuditingOptions` and set the `IsEnabledForGetRequests` to **true** if you want to record _GET_ requests as described in [the documentation](../Audit-Logging.md). |
|||
|
|||
Prior to this version, only the _GET_ requests were not saved as audit logs. From this version on, also the _HEAD_ requests will not be saved as audit logs, if the `IsEnabledForGetRequests` explicitly set as **true**. |
|||
|
|||
You don't need to make any changes related to that, however it's important to know this change. |
|||
|
|||
## Obsolete the `AbpAspNetCoreIntegratedTestBase` Class |
|||
|
|||
In this version, `AbpAspNetCoreAsyncIntegratedTestBase` class has been set as `Obsolete` and it's recommended to use `AbpWebApplicationFactoryIntegratedTest` instead. |
|||
|
|||
## Use NoTracking for Readonly Repositories for EF Core |
|||
|
|||
In this version, ABP Framework provides read-only [repository](Repositories.md) interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`) to explicitly indicate that your purpose is to query data, but not change it. If so, you can inject these interfaces into your services. |
|||
|
|||
Entity Framework Core read-only repository implementation uses [EF Core's No-Tracking feature](https://learn.microsoft.com/en-us/ef/core/querying/tracking#no-tracking-queries). That means the entities returned from the repository will not be tracked by the EF Core [change tracker](https://learn.microsoft.com/en-us/ef/core/change-tracking/), because it is expected that you won't update entities queried from a read-only repository. |
|||
|
|||
> This behavior works only if the repository object is injected with one of the read-only repository interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`). It won't work if you have injected a standard repository (e.g. `IRepository<...>`) then casted it to a read-only repository interface. |
|||
|
|||
> See the issue for more information: https://github.com/abpframework/abp/pull/17421 |
|||
|
|||
## Use `IAbpDaprClientFactory` to Obtain `DaprClient` |
|||
|
|||
From this version on, instead of injecting the `DaprClient` directly, using the `IAbpDaprClientFactory.CreateAsync` method to create `DaprClient` or `HttpClient` objects to perform operations on Dapr is recommended. |
|||
|
|||
The documentation is already updated according to this suggestion and can be found at https://docs.abp.io/en/abp/8.0/Dapr/Index. So, if you want to learn more you can check the documentation or see the PR: https://github.com/abpframework/abp/pull/18117. |
|||
|
|||
## Angular UI |
|||
|
|||
# Guards |
|||
|
|||
From Angular Documentation; |
|||
|
|||
> Class-based **`Route`** guards are deprecated in favor of functional guards. |
|||
|
|||
- Angular has been using functional guards since version 14. According to this situation we have moved our guards to functional guards. |
|||
|
|||
We have modified our modules to adaptate functional guards. |
|||
|
|||
```diff |
|||
- import {AuthGuard, PermissionGuard} from '@abp/ng.core'; |
|||
+ import {authGuard, permissionGuard} from '@abp/ng.core'; |
|||
|
|||
- canActivate: mapToCanActivate([AuthGuard, PermissionGuard]) |
|||
+ canActivate: [authGuard, permissionGuard] |
|||
``` |
|||
|
|||
You can still use class based guards but we recommend it to use functional guards like us :) |
|||
|
|||
## Upgraded NuGet Dependencies |
|||
|
|||
The following NuGet libraries have been upgraded: |
|||
You can see the following list of NuGet libraries that have been upgraded with .NET 8.0 upgrade, if you are using one of these packages explicitly, you may consider upgrading them in your solution: |
|||
|
|||
| Package | Old Version | New Version | |
|||
| ------------------- | ----------- | ----------- | |
|||
| All Microsoft packages | 7.x | 8.x | |
|||
| Microsoft.CodeAnalysis | 4.2.0 | 4.5.0 | |
|||
| NUglify | 1.20.0 | 1.21.0 | |
|||
| Polly | 7.2.3 | 8.0.0 | |
|||
| aliyun-net-sdk-sts | 3.1.0 | 3.1.1 | |
|||
| Autofac | 7.0.0 | 7.1.0 | |
|||
| Autofac.Extras.DynamicProxy | 6.0.1 | 7.1.0 | |
|||
| AutoMapper | 12.0.0 | 12.0.1 | |
|||
| AsyncKeyedLock | 6.2.1 | 6.2.2 | |
|||
| AWSSDK.S3 | 3.7.9.2 | 3.7.205.9 | |
|||
| AWSSDK.SecurityToken | 3.7.1.151 | 3.7.202.4 | |
|||
| Azure.Storage.Blobs | 12.15.0 | 12.18.0 | |
|||
| ConfigureAwait.Fody | 3.3.1 | 3.3.2 | |
|||
| Confluent.Kafka | 1.8.2 | 2.2.0 | |
|||
| Dapper | 2.0.123 | 2.1.4 | |
|||
| Dapr.Client | 1.11.0 | 1.9.0 | |
|||
| DistributedLock.Core | 1.0.4 | 1.0.5 | |
|||
| DistributedLock.Redis | 1.0.1 | 1.0.2 | |
|||
| EphemeralMongo.Core | 1.1.0 | 1.1.3 | |
|||
| EphemeralMongo6.runtime.linux-x64 | 1.1.0 | 1.1.3 | |
|||
| EphemeralMongo6.runtime.osx-x64 | 1.1.0 | 1.1.3 | |
|||
| EphemeralMongo6.runtime.win-x64 | 1.1.0 | 1.1.3 | |
|||
| FluentValidation | 11.0.1 | 11.7.1 | |
|||
| Fody | 6.6.1 | 6.8.0 | |
|||
| Hangfire.AspNetCore | 1.8.2 | 1.8.5 | |
|||
| Hangfire.SqlServer | 1.8.2 | 1.8.5 | |
|||
| HtmlSanitizer | 5.0.331 | 8.0.723 | |
|||
| IdentityModel | 6.0.0 | 6.2.0 | |
|||
| IdentityServer4.AspNetIdentity | 4.1.1 | 4.1.2 | |
|||
| JetBrains.Annotations | 2022.1.0 | 2023.2.0 | |
|||
| LibGit2Sharp | 0.26.2 | 0.27.2 | |
|||
| Magick.NET-Q16-AnyCPU | 13.2.0 | 13.3.0 | |
|||
| MailKit | 3.2.0 | 4.2.0 | |
|||
| Markdig.Signed | 0.26.0 | 0.33.0 | |
|||
| Microsoft.AspNetCore.Mvc.Versioning | 5.0.0 | 5.1.0 | |
|||
| Microsoft.AspNetCore.Razor.Language | 6.0.8 | 6.0.22 | |
|||
| Microsoft.NET.Test.Sdk | 17.2.0 | 17.7.2 | |
|||
| Minio | 4.0.6 | 6.0.0 | |
|||
| MongoDB.Driver | 2.19.1 | 2.21.0 | |
|||
| NEST | 7.14.1 | 7.17.5 | |
|||
| Newtonsoft.Json | 13.0.1 | 13.0.3 | |
|||
| NSubstitute | 4.3.0 | 5.1.0 | |
|||
| NSubstitute.Analyzers.CSharp | 1.0.15 | 1.0.16 | |
|||
| NuGet.Versioning | 5.11.0 | 6.7.0 | |
|||
| Octokit | 0.50.0 | 8.0.1 | |
|||
| Quartz | 3.4.0 | 3.7.0 | |
|||
| Quartz.Extensions.DependencyInjection | 3.4.0 | 3.7.0 | |
|||
| Quartz.Plugins.TimeZoneConverter | 3.4.0 | 3.7.0 | |
|||
| RabbitMQ.Client | 6.3.0 | 6.5.0 | |
|||
| Rebus | 6.6.5 | 7.2.1 | |
|||
| Rebus.ServiceProvider | 7.0.0 | 9.1.0 | |
|||
| Scriban | 5.4.4 | 5.9.0 | |
|||
| Serilog.AspNetCore | 5.0.0 | 7.0.0 | |
|||
| Serilog.Extensions.Hosting | 3.1.0 | 7.0.0 | |
|||
| Serilog.Extensions.Logging | 3.1.0 | 7.0.0 | |
|||
| Serilog.Sinks.Async | 1.4.0 | 1.5.0 | |
|||
| SharpZipLib | 1.3.3 | 1.4.2 | |
|||
| Shouldly | 4.1.0 | 4.2.1 | |
|||
| SixLabors.ImageSharp | 1.0.4 | 3.0.2 | |
|||
| Slugify.Core | 3.0.0 | 4.0.1 | |
|||
| Spectre.Console | 0.46.1-preview.0.7 | 0.47.0 | |
|||
| Swashbuckle.AspNetCore | 6.2.1 | 6.5.0 | |
|||
| System.Linq.Dynamic.Core | 1.3.3 | 1.3.5 | |
|||
| TimeZoneConverter | 5.0.0 | 6.1.0 | |
|||
| xunit | 2.4.1 | 2.5.1 | |
|||
| xunit.extensibility.execution | 2.4.1 | 2.5.1 | |
|||
| xunit.runner.visualstudio | 2.4.5 | 2.5.1 | |
|||
| aliyun-net-sdk-sts | 3.1.0 | 3.1.2 | |
|||
| AsyncKeyedLock | 6.2.1 | 6.2.2 | |
|||
| Autofac | 7.0.0 | 7.1.0 | |
|||
| Autofac.Extras.DynamicProxy | 6.0.1 | 7.1.0 | |
|||
| AutoMapper | 12.0.0 | 12.0.1 | |
|||
| AWSSDK.S3 | 3.7.9.2 | 3.7.300.2 | |
|||
| AWSSDK.SecurityToken | 3.7.1.151 | 3.7.300.2 | |
|||
| Azure.Messaging.ServiceBus | 7.8.1 | 7.17.0 | |
|||
| Azure.Storage.Blobs | 12.15.0 | 12.19.1 | |
|||
| Blazorise | 1.3.1 | 1.3.2 | |
|||
| Blazorise.Bootstrap5 | 1.3.1 | 1.3.2 | |
|||
| Blazorise.Icons.FontAwesome | 1.3.1 | 1.3.2 | |
|||
| Blazorise.Components | 1.3.1 | 1.3.2 | |
|||
| Blazorise.DataGrid | 1.3.1 | 1.3.2 | |
|||
| Blazorise.Snackbar | 1.3.1 | 1.3.2 | |
|||
| Confluent.Kafka | 1.8.2 | 2.3.0 | |
|||
| Dapper | 2.0.123 | 2.1.21 | |
|||
| Dapr.AspNetCore | 1.9.0 | 1.12.0 | |
|||
| Dapr.Client | 1.9.0 | 1.12.0 | |
|||
| Devart.Data.Oracle.EFCore | 10.1.134.7 | 10.1.151.7 | |
|||
| DistributedLock.Core | 1.0.4 | 1.0.5 | |
|||
| DistributedLock.Redis | 1.0.1 | 1.0.2 | |
|||
| EphemeralMongo.Core | 1.1.0 | 1.1.3 | |
|||
| EphemeralMongo6.runtime.linux-x64 | 1.1.0 | 1.1.3 | |
|||
| EphemeralMongo6.runtime.osx-x64 | 1.1.0 | 1.1.3 | |
|||
| EphemeralMongo6.runtime.win-x64 | 1.1.0 | 1.1.3 | |
|||
| FluentValidation | 11.0.1 | 11.8.0 | |
|||
| Hangfire.AspNetCore | 1.8.2 | 1.8.6 | |
|||
| Hangfire.SqlServer | 1.8.2 | 1.8.6 | |
|||
| HtmlSanitizer | 5.0.331 | 8.0.746 | |
|||
| HtmlAgilityPack | 1.11.42 | 1.11.54 | |
|||
| IdentityModel | 6.0.0 | 6.2.0 | |
|||
| IdentityServer4.AspNetIdentity | 4.1.1 | 4.1.2 | |
|||
| JetBrains.Annotations | 2022.1.0 | 2023.3.0 | |
|||
| LibGit2Sharp | 0.26.2 | 0.28.0 | |
|||
| Magick.NET-Q16-AnyCPU | 13.2.0 | 13.4.0 | |
|||
| MailKit | 3.2.0 | 4.3.0 | |
|||
| Markdig.Signed | 0.26.0 | 0.33.0 | |
|||
| Microsoft.AspNetCore.Authentication.JwtBearer | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Authentication.OpenIdConnect | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Authorization | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Components | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Components.Authorization | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Components.Web | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Components.WebAssembly | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Components.WebAssembly.Authentication | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Components.WebAssembly.DevServer | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Components.WebAssembly.Server | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.DataProtection.StackExchangeRedis | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Mvc.NewtonsoftJson | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.Mvc.Versioning | 5.0.0 | 5.1.0 | |
|||
| Microsoft.AspNetCore.Razor.Language | 6.0.8 | 6.0.25 | |
|||
| Microsoft.AspNetCore.TestHost | 7.0.10 | 8.0.0 | |
|||
| Microsoft.AspNetCore.WebUtilities | 2.2.0 | 8.0.0 | |
|||
| Microsoft.Bcl.AsyncInterfaces | 7.0.0 | 8.0.0 | |
|||
| Microsoft.CodeAnalysis.CSharp | 4.2.0 | 4.5.0 | |
|||
| Microsoft.Data.Sqlite | 7.0.0 | 8.0.0 | |
|||
| Microsoft.EntityFrameworkCore | 7.0.10 | 8.0.0 | |
|||
| Microsoft.EntityFrameworkCore.Design | 7.0.0 | 8.0.0 | |
|||
| Microsoft.EntityFrameworkCore.InMemory | 7.0.10 | 8.0.0 | |
|||
| Microsoft.EntityFrameworkCore.Proxies | 7.0.10 | 8.0.0 | |
|||
| Microsoft.EntityFrameworkCore.Relational | 7.0.10 | 8.0.0 | |
|||
| Microsoft.EntityFrameworkCore.Sqlite | 7.0.10 | 8.0.0 | |
|||
| Microsoft.EntityFrameworkCore.SqlServer | 7.0.0 | 8.0.0 | |
|||
| Microsoft.EntityFrameworkCore.Tools | 7.0.1 | 8.0.0 | |
|||
| Microsoft.Extensions.Caching.Memory | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Caching.StackExchangeRedis | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Configuration.Binder | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Configuration.CommandLine | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Configuration.EnvironmentVariables | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Configuration.UserSecrets | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.DependencyInjection | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.DependencyInjection.Abstractions | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.FileProviders.Composite | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.FileProviders.Embedded | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.FileProviders.Physical | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.FileSystemGlobbing | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Hosting | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Hosting.Abstractions | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Http | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Http.Polly| 7.0.10 | 8.0.0 | |
|||
| Microsoft.Extensions.Identity.Core | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Localization | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Logging | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Logging.Console | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Options | 7.0.0 | 8.0.0 | |
|||
| Microsoft.Extensions.Options.ConfigurationExtensions | 7.0.0 | 8.0.0 | |
|||
| Microsoft.NET.Test.Sdk | 17.2.0 | 17.8.0 | |
|||
| Microsoft.VisualStudio.Web.CodeGeneration.Design | 7.0.0 | 8.0.0 | |
|||
| Minio | 4.0.6 | 6.0.1 | |
|||
| MongoDB.Driver | 2.19.1 | 2.22.0 | |
|||
| NEST | 7.14.1 | 7.17.5 | |
|||
| Newtonsoft.Json | 13.0.1 | 13.0.3 | |
|||
| NSubstitute | 4.3.0 | 5.1.0 | |
|||
| NuGet.Versioning | 5.11.0 | 6.7.0 | |
|||
| NUglify | 1.20.0 | 1.21.0 | |
|||
| Npgsql.EntityFrameworkCore.PostgreSQL | 7.0.0 | 8.0.0 | |
|||
| NSubstitute.Analyzers.CSharp | 1.0.15 | 1.0.16 | |
|||
| Octokit | 0.50.0 | 9.0.0 | |
|||
| OpenIddict.Abstractions | 4.8.0 | 4.10.0 | |
|||
| OpenIddict.Core | 4.8.0 | 4.10.0 | |
|||
| OpenIddict.Server.AspNetCore | 4.8.0 | 4.10.0 | |
|||
| OpenIddict.Validation.AspNetCore | 4.8.0 | 4.10.0 | |
|||
| OpenIddict.Validation.ServerIntegration | 4.8.0 | 4.10.0 | |
|||
| Oracle.EntityFrameworkCore | 7.21.8 | 7.21.12 | |
|||
| Polly | 7.2.3 | 8.2.0 | |
|||
| Pomelo.EntityFrameworkCore.MySql | 7.0.0 | 8.0.0-beta.2 | |
|||
| Quartz | 3.4.0 | 3.7.0 | |
|||
| Quartz.Extensions.DependencyInjection | 3.4.0 | 3.7.0 | |
|||
| Quartz.Plugins.TimeZoneConverter | 3.4.0 | 3.7.0 | |
|||
| Quartz.Serialization.Json | 3.3.3 | 3.7.0 | |
|||
| RabbitMQ.Client | 6.3.0 | 6.6.0 | |
|||
| Rebus | 6.6.5 | 8.0.1 | |
|||
| Rebus.ServiceProvider | 7.0.0 | 10.0.0 | |
|||
| Scriban | 5.4.4 | 5.9.0 | |
|||
| Serilog | 2.11.0 | 3.1.1 | |
|||
| Serilog.AspNetCore | 5.0.0 | 8.0.0 | |
|||
| Serilog.Extensions.Hosting | 3.1.0 | 8.0.0 | |
|||
| Serilog.Extensions.Logging | 3.1.0 | 8.0.0 | |
|||
| Serilog.Sinks.Async | 1.4.0 | 1.5.0 | |
|||
| Serilog.Sinks.Console | 3.1.1 | 5.0.0 | |
|||
| Serilog.Sinks.File | 4.1.0 | 5.0.0 | |
|||
| SharpZipLib | 1.3.3 | 1.4.2 | |
|||
| Shouldly | 4.0.3 | 4.2.1 | |
|||
| SixLabors.ImageSharp.Drawing | 2.0.0 | 2.0.1 | |
|||
| Slugify.Core | 3.0.0 | 4.0.1 | |
|||
| StackExchange.Redis | 2.6.122 | 2.7.4 | |
|||
| Swashbuckle.AspNetCore | 6.2.1 | 6.5.0 | |
|||
| System.Collections.Immutable | 7.0.0 | 8.0.0 | |
|||
| System.Linq.Dynamic.Core | 1.3.3 | 1.3.5 | |
|||
| System.Security.Permissions | 7.0.0 | 8.0.0 | |
|||
| System.Text.Encoding.CodePages | 7.0.0 | 8.0.0 | |
|||
| System.Text.Encodings.Web | 7.0.0 | 8.0.0 | |
|||
| System.Text.Json | 7.0.0 | 8.0.0 | |
|||
| TimeZoneConverter | 5.0.0 | 6.1.0 | |
|||
| xunit | 2.4.1 | 2.6.1 | |
|||
| xunit.extensibility.execution | 2.4.1 | 2.6.1 | |
|||
| xunit.runner.visualstudio | 2.4.5 | 2.5.3 | |
|||
|
|||
|
After Width: | Height: | Size: 130 KiB |
File diff suppressed because it is too large
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Authentication; |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
using Volo.Abp.Security.Claims; |
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection; |
|||
|
|||
public static class AbpJwtBearerExtensions |
|||
{ |
|||
public static AuthenticationBuilder AddAbpJwtBearer(this AuthenticationBuilder builder) |
|||
=> builder.AddAbpJwtBearer(JwtBearerDefaults.AuthenticationScheme, _ => { }); |
|||
|
|||
public static AuthenticationBuilder AddAbpJwtBearer(this AuthenticationBuilder builder, Action<JwtBearerOptions> configureOptions) |
|||
=> builder.AddAbpJwtBearer(JwtBearerDefaults.AuthenticationScheme, configureOptions); |
|||
|
|||
public static AuthenticationBuilder AddAbpJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, Action<JwtBearerOptions> configureOptions) |
|||
=> builder.AddAbpJwtBearer(authenticationScheme, "Bearer", configureOptions); |
|||
|
|||
public static AuthenticationBuilder AddAbpJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<JwtBearerOptions> configureOptions) |
|||
{ |
|||
builder.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => |
|||
{ |
|||
var jwtBearerOption = new JwtBearerOptions(); |
|||
configureOptions?.Invoke(jwtBearerOption); |
|||
if (!jwtBearerOption.Authority.IsNullOrEmpty()) |
|||
{ |
|||
options.RemoteRefreshUrl = jwtBearerOption.Authority.RemovePostFix("/") + options.RemoteRefreshUrl; |
|||
} |
|||
}); |
|||
|
|||
return builder.AddJwtBearer(authenticationScheme, displayName, options => |
|||
{ |
|||
configureOptions?.Invoke(options); |
|||
}); |
|||
} |
|||
} |
|||
@ -1,10 +1,25 @@ |
|||
using Volo.Abp.Modularity; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AspNetCore.Authentication.JwtBearer.DynamicClaims; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Security; |
|||
using Volo.Abp.Security.Claims; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Authentication.JwtBearer; |
|||
|
|||
[DependsOn(typeof(AbpSecurityModule))] |
|||
[DependsOn(typeof(AbpSecurityModule), typeof(AbpCachingModule))] |
|||
public class AbpAspNetCoreAuthenticationJwtBearerModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddHttpClient(); |
|||
context.Services.AddHttpContextAccessor(); |
|||
|
|||
if (context.Services.ExecutePreConfiguredActions<WebRemoteDynamicClaimsPrincipalContributorOptions>().IsEnabled && |
|||
context.Services.ExecutePreConfiguredActions<AbpClaimsPrincipalFactoryOptions>().IsRemoteRefreshEnabled) |
|||
{ |
|||
context.Services.AddTransient<WebRemoteDynamicClaimsPrincipalContributor>(); |
|||
context.Services.AddTransient<WebRemoteDynamicClaimsPrincipalContributorCache>(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,10 @@ |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Security.Claims; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Authentication.JwtBearer.DynamicClaims; |
|||
|
|||
[DisableConventionalRegistration] |
|||
public class WebRemoteDynamicClaimsPrincipalContributor : RemoteDynamicClaimsPrincipalContributorBase<WebRemoteDynamicClaimsPrincipalContributor, WebRemoteDynamicClaimsPrincipalContributorCache> |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,75 @@ |
|||
using System; |
|||
using System.Net.Http; |
|||
using System.Threading.Tasks; |
|||
using IdentityModel.Client; |
|||
using Microsoft.AspNetCore.Authentication; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Security.Claims; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Authentication.JwtBearer.DynamicClaims; |
|||
|
|||
public class WebRemoteDynamicClaimsPrincipalContributorCache : RemoteDynamicClaimsPrincipalContributorCacheBase<WebRemoteDynamicClaimsPrincipalContributorCache> |
|||
{ |
|||
public const string HttpClientName = nameof(WebRemoteDynamicClaimsPrincipalContributorCache); |
|||
|
|||
protected IDistributedCache<AbpDynamicClaimCacheItem> Cache { get; } |
|||
protected IHttpClientFactory HttpClientFactory { get; } |
|||
protected IHttpContextAccessor HttpContextAccessor { get; } |
|||
protected IOptions<WebRemoteDynamicClaimsPrincipalContributorOptions> Options { get; } |
|||
|
|||
public WebRemoteDynamicClaimsPrincipalContributorCache( |
|||
IDistributedCache<AbpDynamicClaimCacheItem> cache, |
|||
IHttpClientFactory httpClientFactory, |
|||
IOptions<AbpClaimsPrincipalFactoryOptions> abpClaimsPrincipalFactoryOptions, |
|||
IHttpContextAccessor httpContextAccessor, |
|||
IOptions<WebRemoteDynamicClaimsPrincipalContributorOptions> options) |
|||
: base(abpClaimsPrincipalFactoryOptions) |
|||
{ |
|||
Cache = cache; |
|||
HttpClientFactory = httpClientFactory; |
|||
HttpContextAccessor = httpContextAccessor; |
|||
Options = options; |
|||
} |
|||
|
|||
protected async override Task<AbpDynamicClaimCacheItem?> GetCacheAsync(Guid userId, Guid? tenantId = null) |
|||
{ |
|||
return await Cache.GetAsync(AbpDynamicClaimCacheItem.CalculateCacheKey(userId, tenantId)); |
|||
} |
|||
|
|||
protected async override Task RefreshAsync(Guid userId, Guid? tenantId = null) |
|||
{ |
|||
try |
|||
{ |
|||
if (HttpContextAccessor.HttpContext == null) |
|||
{ |
|||
throw new AbpException($"Failed to refresh remote claims for user: {userId} - HttpContext is null!"); |
|||
} |
|||
|
|||
var authenticateResult = await HttpContextAccessor.HttpContext.AuthenticateAsync(Options.Value.AuthenticationScheme); |
|||
if (!authenticateResult.Succeeded) |
|||
{ |
|||
throw new AbpException($"Failed to refresh remote claims for user: {userId} - authentication failed!"); |
|||
} |
|||
|
|||
var accessToken = authenticateResult.Properties?.GetTokenValue("access_token"); |
|||
if (accessToken.IsNullOrWhiteSpace()) |
|||
{ |
|||
throw new AbpException($"Failed to refresh remote claims for user: {userId} - access_token is null or empty!"); |
|||
} |
|||
|
|||
var client = HttpClientFactory.CreateClient(HttpClientName); |
|||
var requestMessage = new HttpRequestMessage(HttpMethod.Post, AbpClaimsPrincipalFactoryOptions.Value.RemoteRefreshUrl); |
|||
requestMessage.SetBearerToken(accessToken); |
|||
var response = await client.SendAsync(requestMessage); |
|||
response.EnsureSuccessStatusCode(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Logger.LogWarning(e, $"Failed to refresh remote claims for user: {userId}"); |
|||
throw; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Authentication.JwtBearer.DynamicClaims; |
|||
|
|||
public class WebRemoteDynamicClaimsPrincipalContributorOptions |
|||
{ |
|||
public bool IsEnabled { get; set; } |
|||
|
|||
public string AuthenticationScheme { get; set; } |
|||
|
|||
public WebRemoteDynamicClaimsPrincipalContributorOptions() |
|||
{ |
|||
IsEnabled = false; |
|||
AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme; |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Security.Claims; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Client; |
|||
|
|||
[DisableConventionalRegistration] |
|||
public class RemoteDynamicClaimsPrincipalContributor : RemoteDynamicClaimsPrincipalContributorBase<RemoteDynamicClaimsPrincipalContributor, RemoteDynamicClaimsPrincipalContributorCache> |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Net.Http; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Http.Client.Authentication; |
|||
using Volo.Abp.Security.Claims; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Client; |
|||
|
|||
public class RemoteDynamicClaimsPrincipalContributorCache : RemoteDynamicClaimsPrincipalContributorCacheBase<RemoteDynamicClaimsPrincipalContributorCache> |
|||
{ |
|||
public const string HttpClientName = nameof(RemoteDynamicClaimsPrincipalContributorCache); |
|||
|
|||
protected IDistributedCache<AbpDynamicClaimCacheItem> Cache { get; } |
|||
protected IHttpClientFactory HttpClientFactory { get; } |
|||
protected IRemoteServiceHttpClientAuthenticator HttpClientAuthenticator { get; } |
|||
|
|||
public RemoteDynamicClaimsPrincipalContributorCache( |
|||
IDistributedCache<AbpDynamicClaimCacheItem> cache, |
|||
IHttpClientFactory httpClientFactory, |
|||
IOptions<AbpClaimsPrincipalFactoryOptions> abpClaimsPrincipalFactoryOptions, |
|||
IRemoteServiceHttpClientAuthenticator httpClientAuthenticator) |
|||
: base(abpClaimsPrincipalFactoryOptions) |
|||
{ |
|||
Cache = cache; |
|||
HttpClientFactory = httpClientFactory; |
|||
HttpClientAuthenticator = httpClientAuthenticator; |
|||
} |
|||
|
|||
protected async override Task<AbpDynamicClaimCacheItem?> GetCacheAsync(Guid userId, Guid? tenantId = null) |
|||
{ |
|||
return await Cache.GetAsync(AbpDynamicClaimCacheItem.CalculateCacheKey(userId, tenantId)); |
|||
} |
|||
|
|||
protected async override Task RefreshAsync(Guid userId, Guid? tenantId = null) |
|||
{ |
|||
try |
|||
{ |
|||
var client = HttpClientFactory.CreateClient(HttpClientName); |
|||
var requestMessage = new HttpRequestMessage(HttpMethod.Post, AbpClaimsPrincipalFactoryOptions.Value.RemoteRefreshUrl); |
|||
await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, requestMessage, new RemoteServiceConfiguration("/"), string.Empty)); |
|||
var response = await client.SendAsync(requestMessage); |
|||
response.EnsureSuccessStatusCode(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Logger.LogWarning(e, $"Failed to refresh remote claims for user: {userId}"); |
|||
throw; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Security.Claims; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Security.Claims; |
|||
|
|||
public class AbpDynamicClaimsMiddleware : IMiddleware, ITransientDependency |
|||
{ |
|||
public async Task InvokeAsync(HttpContext context, RequestDelegate next) |
|||
{ |
|||
if (context.User.Identity?.IsAuthenticated == true) |
|||
{ |
|||
if (context.RequestServices.GetRequiredService<IOptions<AbpClaimsPrincipalFactoryOptions>>().Value.IsDynamicClaimsEnabled) |
|||
{ |
|||
var abpClaimsPrincipalFactory = context.RequestServices.GetRequiredService<IAbpClaimsPrincipalFactory>(); |
|||
context.User = await abpClaimsPrincipalFactory.CreateDynamicAsync(context.User); |
|||
} |
|||
} |
|||
|
|||
await next(context); |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue