XAF 自定义用户与角色的例子

1、How to: Use Custom Logon Parameters and Authentication

2、How to: Implement Custom Security Objects (Users, Roles, Operation Permissions)

3、How to: Use Active Directory and OAuth2 Authentication Providers in Blazor Applications

4、How to: Implement a Custom Security System User Based on an Existing Business Class

      XAF Blazor UI: External Authentication – Windows Active Directory and OAuth providers (Google, GitHub, Azure AD)

5、Logon Form Controllers and Actions

 6、User Authentication using a Logon Window in Windows Forms Applications

 7、User Authentication Without a Logon Window in Windows Forms Applications

 

10、How to implement the CreatedBy, CreatedOn and UpdatedBy, UpdatedOn properties in a business class

11、How to: Get the Current User in Code

 

**************************

几个重要类:

SecuritySystem   static 类  ,属于  DevExpress.ExpressApp

     通过  Instance  指向一个具体的 安全策略:ISecurityStrategyBase

XafApplicationExtensions  静态扩展类,扩展方法用于获取 安全策略,GetSecurityStrategy(XafApplication)

SecurityStrategy  ----》SecurityStrategyComplex

 

PermissionPolicyUser 继承  BaseObject,实现接口

          IPermissionPolicyUser(成员 IEnumerable<IPermissionPolicyRole(5个成员string Name、bool IsAdministrative、bool CanEditModel、SecurityPermissionPolicy PermissionPolicy等)> Roles),

        ISecurityUserWithRoles(成员  IList<ISecurityRole(成员 string Name)> Roles)

        ISecurityUser(成员 string UserName、bool IsActive)

        IAuthenticationStandardUser(string UserName、bool ChangePasswordOnFirstLogon、bool ComparePassword(string password)、void SetPassword(string password))   

        IAuthenticationActiveDirectoryUser(成员 string UserName) 

 (或 Employee 继续  Person 自行实现接口: IPermissionPolicyUserISecurityUser,ISecurityUserWithRoles、       IAuthenticationStandardUser(或  IAuthenticationActiveDirectoryUser))

 

UserLoginInfo  实现 :ISecurityUserLoginInfo   

        与 PermissionPolicyUser 是 多对一关系,记录登录后,是采用哪种验证方式登录,以及用户名。

 

CustomLogonParameters 自定义登录界面输入的信息, 实现接口: INotifyPropertyChanged, ISerializable, ICustomObjectSerialize, ISupportClearPassword, IAuthenticationStandardLogonParameters

       主要获取两个登录参数:UserName、Password

CustomAuthentication  自定义验证,继承 AuthenticationBase, 

                                         实现接口:IAuthenticationStandard, ISupportChangePasswordOption

      初始化三个:UserType、logonParametersType、LogonParameters(object

     object Authenticate(IObjectSpace objectSpace)  核心:验证方法。

     void Logoff()   退出登录方法。

 

 

 

 

 

 

 

 


  

posted @ 2021-06-13 18:36  eccorp  阅读(174)  评论(0编辑  收藏  举报