Re: IPrincipal and IsInRole

From: Nicole Calinoiu (nicolec_at_somewhere.net)
Date: 08/27/04

  • Next message: Nicole Calinoiu: "Re: IPrincipal and IsInRole"
    Date: Fri, 27 Aug 2004 14:46:56 -0400
    
    

    "Arturo" <arturo-g@lycos.com> wrote in message
    news:e1a45d36.0408270311.1d87e844@posting.google.com...
    > Hello. I have a question:
    >
    > My methods are implementing the <PrincipalPermission> attribute and
    > checking through role in the identity. I have implemented my own
    > Principal and Identity object. The user should logon and the info is
    > loaded from a database.
    >
    > If this library exposes public methods and another developer makes a
    > console app and creates it's own implementation of IPrincipal and
    > IIdentity and always returns true in IsInRole, is he going to be able
    > to execute my code?

    Yes. See, for example,
    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconreplacingprincipalobject.asp.
    Please note that SecurityPermission.ControlPrincipal is part of the
    FullTrust named permission set (which a developer can most likely grant to
    any code running on his own machine or have granted to his code on other
    machines), and it can be bypassed anyway by disabling CAS on the machine.
    Also, it doesn't only affect public methods since low accessibility
    (private, internal, protected) members can be accessed via reflection.

    >
    > Is there any way to tag the method to request only Windows security or
    > My own security IPrincipal or IIdentity of type X, but nothing else?

    Yup, but it'll just raise the bar a bit since the developer could decompile
    your library, remove the verifications, and recompile. I agree that this is
    a major PITA but, within the current .NET Framework context, there's not
    much you can do to prevent it if the code executes on a machine that is
    directly or indirectly in your putative malicious and/or ignorant
    developer's control.

    If your code is running on a "safe" machine, your best bet for assuring that
    a specific IPrincipal or IIdentity type may be to create a new
    permission/attribute pair analogous to PrincipalPermission[Attribute].
    Otherwise, you would need to check that the correct type is being used every
    time a target class or member is accessed. The burden of the latter
    approach could be lightened somewhat by using another attribute that simply
    checks the principal type rather than making this verification within the
    target members.

    >
    > Many thanks!


  • Next message: Nicole Calinoiu: "Re: IPrincipal and IsInRole"

    Relevant Pages

    • Re: thread?
      ... Any instance members are not guaranteed to be ... > Am I to conclude that the public methods are thread safe and the protected ... your Thread Safety comment was referring to. ...
      (microsoft.public.dotnet.languages.vb)
    • Re: How to use VB2005 .dll Class Library in VB6 ?s
      ... Intellisense won't pick up your public methods & members without some more ... in VB6 the cla_logging object shows up in the object browser but I don't ...
      (microsoft.public.dotnet.framework.interop)
    • Re: Initializing With a Base Class Instance
      ... In my real-world problem, "Base" is a class with tons of members, and I don't ... want to introduce a new maintenance issue of keeping the copy constructor in ... "Base" is in code that another developer owns. ... > believe C++ creates a default copy constructor anyway. ...
      (microsoft.public.dotnet.languages.csharp)
    • UML Association?
      ... information (members, methods, relationships) and display this ... Also, I do not believe that DEVELOPER should have to know about CLASS, ... asked the CLASS object for all the DEVELOPER objects associated with ...
      (comp.object)