我的CustomAuthorizationPolicy.Evaluate()方法永远不会触发
我创建了一个带有自定义授权和身份validation的wcf服务,如您所见:
public class AuthorizationPolicy : IAuthorizationPolicy { string id = Guid.NewGuid().ToString(); public string Id { get { return this.id; } } public System.IdentityModel.Claims.ClaimSet Issuer { get { return System.IdentityModel.Claims.ClaimSet.System; } } // this method gets called after the authentication stage public bool Evaluate(EvaluationContext evaluationContext, ref object state) { // get the authenticated client identity IIdentity client = HttpContext.Current.User.Identity; // set the custom principal evaluationContext.Properties["Principal"] = new CustomPrincipal(client); System.IO.File.WriteAllText(@"d:a.txt", client.Name); return true; } } public class CustomPrincipal : IPrincipal { private IIdentity _identity; public IIdentity Identity { get { return _identity; } } public CustomPrincipal(IIdentity identity) { System.IO.File.WriteAllText(@"d:a.txt", identity.Name); _identity = identity; } public bool IsInRole(string role) { System.IO.File.WriteAllText(@"d:a.txt", role); return false; } }
使用此webconfig:
和
和
[OperationContract] [PrincipalPermission(SecurityAction.Demand, Role = "Admin")] [WebInvoke(Method = "GET", UriTemplate = "/Data/{data}")] string GetData(string data);
但我的评估function从未解雇过。 为什么?
上述就是C#学习教程:我的CustomAuthorizationPolicy.Evaluate()方法永远不会触发分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1017122.html