本文章同步发表于 https://blog.exfast.me/2019/01/netcore-lexlibrary-rbac-based-on-role-based-access-control-implementation-verification-module/
LexLibrary.Rbac
本专案基于 Role-based access control 实作下列模组
登入 & 登出注册 & 验证 Email忘记密码 & 重设密码角色模组功能模组验证授权状态 (可限制登入装置数量)基本资料维护专案演示
网址:https://exfast-lexlibrary-rbac-sample.azurewebsites.net/
帐号:admin
密码:zxcv1234
信箱:admin@exfast.me
GitHub:https://github.com/shuangrain/LexLibrary.Rbac
加入专案
验证模组
找到 Startup.cs
中的 ConfigureServices
方法新增下列程式
services.AddLexLibraryRbac(options =>{ options.UseSqlServer(_configuration.GetConnectionString("DefaultConnection"));});// 请自行实作 ICryptHelper, IEmailSender 介面services.AddScoped(typeof(ICryptHelper), typeof(CryptHelper));services.AddScoped(typeof(IEmailSender), typeof(EmailSender));
预设页面(选用)
找到 Startup.cs
中的 Configure
方法新增下列程式
app.UseLexLibraryRbacRoute();
验证方法
在需要验证的 Controller 或 Action 上方加入验证标籤即可
[LexLibraryRbacAuthorize(FunctionIds = "1", RoleIds = "2,1")]