Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Resource based authorization#24184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
maliming wants to merge73 commits intodev
base:dev
Choose a base branch
Loading
fromresource-based-auth
Open

Resource based authorization#24184

maliming wants to merge73 commits intodevfromresource-based-auth

Conversation

@maliming
Copy link
Member

@malimingmaliming commentedNov 15, 2025
edited by hikalkan
Loading

Resolves#236

Demo:https://github.com/maliming/AbpResourcePermission

Work to be done

  • ImplementIResourcePermissionChecker in the Permission Management module. This is just for checking permissions, not managing (setting) them. Defined in the framework, so any module can be independent of the Permission Management module, yet can check permissions. We can implement as NullResourcePermissionChecker (just throw not implemented exception for now) in the framework to not get DI exceptions.
  • CreateIResourcePermissionManager to manage (get/set) permissions for resources in the Permission Management module, like the current IPermissionManager service. Implement it in the same place.
  • Create an app service to provide application logic to manage resource permissions.
  • Define a resource permission management modal, which should be reusable, like the current permission management modal.

Demo

maliming/AbpResourcePermission@7cb3269

Define resource permissions:

publicclassBookStorePermissionDefinitionProvider:PermissionDefinitionProvider{publicoverridevoidDefine(IPermissionDefinitionContextcontext){AddBookStoreResourcePermission(context);}privatestaticLocalizableStringL(stringname){returnLocalizableString.Create<BookStoreResource>(name);}}

Add resource permissions property to the DTO class.

publicclassBookDto:AuditedEntityDto<Guid>,IHasResourcePermissions{publicstringName{get;set;}//...publicDictionary<string,bool>ResourcePermissions{get;set;}publicstringGetResourceKey(){returnId.ToString();}}

UseResourcePermissionPopulator to populate the resource permissions:

publicoverrideasyncTask<BookDto>GetAsync(Guidid){//...varbookDto=ObjectMapper.Map<Book,BookDto>(queryResult.book);await_resourcePermissionPopulator.PopulateAsync(bookDto,typeof(Book).FullName!);returnbookDto;}publicoverrideasyncTask<PagedResultDto<BookDto>>GetListAsync(PagedAndSortedResultRequestDtoinput){//...varbookDtos=queryResult.Select(x=>{varbookDto=ObjectMapper.Map<Book,BookDto>(x.book);bookDto.AuthorName=x.author.Name;returnbookDto;}).ToList();await_resourcePermissionPopulator.PopulateAsync(bookDtos,typeof(Book).FullName!);returnnewPagedResultDto<BookDto>(totalCount,bookDtos);}

UseIAuthorizationService to check resource permissions in the backend app:

varbooks=awaitBookRepository.GetListAsync();varresourvePermissions=newDictionary<string,bool>();foreach(varbookinbooks){resourvePermissions[book.Name]=awaitAuthorizationService.IsGrantedAsync(book,BookStorePermissions.Resources.ChangeBookName);}

Screenshots:

imageimageimageimage

hikalkanand others added21 commitsNovember 7, 2025 16:30
@malimingmaliming mentioned this pull requestNov 15, 2025
8 tasks
@malimingmaliming added this to the10.1-preview milestoneNov 15, 2025
malimingand others added22 commitsNovember 20, 2025 15:55
Added the IKeyedObject interface to provide a standard way to retrieve object keys, including support for composite keys via KeyedObjectHelper. Updated IEntity, IEntityDto, and related DTOs to implement IKeyedObject, and refactored resource permission logic to use GetObjectKey for key retrieval. This change improves consistency and reliability in handling object keys across the framework.
Introduced the GetObjectKey method to MyEntity, returning the string representation of the entity's Id. This may be used for scenarios requiring a unique key in string format.
Introduces unit tests for encoding and decoding composite keys in the KeyedObjectHelper class, verifying correct behavior for various input scenarios.
Removed all usages of JetBrains.Annotations attributes and related imports from resource permission interfaces and context classes. Reformatted method signatures and constructors for better readability and consistency.
The class ResourcePermissionExtenstions was renamed to KeyedObjectResourcePermissionExtenstions to better reflect its purpose and usage.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@hikalkanhikalkanAwaiting requested review from hikalkan

@EngincanVEngincanVAwaiting requested review from EngincanV

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

Projects

None yet

Milestone

10.1-preview

Development

Successfully merging this pull request may close these issues.

Resource based authorization integration

3 participants

@maliming@hikalkan

[8]ページ先頭

©2009-2025 Movatter.jp