Analog System.Security.Permissions in .NET Core

2019-07-29 10:52发布

问题:

I am trying to port project to .NET Core, but can't find analog System.Security.Permissions. Project uses construction like that

[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")] or [EnvironmentPermission(SecurityAction.LinkDemand, Unrestricted = true)], ''

回答1:

Code Access Security isn't and won't be available in .Net Core. Since all code is effectively running under full trust, it should be enough to remove those attributes.

If you actually want to restrict some code, the recommendation is:

Use operating system provided security boundaries, such as user accounts for running processes with the least set of privileges.