简体   繁体   English

为基于声明的安全性实现自定义属性

[英]Implementing custom atributes for claims based security

I am trying to implement claims based security using System.IdentityModel. 我正在尝试使用System.IdentityModel实现基于声明的安全性。 We are using Windows XP for all development work and therefore cannot use Windows Identity Foundation. 我们将Windows XP用于所有开发工作,因此无法使用Windows Identity Foundation。 What I am trying to do is decorate methods in service contract with permission attributes, I am not sure how to do that 我想做的是用权限属性修饰服务协定中的方法,我不确定该怎么做

For example in my service I want to have method 例如在我的服务中,我想使用方法

void DeleteRecord(int recordId); void DeleteRecord(int recordId);

I want to decorate it with an attribute like this 我想用这样的属性装饰它

[HasDeletePermission] void DeleteRecord(int recordId); [HasDeletePermission] void DeleteRecord(int recordId);

So based on the claimset user has, method will either execute or exception will be thrown. 因此,基于用户拥有的Claimset,方法将执行或抛出异常。 How do I achieve this. 我该如何实现。

您可以使用PostSharp之类的东西将方面嵌入所需的方法中。

Used PostSharp free edition to implement attribute. 使用PostSharp免费版实现属性。 Works well 效果很好

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

相关问题 在 .NET 中使用自定义授权属性实现基于声明的动态身份验证 6 - Implementing dynamic claims-based auth with custom authorization attribute in .NET 6 将授权属性与基于自定义声明的身份验证一起使用 - Use Authorize Attribute with Custom Claims based Authentication 根据声明注入自定义创建的对象 - Inject custom created object based on claims 实现自定义代码访问安全性的IPermission - Implementing IPermission for custom code access security 如何使用SDK连接到CRM(基于声明的身份验证和自定义STS) - How to connect to CRM using SDK (claims based authentication and custom STS) 使用VS 2013和ADFS 2.0在ASP.NET WebApi中实现基于声明的身份验证 - Implementing Claims based authentication in ASP.NET WebApi using VS 2013 and ADFS 2.0 将自定义声明放入安全令牌中,并在ASP.NET Web API中创建 - Put custom claims into security token and create it in ASP.NET Web API System.Security.Claims缺失 - System.Security.Claims missing 基于索赔和政策的授权 - Claims and policy based Authorization 请求其他索赔Owin Security - Request additional claims Owin Security
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM