Activities of "cangunaydin"

Thank you for the help.

Hello, I didn't understand how i can pass the authorization header while i am redirecting the user from angular. Is there any sample code how to do that? I would be happy if you can share it. I fixed the problem by implementing another authentication schema, so in that way i can challenge the user to authenticate and when it is done i can sign in the user and redirect the user to the page. sth like this.

 context.Services.AddAuthentication(options =>
        {
            options.DefaultScheme = "DoohlinkCustomPolicy";
            options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
        })
        .AddPolicyScheme("DoohlinkCustomPolicy", "DoohlinkCustomPolicy", options =>
        {
            options.ForwardDefaultSelector = context =>
            {
                string authorization = context.Request.Headers[HeaderNames.Authorization];
                if (!string.IsNullOrEmpty(authorization) && authorization.StartsWith("Bearer "))
                    return JwtBearerDefaults.AuthenticationScheme;
                else
                    return CookieAuthenticationDefaults.AuthenticationScheme;
            };
        })
        .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options =>
        {
            options.Authority = configuration["AuthServer:Authority"];
            options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
            options.Audience = "Doohlink";
        })
        .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
         {
             options.ExpireTimeSpan = TimeSpan.FromDays(365);
         })
        .AddAbpOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options =>
        {
            options.Authority = configuration["AuthServer:Authority"];
            options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
            options.ResponseType = OpenIdConnectResponseType.Code;

            options.ClientId = configuration["AuthServer:WebClientId"];
            options.ClientSecret = configuration["AuthServer:WebClientSecret"];

            options.UsePkce = true;
            options.SaveTokens = true;
            options.GetClaimsFromUserInfoEndpoint = true;

            options.Scope.Add("roles");
            options.Scope.Add("email");
            options.Scope.Add("phone");
            options.Scope.Add("Doohlink");
            options.Events.OnTicketReceived = async (TicketReceivedContext e) =>
            {
                await e.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
                    e.Principal,
                    new AuthenticationProperties
                    {
                        IsPersistent = true,
                        AllowRefresh = true,
                        ExpiresUtc = DateTime.UtcNow.AddDays(1)
                    });
            };
        });

and challenging the user to login in a controller.

public ActionResult Login()
    {
        return Challenge(new AuthenticationProperties { RedirectUri = "/hangfire" }, OpenIdConnectDefaults.AuthenticationScheme);
    }

this works for now. But I would happy to know how to do it from angular. Because as i know when you do redirect from client side like. window.open() you can not pass authorization header. Or maybe I am wrong?

Hello again, Thanks for the explanation, can i ask how can i do the same for hangfire dashboard? If i write a mvc controller action, how can i redirect the user to auth server log in page and then redirect to hangfire dashboard?

Thanks a lot, i have seen the fix now, I am closing the issue then.

Hello @liangshiwei. As you mention it works when you await, probably when i try to await i did sth wrong. It was late at night :) Thank you for sharing the issue link with me So it seems, collection has been updated from two threads. And collection that is updated in Volo.Abp.Uow.UnitOfWorkExtensions.GetOrAddItem is not thread safe. Maybe changing that to ConcurrentDictionary can help. https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2?view=net-5.0

Thank you @mahmut.

Hello again, you can find the project in this github repo. https://github.com/cangunaydin/abpConcurrencyIssue to produce the same error you have to do the followings.

1- Clone the project.

2- Go to aspnet-core\etc\docker

3- execute run-docker-sideapps.ps1 this will create the redis and postgres(postgis) container.(stick to these images since appsettings has been configured according to those docker images and geolocation is involved)

4- Build project and run dbmigrator. This will seed a new tenant named "Tribulus" and one screen belongs to this tenant with id: "ad16f9e2-bf39-43cf-af69-47b7388ee9cd". You can check TenantDataSeeder class if you want.

5- abp install-libs inside AuthServer folder then Run Doohlink.AuthServer and Doohlink.HttpApi.Host project

6- Run angular app and get bearer token for Tribulus tenant with username: admin, password: 123qwe, note the bearer token and tenantid to somewhere, you will use them on step 8 7- Install Jmeter to do multiple http requests async. If you want you can use another tool but important part is you need bunch of async calls at the same time. https://jmeter.apache.org/download_jmeter.cgi Download zip file, unzip it then run jmeter.bat

8- After running the Jmeter, you need to open the TestJmeter.jmx file on the root folder of the project. This is a script that will do the call to the endpoint.

9- Change the bearer token and tenantid to what you got from step 6. You need to do that from Http Header Manager

10-Run the jmeter, it is gonna take 10 seconds, you can see if http requests are successful on treeview. Most of them will succeed around 5 of them will fail. you can look at the logs afterwards.

Hello @liangshiwei, is it okay if i share the original project? it is not a super complicated project i think you will understand.

Hello again, thanks for pointing out the code now it is more clear. What i couldn't understand is if it is in the cache, it shouldn't give any error since it is gonna return it from the cache. Anyway i am gonna close this issue, thanks for your help @liangshiwei

I think i have found the solution but I couldn't understand why it behaves like it. I use docker container for postgres and redis. If I remove containers and images and compose it again, it writes to database. I still couldn't find where the data is persisted (from which section of the code).
I was checking ILocalizationResourceContributor implementations inside the source code, can not see any data persistency. Can you post the class or line where abp store the localization resources to db?

For my problem, I am suspicious that after some time probably i deleted the db manually and recreate it again through dbmigrator. Maybe resources stayed in the cache, but still didn't make sense why it couldn't find the resource if it is still in the cache. Cause endpoint should return to angular app if it was there.

I can share my project, but i don't think you could reproduce the issue since you are gonna create it from scratch.

Showing 61 to 70 of 84 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35