Backoffice User Access Control

在Backoffice中,配置不同用户对于不同的Item的操作权限都在文件xxx-access-rights.impex中配置,例子如下:

$START_USERRIGHTS;;;;;;;;;
Type;UID;MemberOfGroups;Password;Target;read;change;create;remove;change_perm
UserGroup;productmanagergroup;cockpitgroup;;;;;;;

# Access Rights for Products & Catalog;;;;;;;;;
;;;;ItemSyncTimestamp;+;;;
;;;;SyncItemJob;+;;;
;;;;Type;+;;;
;;;;Product;+;+;+;+;+;
;;;;Category;+;+;+;+;+;
;;;;variantType;+;+;+;+;+;
;;;;Catalog;+;;;
;;;;CatalogVersion;+;+;+;+;+;
;;;;ClassificationAttributeUnit;+;;;
;;;;Media;+;+;+;+;+;
;;;;MediaContainer;+;+;+;+;+;
;;;;MediaFormat;+;+;+;+;+;
;;;;MediaFolder;+;+;+;+;+;
;;;;Vendor;+;+;+;+;+;
;;;;StockLevel;+;+;+;+;+;
;;;;Tax;+;+;+;+;+;
;;;;TaxRow;+;+;+;+;+;
;;;;PriceRow;+;+;+;+;+;
;;;;ProductFeature;+;+;+;+;+;
;;;;ProductReference;+;+;+;+;+;
;;;;Warehouse;+;+;+;+;+;
;;;;ProductTaxCode;+;+;+;+;+;
;;;;ProductOrderLimit;+;+;+;+;+;


$END_USERRIGHTS;;;;;

这里的Impex主要更新ACL Entries( (Table «aclentries»)),该表主要作用是处理用户权限相关:Access Control Lists (Permission-User-Item)

但是在处理Product的时候会发现,即使在这里配置了权限,在EditorArea中也不能编辑产品,查看源码发现,Editor是否可以编辑由EditorContext中的属性isEditable决定,所以找到isEditable的设置逻辑就可以找到此问题的根源。

具体逻辑在DefaultPlatformPermissionFacadeStrategy中实现,具体方法为canReadInstance

public boolean canReadInstance(Object instance) {
    String type = this.typeFacade.getType(instance);
    return this.canReadType(type) && this.canReadCatalogVersionAwareInstance(instance);
}

其中前一部分为上文中提到的权限配置表ACL Entries中配置,后一部分判断该Item是否具有CatalogVersion,如果有,则需要在Principal2ReadableCatalogVersionRelation中配置,例子如下:

UPDATE CatalogVersion;catalog(id)[unique=true];version[unique=true];writePrincipals(uid);
;electronicsProductCatalog;Online;productmanagergroup,productmanager;
;electronicsProductCatalog;Staged;productmanagergroup,productmanager;

这样,ProductManagerGroup和ProductManager都可以编辑产品了。

当然如果有更复杂的需求,我们还可以通过覆盖和扩展DefaultPlatformPermissionFacadeStrategy来实现,Hybris框架提供了足够灵活的扩展空间来应对权限相关的需求。

参考资料:
https://hybrismart.com/2018/05/06/explaining-hybris-database-structure

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,041评论 19 139
  • 0×1.ACL概述ACL(Access Control List,访问控制列表),是一系列运用到路由器接口的指令列...
    Zero___阅读 2,874评论 0 3
  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 12,243评论 2 33
  • 因为要结局swift3.0中引用snapKit的问题,看到一篇介绍Xcode8,swift3变化的文章,觉得很详细...
    uniapp阅读 4,556评论 0 12
  • 1、心中的是非观越来越模糊,但是我也不会只看利弊。——林子大了,各种鸟都有生存下去的权利和意义,少一些愤世嫉俗。道...
    知笔行阅读 320评论 0 0