Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "MellowoodMedical"

I am Using swagger login feature for this as mentioned above. The steps are below,

  • go to swagger UI of API [https://{tenantname}.api.mellowoodmedical.com/swagger/index.html].
  • Authorize using admin username and password.[leveraging swagger login feature in zero as adviced]
  • The above action will set return token from 'Authorize' method of 'TokenAuthController'. Setting this token as 'Abp.AuthToken' cookie on 'abp.js' file .
  • Try to access [https://{tenantname}.api.mellowoodmedical.com/hangfire] where the request executes 'Authorize' method of HangfireAuthorizationFilter which is implemented on the initial question. Here, we are getting the token as null .Looking at the request, there is not cookie passed with the request.

So** I am not trying to access hangfire from angular projects**. Only API project is involved on this action. Could you please advice why the cookie is passing/null in the above scenario?

@maliming , Thanks for responding. There is an update on the issue. Now getting 500 exception and the details below.

Actually i am trying to access the dashbord from api by appending /hangfire and there is no angular involved here. One I authorize the API, A cookie[Abp.Athtoken] is set on Abp.swagger js file.

After this I call hangfire dashboard by /hangfire and I could see in the network request, no cookie is passed . Now I get the below exception in the request.

ERROR 2019-10-10 15:32:40,445 [4 ] Default - Exception on hangfire authorization System.ArgumentNullException: IDX10000: The parameter 'token' cannot be a 'null' or an empty object. Parameter name: token at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken) at PatientPortal.Web.Url.HangfireAuthorizationFilter.Authorize(DashboardContext context) in D:\a\1\s\src\PatientPortal.Web.Host\Url\HangfireAuthorizationFilter.cs:line 42

Why we are not passing cookie with hangfire request? Please let me know if any further info is needed.

Hi ,

I have the set up below for hangfire dashboard authorization on angular and core application. Both are hosted seperatly.


app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
                Authorization = new[] { new Url.HangfireAuthorizationFilter() }
            });
            app.UseHangfireServer();
            
   The HangfireAuthorizationFilter make use of the [AbpAuthtoken] which is set after login to api directly.
   
    public bool Authorize(DashboardContext context)
        {
            try
            {
                var cookies = context.GetHttpContext().Request.Cookies;
                var token = cookies["Abp.AuthToken"];
                _logger.Info($"hangfire authorization token  {token}");
                JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
                TokenValidationParameters tokenValidationParameters = new TokenValidationParameters
                {
                    ValidAudience = _configuration.Audience,
                    ValidIssuer = _configuration.Issuer,
                    IssuerSigningKey = _configuration.SecurityKey
                };

                SecurityToken principal;
                var _ = jwtSecurityTokenHandler.ValidateToken(token, tokenValidationParameters, out principal);

                //httpContext.User
                // Allow all authenticated users to see the Dashboard (potentially dangerous).
                return _.Identity.IsAuthenticated && _.IsInRole("Admin");
            }
            catch(Exception ex)
            {
                _logger.Error("Exception on hangfire authorization ", ex);
                return false;
            }
        }
        

Still getting 401 exception on /hangfire. Any thoughts?

Got it working :)

Hi,

How can I access log4net.ThreadContext.Properties in my service class to support custom log4net properties.

Thanks

Thanks a lot, ryancyq. Your solution works. Our second db context is just inherited from AbpDbContext.

Hi,

We have 2 databases and 2 dbContext and each has its own entities. The one which was created by default with aspnetzero works fine with EntityHistory and the one we added as second database is having issues.

thanks

We are using multiple databases for the our project. Now we have created a custom implementation for IEntityHistoryStore and used it to replace the default implementation. Also, we have uncommented lines to write change logs for the entities and added the entity type for Entity History selectors. The problem is that Entity History works for entities stored in the one database and doesn't work for entities stored in another databases. Do you have any suggestions for that?

The version of Asp.net Zero is v6.6.0 and we are using EntityFramework Core.

Hi,

I have added second DbContext to my aspnetzero project and it works fine on my local but as soon as I deploy it to azure it throws following exception:

System.Exception: Could not find content root folder!   at PatientPortal.Web.WebContentDirectoryFinder.CalculateContentRootFolder() in D:\a\1\s\src\PatientPortal.Core\Web\WebContentFolderHelper.cs:line 27   at PatientPortal.EntityFrameworkCore.PatientPortalConnectionStringResolver.GetNameOrConnectionString(ConnectionStringResolveArgs args) in D:\a\1\s\src\PatientPortal.EntityFrameworkCore\EntityFrameworkCore\PatientPortalConnectionStringResolver.cs:line 19   at Abp.Domain.Uow.UnitOfWorkBase.ResolveConnectionString(ConnectionStringResolveArgs args)   at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.GetOrCreateDbContext[TDbContext](Nullable`1 multiTenancySide, String name)   at Abp.EntityFrameworkCore.Uow.UnitOfWorkExtensions.GetDbContext[TDbContext](IActiveUnitOfWork unitOfWork, Nullable`1 multiTenancySide, String name)   at Abp.EntityFrameworkCore.Uow.UnitOfWorkDbContextProvider`1.GetDbContext(Nullable`1 multiTenancySide)   at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase`3.get_Context()   at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase`3.get_Table()   at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase`3.GetAllIncluding(Expression`1[] propertySelectors)   at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase`3.GetAll()   at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase`3.FirstOrDefaultAsync(TPrimaryKey id)   at Abp.Domain.Repositories.AbpRepositoryBase`2.GetAsync(TPrimaryKey id)   at Abp.Threading.InternalAsyncHelper.AwaitTaskWithPostActionAndFinallyAndGetResult[T](Task`1 actualReturnValue, Func`1 postAction, Action`1 finalAction)   at PatientPortal.Demographic.Service.DemographicService.GetDemograph(Int32 input)   at lambda_method(Closure , Object )   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExec...

Please suggest.

Thanks, Gaurav Singh

Answer

Hi, Sent you email with onedrive link to the above mentioned email.

Showing 71 to 80 of 89 entries