I could manage this by following below link.
https://support.abp.io/QA/Questions/550/Why-are-there-no-Startupcs-and-Apprazor-files-in-an-abpio-Blazor-project
But the references in the LeptonTheme module does not seem working correctly at first. I had to remove "project" references in identityserver project then I added packages from ABP Cumercial Nnuget Server.
@mailming I know that the admin account and admin roll are set by seeds. I can login and see all the pages and permissions working correctly on web site.(using the same database). But when I try above method, it does not work. it only works when I remove the admin roll from the admin account and set all permissions directly without the roll.
I don't think the permissions granted by the roll are working with above code. and as permissions are not (Role = ), it's a (Policy =) I could not add them as cliams.(I could not find a way to do that).
I think it would be nice if there is a test case Should_Allow_To_Call_Method_If_Has_Permission_ProtectedByClass_Async()
below class has only Should_Not cases for Policy authorazation.
https://github.com/abpframework/abp/blob/bd041b8774ab4df45de11077de8cfa8189d6b85f/framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/Authorization_Tests.cs
@maliming Thanks for you answer.
Above links work for users who are garanted permissions directly without Roles but it does not work for the accounts that are granted permissions by Roles (like Admin user with Admin Role)
//var user = await _userManager.FindByNameAsync("jhan"); // this works
var user = await _userManager.FindByNameAsync("admin"); //this does not
var newPrincipal = new ClaimsPrincipal(
new ClaimsIdentity(
new Claim[]
{
new Claim(AbpClaimTypes.UserId, user.Id.ToString()),
}
));
using (_currentPrincipalAccessor.Change(newPrincipal))
{
var lastRunTimeCoreSetting = await _coreSettingAppService.GetByNameAsync("LastRunTime");
Your link contains exmples for Role-Authorize,
Authorize(Role ="MyAuthorizedService1")
.
.
new Claim(AbpClaimTypes.Role, "MyAuthorizedService1"), // I need something like this for Policy based Authorize.
but I cannot find an exmaple for policy.
Authorize(Policy ="MyAuthorizedService1")