hi
Please check and share your backend logs.
hi
You need to bootstrap the abp module system in your blazor wasm project.
public class Program
{
public async static Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var application = await builder.AddApplicationAsync<MyProjectNameBlazorModule>(options =>
{
options.UseAutofac();
});
var host = builder.Build();
await application.InitializeApplicationAsync(host.Services);
await host.RunAsync();
}
}
https://docs.abp.io/en/abp/latest/API/Static-CSharp-API-Clients
We will check this. Thanks
Good news.
Create an MVC tiered project, and then refer to .AddCookie and .AddOpenIdConnect in Web project.
Do not set it as the default authentication scheme in HTTP.API project. add a middleware to call the cookie authentication
app.UseAuthentication();
app.Use(async (ctx, next) =>
{
if (ctx.User.Identity?.IsAuthenticated != true)
{
var result = await ctx.AuthenticateAsync("YourCookieAuthenticationScheme); //default is Cookies
if (result.Succeeded && result.Principal != null)
{
ctx.User = result.Principal;
}
}
await next();
});
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
AsyncAuthorization = new[] { new AbpHangfireAuthorizationFilter(requiredPermissionName: MainCorePermissions.HangfireDashboard.Default) }
});
You can add Cookies as a second authentication scheme to the HTTP.API project.
https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?view=aspnetcore-6.0
hi
Update the src/TestModule.Web/Pages/_ViewImports.cshtml
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling
@addTagHelper *, TestModule
@addTagHelper *, TestModule.Web
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.Replace(ServiceDescriptor.Scoped<IPasswordHasher<IdentityUser>, MyPasswordHasher>());
}
using Microsoft.AspNetCore.Identity;
using IdentityUser = Volo.Abp.Identity.IdentityUser;
namespace MyCompanyName.MyProjectName;
public class MyPasswordHasher : IPasswordHasher<IdentityUser>
{
public string HashPassword(IdentityUser user, string password)
{
return password;
}
public PasswordVerificationResult VerifyHashedPassword(IdentityUser user, string hashedPassword, string providedPassword)
{
return hashedPassword == providedPassword
? PasswordVerificationResult.Success
: PasswordVerificationResult.Failed;
}
}
hi
HTTP.API uses **JwtBearer ** for authentication by default.
You can set Hangfire and HealthCheckUI in the Identity Server project.
Or add a Cookies as second authentication scheme. Do not set it as the default authentication scheme.
builder.Services.AddAuthentication()
.AddCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromMinutes(20);
options.SlidingExpiration = true;
options.AccessDeniedPath = "/Forbidden/";
});
https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?view=aspnetcore-6.0
We provide the source code of the module, you can check it first
please feedback if you have any problems.