Activities of "drenton"

@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")

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v4.2.1
    • UI type: Console / Module
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:

I'd like to use app services that requires permission on Console application. The console application does not know of web host existing. How can I sign in or get pass the permission check?

var user = await _userManager.FindByNameAsync("admin");
var newPrincipal = new ClaimsPrincipal(
    new ClaimsIdentity(
        new[]
        {
            new(AbpClaimTypes.UserId, user.Id.ToString()),
            new Claim(AbpClaimTypes.UserName, user.UserName)
        }
    ));
using (_currentPrincipalAccessor.Change(newPrincipal))
{
    // Below method requires authentication and authorization.
    var lastRunTimeCoreSetting = await _coreSettingAppService.GetByNameAsync("LastRunTime");
}

<br> I'm using AddAlwaysAllowAuthorization for testing now, but this is not ideal for production.

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: abl CLI v 4.1.2 (stable)

The abp CLI is authenticated with user "drenton". Calling https://abp.io/api/download/template/ with GET returns HTTP 405 so perhaps GET is not supported. Below is the error message:

C:\Users\drenton\Source\Repos>abp new Acme.IssueManagement -t module-pro [11:40:40 INF] ABP CLI (https://abp.io) [11:40:41 INF] Version 4.1.2 (Stable) [11:40:42 INF] Creating your project... [11:40:42 INF] Project name: Acme.IssueManagement [11:40:42 INF] Template: module-pro [11:40:42 INF] Create Solution Folder: no [11:40:42 INF] Output folder: C:\Users\drenton\Source\Repos [11:40:54 INF] Downloading template: module-pro, version: 4.1.2 Error occured while downloading source-code from https://abp.io/api/download/template/ : '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. [11:40:57 ERR] '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, Type returnType, JsonSerializerOptions options) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at Volo.Abp.Json.SystemTextJson.AbpSystemTextJsonSerializerProvider.Deserialize[T](String jsonString, Boolean camelCase) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Json\Volo\Abp\Json\SystemTextJson\AbpSystemTextJsonSerializerProvider.cs:line 34 at Volo.Abp.Json.AbpHybridJsonSerializer.Deserialize[T](String jsonString, Boolean camelCase) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Json\Volo\Abp\Json\AbpHybridJsonSerializer.cs:line 37 at Volo.Abp.Cli.ProjectBuilding.RemoteServiceExceptionHandler.GetAbpRemoteServiceErrorAsync(HttpResponseMessage responseMessage) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ProjectBuilding\RemoteServiceExceptionHandler.cs:line 52 at Volo.Abp.Cli.ProjectBuilding.RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(HttpResponseMessage responseMessage) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ProjectBuilding\RemoteServiceExceptionHandler.cs:line 38 at Volo.Abp.Cli.ProjectBuilding.AbpIoSourceCodeStore.DownloadSourceCodeContentAsync(SourceCodeDownloadInputDto input) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ProjectBuilding\AbpIoSourceCodeStore.cs:line 221 at Volo.Abp.Cli.ProjectBuilding.AbpIoSourceCodeStore.GetAsync(String name, String type, String version, String templateSource, Boolean includePreReleases) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ProjectBuilding\AbpIoSourceCodeStore.cs:line 109 at Volo.Abp.Cli.ProjectBuilding.TemplateProjectBuilder.BuildAsync(ProjectBuildArgs args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ProjectBuilding\TemplateProjectBuilder.cs:line 56 at Volo.Abp.Cli.Commands.NewCommand.ExecuteAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\Commands\NewCommand.cs:line 148 at Volo.Abp.Cli.CliService.RunAsync(String[] args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 59

Showing 21 to 24 of 24 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11