-
Notifications
You must be signed in to change notification settings - Fork 458
Sort out whether AllowPartiallyTrustedCallers gets defined #248
Description
I think the removal of System.Security.AllowPartiallyTrustedCallers assembly attribute from Windsor should be listed under "Breaking Changes" (@alinapopa)
I thought Castle Core was defining the attribute and so I was going to say it should go back in, however it appears the attribute was never defined out of the box for Castle Core.
For Castle Core:
- Prior to v4 you could specify a property to get it to be defined: https://github.com/castleproject/Core/blob/v3.3.3/buildscripts/Castle.Common.Targets#L115
- With the v4 work it got moved to being conditionally compiled if
FEATURE_APTCAwas defined so it could be enabled on .NET Core: https://github.com/castleproject/Core/blob/v4.0.0/buildscripts/CommonAssemblyInfo.cs#L51-L53
I mentioned this file already to @Fir3pho3nixx in castleproject/Core#261 (comment) where it got removed in a open PR.
Interesting that Windsor was always defining the attribute and then had the option to define it in the build scripts:
- https://github.com/castleproject/Windsor/blob/v3.4.0/src/Castle.Windsor/SecurityAssemblyInfo.cs#L4
- https://github.com/castleproject/Windsor/blob/v3.4.0/buildscripts/Castle.Common.Targets#L118
Looking at MSDN I think these two remarks are the reason APTCA got all messed up and we didn't want to always define it:
- "The .NET Framework 4 introduces new security rules that affect the behavior of the AllowPartiallyTrustedCallersAttribute attribute (see Security-Transparent Code, Level 2). In the .NET Framework 4, all code defaults to security-transparent, that is, partially trusted. However, you can annotate individual types and members to assign them other transparency attributes. For this and other security changes, see Security Changes in the .NET Framework."
- "Caution: The presence of this assembly-level attribute prevents the default behavior of placing FullTrustLinkDemand security checks, and makes the assembly callable from any other (partially or fully trusted) assembly."
- (https://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute(v=vs.110).aspx)
We should make a decision whether we want this in the code and then implement it in both Castle Core and Windsor.