hi
In blazor wasm module.
private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)
{
builder.Services.AddOidcAuthentication(options =>
{
builder.Configuration.Bind("AuthServer", options.ProviderOptions);
options.UserOptions.NameClaim = OpenIddictConstants.Claims.Name;
options.UserOptions.RoleClaim = OpenIddictConstants.Claims.Role;
options.ProviderOptions.DefaultScopes.Add("MyProjectName");
options.ProviderOptions.DefaultScopes.Add("roles");
options.ProviderOptions.DefaultScopes.Add("email");
options.ProviderOptions.DefaultScopes.Add("phone");
});
builder.Services.AddAuthorizationCore(options =>
{
options.AddPolicy("TenantPolicy", policy =>
{
policy.RequireAuthenticatedUser().RequireAssertion(handlerContext =>
{
var userId = handlerContext.User.FindUserId();
Console.WriteLine($"****** UserId: {userId} ******");
var tenantId = handlerContext.User.FindTenantId();
Console.WriteLine($"****** TenantId: {tenantId} ******");
return true; // false to skip
});
});
});
}
Index.razor of blazor wasm project
@attribute [Authorize(policy: "TenantPolicy")]
hi
The logs show that the cors check is successful.
Do you have an online angular URL so I can see the cors error?
Or please share the HTTP request and response of the https://localhost:44371/api/abp/application-configuration , you can view them in Chrome dev-tool.
hi
Can you share a template project with your custom code? https://wetransfer.com/
liming.ma@volosoft.com
Thanks
hi
The problem is the options.CallbackPath = "/signin-oidc";
You can remove it and try again.
https://github.com/Flo3Digital/Flo3BlazorDevSingle/commit/fcf6281c3b09d4e58487213e35b5b07635a3aacd
hi
And I have to replace in all 3 Projects your entire code?
You can do this. Remove all existing Logs.txt files and share again.
Thanks.
hi
The localhost:44371 project.
but you can change code and share the logs of Host and AuthServer at the same time.
hi
I didn't receive your logs. Can you share it via https://wetransfer.com/
Do you have any unresolved problems?
hi
Please delete the Logs.txt files.
And set the log level to Debug, then reproduce the cors error and share again.
Thanks.
public class Program
{
public async static Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
.WriteTo.Async(c => c.Console())
.CreateLogger();
```