Ensuring the correct IPrincipal and IIdentity with PrincipalPermission

I have defined a custom IPrincipal and a custom IIdentity based on a website that defines both valid identifiers and their permissions. Both of these classes are intended for use in the assembly used in a Windows forms application.

The question is, when using the declarative attribute PrincipalPermission on top of my assembly classes, how to ensure that my custom IPrincipal and IIdentity classes are used, and not some other IPrincipal / IIdentity that can be authenticated.

[PrincipalPermission(SecurityAction.Demand, Authenticated = true, Role = "limited")]
public class RequiresAuthentication
{ }
+3
source share
3 answers

: (IP), IIdentity IPrincipal, (RP), .

RP , IPrincipal, .

, , IP-. , , - IIdentity IPrincipal.

IP- , , IPrincipal .

EDIT:

, , , , "limited", IP- . , , , . , , URI . , , IPrincipal, , , - IP-.

Windows Identity Foundation ( , ) , .

+2

, , .

PrincipalPermission ( PrincipalPermissionAttribute) Thread.CurrentPrincipal, , IPrincipal .

, IPrincipal, CustomPrincipalPermission, PrincipalPermission.

+2

/.

, CodeAccessSecurityAttribute, CreatePermission, ( IPermission IUnrestrictedPermission), . , . , , .

[MyPrincipalPermission(SecurityAction.Demand, Roles = MyRoles.Limited)]
public void Foo() { ... }

- , Intersect, Union .., , , , - 2-5 , , .

0

Source: https://habr.com/ru/post/1721986/


All Articles