forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOwinHttpConfigurationExtensions.cs
More file actions
37 lines (34 loc) · 1.8 KB
/
Copy pathOwinHttpConfigurationExtensions.cs
File metadata and controls
37 lines (34 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Web.Http.Filters;
using System.Web.Http.Owin;
namespace System.Web.Http
{
/// <summary>Provides extension methods for the <see cref="HttpConfiguration"/> class.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static class OwinHttpConfigurationExtensions
{
/// <summary>Enables suppression of the host's default authentication.</summary>
/// <param name="configuration">The server configuration.</param>
/// <remarks>
/// When the host's default authentication is suppressed, the current principal is set to anonymous upon
/// entering the <see cref="HttpServer"/>'s first message handler. As a result, any default authentication
/// performed by the host is ignored. The remaining pipeline within the <see cref="HttpServer"/>, including
/// <see cref="IAuthenticationFilter"/>s, is then the exclusive authority for authentication.
/// </remarks>
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope",
Justification = "Message handler should be disposed with parent configuration.")]
public static void SuppressDefaultHostAuthentication(this HttpConfiguration configuration)
{
if (configuration == null)
{
throw new ArgumentNullException("configuration");
}
Contract.Assert(configuration.MessageHandlers != null);
configuration.MessageHandlers.Insert(0, new PassiveAuthenticationMessageHandler());
}
}
}