简体   繁体   English

链接CanExecute命令方法和授权管理

[英]Linking CanExecute method of commands and authorization management

I want to manage permissions to execute commands and view controls and so on. 我想管理执行命令和查看控件等的权限。 Therefore I have a class UserAction implementing ICommand interface. 因此,我有一个实现ICommand接口的UserAction类。

I want to define UserActions available for the UserManagement using one Enum. 我想使用一个枚举定义可用于UserManagement的UserAction。

For simplifying UserManagement I want to wrap multiple UserActions to UserActivities which permissions are set in a database table. 为了简化UserManagement,我想将多个UserAction包装到UserActivities中,在数据库表中设置了权限。

On runtime I have a Role class which maintains the currently set of permissions (stored as UserActivities), these permissions are likely to change during runtime. 在运行时,我有一个Role类,该类维护当前的权限集(存储为UserActivities),这些权限在运行时可能会更改。

Does anyone know how to manage this CanExecute methods correctly or are there any nice patterns or frameworks meant for this topic? 有谁知道如何正确地管理CanExecute方法,或者有没有适合该主题的好的模式或框架?

I did not find a lot about this for now on the net. 我目前在网上找不到很多有关此的内容。

As a whole what you want to achieve is called externalized authorization management . 总体而言,您要实现的目标称为外部化授权管理 You can consider two different approaches: 您可以考虑两种不同的方法:

  1. Microsoft provides something called claims-based authorization. Microsoft提供了一种称为基于声明的授权。 You can find lots of tutorials on the topic online. 您可以在线找到许多有关该主题的教程。 Here's a great article from 2013 . 这是2013年的精彩文章
  2. You can also fully externalize (and standardize) your authorization by using XACML, the eXtensible Access Control Markup Language which is both an authorization framework as well as a policy language to define your authorization policies. 您还可以使用XACML(可扩展访问控制标记语言,它既是授权框架又是定义您的授权策略的策略语言)来完全外部化(和标准化)您的授权。 Unfortunately .NET doesn't have XACML built-in so you need to add in an external authorization engine (also called policy decision point or PDP). 不幸的是.NET没有内置的XACML,因此您需要添加一个外部授权引擎(也称为策略决策点或PDP)。 There are a couple available from Axiomatics or XEngine (on sourceforge). Axiomatics或XEngine(在sourceforge上)有几个可用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM