惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Register - Security
The Register - Security
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
GbyAI
GbyAI
WordPress大学
WordPress大学
博客园 - 【当耐特】
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
S
SegmentFault 最新的问题
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
腾讯CDC
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
Last Week in AI
Last Week in AI
Engineering at Meta
Engineering at Meta
D
DataBreaches.Net
C
Check Point Blog
G
Google Developers Blog
有赞技术团队
有赞技术团队
I
InfoQ
T
The Blog of Author Tim Ferriss
F
Full Disclosure
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
T
Tenable Blog
Know Your Adversary
Know Your Adversary
N
Netflix TechBlog - Medium
H
Hacker News: Front Page
C
Cyber Attacks, Cyber Crime and Cyber Security
Project Zero
Project Zero
Latest news
Latest news
Recorded Future
Recorded Future
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
News | PayPal Newsroom
C
Cisco Blogs
T
Tor Project blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
Secure Thoughts
A
Arctic Wolf

博客园 - lovebanyi

Memory stream is not expandable 博客园密文招聘的解密 微软Azure平台 cloud service动态申请证书并绑定证书碰到的坑 PInvoke在 2.0 3.0的时候正常 升级到4.0后出错。 不要进行过度设计,某一层存在真的有意义吗?是否可以更简单。 Ajax加载子域跨站cookie丢失的问题. Exists 比Contains 慢非常多。 ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" can not work - lovebanyi 支付系统会碰到的漏洞问题。 值类型引用类型List Remove 方法Remove不掉哪一个项。 流程变换与抽象 Compiler Error Message: CS1513: } expected 如何用好SVN的Branch EntityFramework Any 生成的sql语句超长。 Quartz 的SB问题 GetNextValidTimeAfter 输出和输出 时区 不同步,好傻的方法? 新的一家公司Web开发选择的控件是Dev Express 太烂了,发现项目结构也是混乱的。 使用lambda表达式对属性进行验证。 数据库连接字符串配置的流程改进 从解放劳动力来看未来的科技进程
化繁为简 定义权限
lovebanyi · 2015-03-12 · via 博客园 - lovebanyi
        public static class Tickets
        {
            public const string GroupName = "Tickets";



            public const string CreateTicket = "tickets:ticket:create";
            public const string NameOfCreateTicket = "Create ticket";

            public const string EditTicket = "users:user:edit";
            public const string NameOfEditTicket = "Edit ticket";

            public const string DeleteTicket = "tickets:ticket:delete";
            public const string NameOfDeleteTicket = "Delete ticket";


        }


public GetPermissions(){
return new List<PredefinedPermission>(){
     new PredefinedPermission(Tickets.ViewAllTickets,Tickets.NameOfViewTickets,Tickets.GroupName),
                new PredefinedPermission(Tickets.CreateTicket,Tickets.NameOfCreateTicket,Tickets.GroupName),
                new PredefinedPermission(Tickets.EditTicket,Tickets.NameOfEditTicket,Tickets.GroupName),
                new PredefinedPermission(Tickets.DeleteTicket,Tickets.NameOfViewTickets,Tickets.GroupName),
}}

第一个地方因为改进成

使用Enum

	[Description("Tickets")]
	public enum Tickets{
	[Description("View all ticket")]
ViewAll,

Edit,

Delete,

}

第二个改成反射的方式来获取所有的写好的权限。