AbpIdentityWebModule // Remain
AbpAccountPublicWebIdentityServerModule //Replace with AbpAccountPublicWebOpenIddictModule
AbpIdentityServerWebModule //Replace with AbpOpenIddictProWebModule
IdentityMenuNames// Remain
AbpIdentityServerMenuNames// Replace with OpenIddictProMenus
I recommend you to create a new project and check its code.
hi
You should remove all Identity Server-related code.
You can create a new template project to compare the code.
hi
Thanks. I will ask our colleagues.
hi
A DataSeedContributor to add two roles and add all permissions to these roles.
You can give it a try.
https://docs.abp.io/en/abp/latest/Data-Seeding
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Identity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Uow;
public class MyDataSeedContributor : IDataSeedContributor, ITransientDependency
{
protected IGuidGenerator GuidGenerator { get; }
protected IIdentityRoleRepository RoleRepository { get; }
protected IIdentityUserRepository UserRepository { get; }
protected ILookupNormalizer LookupNormalizer { get; }
protected IdentityUserManager UserManager { get; }
protected IdentityRoleManager RoleManager { get; }
protected ICurrentTenant CurrentTenant { get; }
protected IOptions<IdentityOptions> IdentityOptions { get; }
protected IPermissionDefinitionManager PermissionDefinitionManager { get; }
protected IPermissionDataSeeder PermissionDataSeeder { get; }
public MyDataSeedContributor(
IGuidGenerator guidGenerator,
IIdentityRoleRepository roleRepository,
IIdentityUserRepository userRepository,
ILookupNormalizer lookupNormalizer,
IdentityUserManager userManager,
IdentityRoleManager roleManager,
ICurrentTenant currentTenant,
IOptions<IdentityOptions> identityOptions,
IPermissionDefinitionManager permissionDefinitionManager,
IPermissionDataSeeder permissionDataSeeder)
{
GuidGenerator = guidGenerator;
RoleRepository = roleRepository;
UserRepository = userRepository;
LookupNormalizer = lookupNormalizer;
UserManager = userManager;
RoleManager = roleManager;
CurrentTenant = currentTenant;
IdentityOptions = identityOptions;
PermissionDefinitionManager = permissionDefinitionManager;
PermissionDataSeeder = permissionDataSeeder;
}
[UnitOfWork]
public virtual async Task SeedAsync(DataSeedContext context)
{
var tenantId = context.TenantId;
using (CurrentTenant.Change(tenantId))
{
await IdentityOptions.SetAsync();
// "Employer" and "Contractor" roles
const string employerRoleName = "Employer";
const string contractorRoleName = "Contractor";
var employerRoleNameRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(employerRoleName));
if (employerRoleNameRole == null)
{
employerRoleNameRole = new IdentityRole(GuidGenerator.Create(), employerRoleName, tenantId)
{
IsPublic = true
};
(await RoleManager.CreateAsync(employerRoleNameRole)).CheckErrors();
}
var contractorRoleNameRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(contractorRoleName));
if (contractorRoleNameRole == null)
{
contractorRoleNameRole = new IdentityRole(GuidGenerator.Create(), contractorRoleName, tenantId)
{
IsPublic = true
};
(await RoleManager.CreateAsync(contractorRoleNameRole)).CheckErrors();
}
var yourUser = await UserRepository.FindAsync(Guid.NewGuid());//your user id
(await UserManager.AddToRoleAsync(yourUser, employerRoleName)).CheckErrors();
(await UserManager.AddToRoleAsync(yourUser, contractorRoleName)).CheckErrors();
var multiTenancySide = CurrentTenant.GetMultiTenancySide();
var allPermissionNames = (await PermissionDefinitionManager.GetPermissionsAsync())
.Where(p => p.MultiTenancySide.HasFlag(multiTenancySide))
.Select(p => p.Name)
.ToArray();
await PermissionDataSeeder.SeedAsync(
RolePermissionValueProvider.ProviderName,
employerRoleName,
allPermissionNames,
context?.TenantId
);
await PermissionDataSeeder.SeedAsync(
RolePermissionValueProvider.ProviderName,
contractorRoleName,
allPermissionNames,
context?.TenantId
);
}
}
}
hi
Can you try to use http://backoffice-authserver to replace the http://localhost:44395?
Because your container can't reach the http://localhost:44395 in docker.
What are the logs after setting the AuthServer:Authority to http://backoffice-authserver ?
I have tried but still not working
What is your AuthServer:Authority value?
What are the logs after setting the AuthServer:Authority ?
There is no account module in your Web project.
Please add <PackageReference Include="Volo.Abp.Account.Pro.Public.Web.OpenIddict" Version="8.1.1" /> to it and try again.
You can create a new template project to compare the csproj file.
hi
Can you also share the screenshot of the project structure? Do you have AuthServer project?
These classes are in the Volo.Abp.Account.Pro.Public.Web.OpenIddict package.
btw, can you share your csproj file of backed?