Skip to main content

Posts

Showing posts with the label Code Security

Authenticating and Authorizing in .Net

Namespace: System.Security.Principal Authenticating is the process of checking a user’s identity. Authorization means verifying user’s right to access the resources according to his identity. Usually authorization happens after authentication . Integrate system with Active Directory using WindowsIdentity and WindowsPrincipal . For straight-forward database, use GenericIdentity and GenericPrincipal . For a better control over user and roles implement IIdentity and IPrinciapl . WindowsIdentity Class : This class represents a windows account, along with user name and authentication code. Instance of WindowsIdentity can be created using: 1.        GetAnonymous : Returns WindowsIdentity Object of an unauthenticated user, which is used to insure that your code runs successfully. 2.        GetCurrent : Returns WindowsIdentity that represents the current logged in user. 3.    ...

Declarative Security to Protect Assemblies

Namespace: System.Security.Permissions What is Declarative Code Access Security?                 Declarative Code Access security helps in restricting access to different resources; it also intimates the user if assembly required resource can’t be granted at the time of loading; it also helps in predetermining the resources an application require to run and it also protects system and resource from an attacker who intends to access unintended/protected resources. It also makes fine-tuned permission outline to make your application run in partially-trusted zone. Because permission attribute classes are inherited from CodeAccesSecurityAttribute they share the following two most common properties . Action :                  Specifies the security action to take. Use SecurityAction enumeration. Unrestricted : ...

Code Access Security in .Net

Namespace: System.Security What is Code Access Security? Code Access Security is a mechanism through which Developers and administrators can restrict code from accessing different resources , without caring about the users’ access level. You can also control resource that can’t be controlled through traditional RBS (Role Based Security), e.g. Web Requests and DNS requests etc. It can be only applied to Managed Applications. These restriction are applied not to the user instead to the Application, thus it does not require username or password. Evidence: It is the information that runtime gather about the assembly to determine which Code Groups the assembly belongs to. The following table shows the common types of evidence that a host can present to the runtime. Evidence Description Application directory The application's installation directory. Hash Cryptographic hash such as SHA1. Publisher Soft...