public static bool TryExtract(BindingParameterCollection collection, out AuthenticationSchemes authenticationSchemes) { Fx.Assert(collection != null, "collection != null"); authenticationSchemes = AuthenticationSchemes.None; AuthenticationSchemesBindingParameter instance = collection.Find <AuthenticationSchemesBindingParameter>(); if (instance != null) { authenticationSchemes = instance.AuthenticationSchemes; return(true); } return(false); }
internal static AuthenticationSchemes GetEffectiveAuthenticationSchemes(AuthenticationSchemes currentAuthenticationSchemes, BindingParameterCollection bindingParameters) { if (bindingParameters == null) { return(currentAuthenticationSchemes); } AuthenticationSchemes hostSupportedAuthenticationSchemes; if (!AuthenticationSchemesBindingParameter.TryExtract(bindingParameters, out hostSupportedAuthenticationSchemes)) { return(currentAuthenticationSchemes); } // TODO: Add logic for Metadata endpoints to inherit authentication scheme of host. This might not be necessary, needs more thought. //if (currentAuthenticationSchemes == AuthenticationSchemes.None || // (AspNetEnvironment.Current.IsMetadataListener(bindingParameters) && // currentAuthenticationSchemes == AuthenticationSchemes.Anonymous && // hostSupportedAuthenticationSchemes.IsNotSet(AuthenticationSchemes.Anonymous))) //{ // //Inherit authentication schemes from host. // //This logic of inheriting from the host for anonymous MEX endpoints was previously implemented in HostedAspNetEnvironment.ValidateHttpSettings. // //We moved it here to maintain the pre-multi-auth behavior. (see CSDMain 183553) // if (!hostSupportedAuthenticationSchemes.IsSingleton() && // hostSupportedAuthenticationSchemes.IsSet(AuthenticationSchemes.Anonymous) && // AspNetEnvironment.Current.AspNetCompatibilityEnabled && // AspNetEnvironment.Current.IsSimpleApplicationHost && // AspNetEnvironment.Current.IsWindowsAuthenticationConfigured()) // { // // Remove Anonymous if ASP.Net authentication mode is Windows (Asp.Net would not allow anonymous requests in this case anyway) // hostSupportedAuthenticationSchemes ^= AuthenticationSchemes.Anonymous; // } // return hostSupportedAuthenticationSchemes; //} //else //{ //build intersection between AuthenticationSchemes supported on the HttpTransportbidningELement and ServiceHost/IIS return(currentAuthenticationSchemes & hostSupportedAuthenticationSchemes); //} }