Most possible it is due to missing Volo.Abp.Account.Pro.Admin.HttpApi.Client package at .Web.Host template
Is it related with https://support.abp.io/QA/Questions/4677/User-lost-credentials-after-30min-without-activity or https://github.com/abpframework/abp/issues/14068
Create extension for CurrentUser in order to get OrganizationIds from token.
public static class CurrentUserExtensions
{
public static string[] GetOrganizationUnits(this ICurrentUser currentUser)
{
Claim[] claims = currentUser.FindClaims("organization_unit");
return claims.Select(c => c.Value).ToArray();
}
}
Add query filters for EF Core
protected override bool ShouldFilterEntity< TEntity >(IMutableEntityType entityType)
{
if (typeof(IHasAccessControl).IsAssignableFrom(typeof(TEntity)))
{
return true;
}
return base.ShouldFilterEntity< TEntity >(entityType);
}
protected override Expression< Func< TEntity, bool > > CreateFilterExpression< TEntity >()
{
var expression = base.CreateFilterExpression< TEntity >();
if (typeof(IHasAccessControl).IsAssignableFrom(typeof(TEntity)))
{
Expression< Func < TEntity, bool > > hasAccessControlFilter = e => CurrentUser.GetOrganizationUnits().Contains(EF.Property< string >(e, "OrganizationId")) || CurrentUser.Id == (EF.Property< string >(e, "OwnerId"));
expression = expression == null ? hasAccessControlFilter : CombineExpressions(expression, hasAccessControlFilter);
}
return expression;
}
Let suppose we have microservices A and B. A for identity, auditing, saas etc, basic IT needs Where B is business microservice.
After creating a new "project" object in microservice B, I want to assign it to a specific person or a specific organizational unit. (see global filter implementation)
So we needed lookup values for organization units (it can be logins, tokens, roles, claims for another use cases)
Information exchange between A and B can be
Again let assume that we would like keep asynchronous communication where we were using UserEtos
So, every time the user is updated in microservice A, I want to update the user information in microservice B via distributed events.
However UserEto's doesn't carry information about
So how can we access asynchronously the above information about the user ?
UserLookupService from Volo.Abp.Users package only forces IUser interface which is doesn't force claims, roles, tokens, ou etc..
public abstract class UserLookupService<TUser, TUserRepository> : IUserLookupService<TUser>, ITransientDependency where TUser : class, IUser where TUserRepository : IUserRepository<TUser>
OU and roles are mainly used to organize permissions and your module should only need to the permission system dependency (it already has). These details are internals of the Identity module.
I think permission system dependency looks enough if you are building "policy based" authorization but not "row level" authorization.
Let's assume use case where we are adding query filters according users organization unit detail. We may want to the user access more or less data according to their hierarchy in the organizational unit. Policy authorized one end point should return all organizational units lookup values for assignment.
Let's define interface for this;
public interface IHasAccessControl
{
public string OwnerId { get; }
public string OrganizationId { get; }
}
Implement interface to the Aggregate Root
public class Project : AuditedAggregateRoot<Guid>, IMultiTenant, IHasAccessControl
{
public virtual string Name { get; protected set; }
// ...
public virtual Guid? TenantId { get; protected set; }
public virtual string OwnerId { get; protected set; }
public virtual string OrganizationId { get; protected set; }
public virtual void SetOwnerId([NotNull] string ownerId)
{
}
public virtual void SetOrganizationId([NotNull] string organizationId)
{
}
}
Let's add organization id information to the token.
public class OrganizationUnitPrincipalContributor : IAbpClaimsPrincipalContributor, ITransientDependency
{
public async Task ContributeAsync(AbpClaimsPrincipalContributorContext context)
{
var identity = context.ClaimsPrincipal.Identities.FirstOrDefault();
var userId = identity?.FindUserId();
if (userId.HasValue)
{
var userService = context.ServiceProvider.GetRequiredService< IdentityUserManager >();
var user = await userService.FindByIdAsync(userId.ToString());
if (user != null)
{
user.OrganizationUnits
.Select(u => u.OrganizationUnitId).ToList()
.ForEach(unit => identity.AddClaim(new Claim(type: "organization_unit", value: unit.ToString())));
}
}
}
}
Add short cut for identityServer (https://github.com/abpframework/abp/pull/7998)
Configure<AbpClaimsServiceOptions>(options =>
{
options.RequestedClaims.AddRange(new[] { "organization_unit" });
});
1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable
1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList
1 entriesToSave, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func
4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Volo.Abp.EntityFrameworkCore.AbpDbContext1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Volo.Abp.Uow.UnitOfWork.SaveChangesAsync(CancellationToken cancellationToken)
at Volo.Abp.Uow.UnitOfWork.CompleteAsync(CancellationToken cancellationToken)
at Volo.Abp.AspNetCore.Mvc.Uow.AbpUowActionFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)There is a nice documentation and blog post on how to check concurrency (https://docs.abp.io/en/abp/latest/Concurrency-Check), but there is no example on how to resolve conflicts manually. I don't understand how we can access the "values" (values on db, submitted data etc) in case of conflict.
The SaveChangesAsync() function throws AbpDbConcurrencyException not DbUpdateConcurrencyException
The AbpDbConcurrencyException class does not derive from the DbUpdateConcurrencyException class.
For this reason, I cannot access the Current/Original/Database values of the entity. (https://learn.microsoft.com/en-us/ef/core/saving/concurrency#resolving-concurrency-conflicts)
Can you share an example about the resolving concurrency conflicts ? Existing framework documentation doesn't provide any info resolving concurrency.
Ok thx after login it is working again, but I didn't perform any "log out" operation ? Do we need to refresh our login time to time ? Is there any kind of necessity ?
ABP-LIC-0013 - License exception: ABP-LIC-0023: An error occured while calling the license server! The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. Error occured while getting the latest version from https://abp.io/api/download/template/get-version/ : Remote server returns '403-Forbidden'. Message: Pro templates require a commercial license! Should login to be able to download a pro template.
And also is this UI issue ? Why we can't set status to non-private ?
Thanks for the information. It's really easy to override. Thanks for abp modularization.
What I want to understand is whether this change will cause a problem in the operation of template engines (razor, scribian).
Do i need to consider to check AbpTextTemplatingScribanModule or AbpTextTemplatingRazorModule as well ?
ABP Framework version: v5.3.3
UI type: MVC
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): yes
Exception message and stack trace:
2022-09-21 12:35:43.088 +00:00 [ERR] content length must be equal to or lower than 65535! (Parameter 'content')
System.ArgumentException: content length must be equal to or lower than 65535! (Parameter 'content')
at Volo.Abp.Check.NotNullOrWhiteSpace(String value, String parameterName, Int32 maxLength, Int32 minLength) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Core\Volo\Abp\Check.cs:line 82
at Volo.Abp.TextTemplateManagement.TextTemplates.TextTemplateContent.SetContent(String content)
at Volo.Abp.TextTemplateManagement.TextTemplates.TextTemplateContent..ctor(Guid id, String name, String content, String cultureName, Nullable1 tenantId) at Volo.Abp.TextTemplateManagement.TextTemplates.TemplateContentAppService.UpdateAsync(UpdateTemplateContentInput input) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue
1.ProceedAsync() in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpMethodInvocationAdapterWithReturnValue.cs:line 25
at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Authorization\Volo\Abp\Authorization\AuthorizationInterceptor.cs:line 20
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAsyncAbpInterceptorAdapter.cs:line 34
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpMethodInvocationAdapterWithReturnValue.cs:line 25 at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.GlobalFeatures\Volo\Abp\GlobalFeatures\GlobalFeatureInterceptor.cs:line 26 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAsyncAbpInterceptorAdapter.cs:line 34 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue
1.ProceedAsync() in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpMethodInvocationAdapterWithReturnValue.cs:line 25
at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Auditing\Volo\Abp\Auditing\AuditingInterceptor.cs:line 103
at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Auditing\Volo\Abp\Auditing\AuditingInterceptor.cs:line 49
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAsyncAbpInterceptorAdapter.cs:line 34
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpMethodInvocationAdapterWithReturnValue.cs:line 25 at Volo.Abp.Features.FeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Features\Volo\Abp\Features\FeatureInterceptor.cs:line 29 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAsyncAbpInterceptorAdapter.cs:line 34 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue
1.ProceedAsync() in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpMethodInvocationAdapterWithReturnValue.cs:line 25
at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Validation\Volo\Abp\Validation\ValidationInterceptor.cs:line 20
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAsyncAbpInterceptorAdapter.cs:line 34
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpMethodInvocationAdapterWithReturnValue.cs:line 25 at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Uow\Volo\Abp\Uow\UnitOfWorkInterceptor.cs:line 53 at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAsyncAbpInterceptorAdapter.cs:line 34 at Volo.Abp.TextTemplateManagement.TextTemplates.TemplateContentController.UpdateAsync(UpdateTemplateContentInput input) at lambda_method13416(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask
1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Steps to reproduce the issue:"
Why there is such a limit ?