c# - Claims permission check fails when ClaimsPrincipalPermission is applied to class & method within it -


i have following class:

[claimsprincipalpermission(securityaction.demand, operation = "view", resource = "agreement")] public class agreementviewmodel : screen {     [claimsprincipalpermission(securityaction.assert, operation = "save", resource = "agreement")]     public async void save()     {     } } 

my problem though principal has both claims specified above, call save fails. if take off claims class level works fine. class instantiates fine. "manual" check figure out if user can execute action works fine, it's actual execution fails. manual check defined following:

    public bool canexecute(object sender, [callermembername] string callermethod = null)     {         string targetmethodname = callermethod;         if (callermethod == null)             return true;         if (callermethod.startswith("can"))             targetmethodname = callermethod.substring(3, callermethod.length - 3);         if (string.isnullorempty(targetmethodname))             return true;         var claimsattribute = sender.gettype().getmethods()             .where(x => x.name == targetmethodname)             .selectmany(x => x.getcustomattributes(typeof(claimsprincipalpermissionattribute), true).cast<claimsprincipalpermissionattribute>())             .firstordefault();         return canexecute(claimsattribute);     }     private bool canexecute(claimsprincipalpermissionattribute claimsattribute)     {         if (claimsattribute == null)             return true;         try         {             claimsattribute.createpermission().demand();         }         catch (securityexception)         {             return false;         }         return true;     } 


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -