Skip to content

Commit 2c7945e

Browse files
authored
Defaulting SwtAuthenticationEnabled to False (#10192)
1 parent 3d401d3 commit 2c7945e

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/WebJobs.Script/Config/FunctionsHostingConfigOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ internal bool SwtAuthenticationEnabled
6666
{
6767
get
6868
{
69-
return GetFeatureAsBooleanOrDefault(ScriptConstants.HostingConfigSwtAuthenticationEnabled, true);
69+
return GetFeatureAsBooleanOrDefault(ScriptConstants.HostingConfigSwtAuthenticationEnabled, false);
7070
}
7171

7272
set

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/SamplesEndToEndTests_CSharp.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,10 @@ public override void ConfigureWebHost(IServiceCollection services)
13911391
{
13921392
base.ConfigureWebHost(services);
13931393

1394+
// SWT auth is disabled by default so we must enable to test
1395+
services.AddOptions<FunctionsHostingConfigOptions>()
1396+
.Configure(o => o.SwtAuthenticationEnabled = true);
1397+
13941398
// The legacy http tests use sync IO so explicitly allow this
13951399
var environment = new TestEnvironment();
13961400
string testSiteName = "somewebsite";

test/WebJobs.Script.Tests/Configuration/FunctionsHostingConfigOptionsTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ public void Property_Validation()
126126
(nameof(FunctionsHostingConfigOptions.SwtAuthenticationEnabled), "SwtAuthenticationEnabled=False", false),
127127
(nameof(FunctionsHostingConfigOptions.SwtAuthenticationEnabled), "SwtAuthenticationEnabled=True", true),
128128
(nameof(FunctionsHostingConfigOptions.SwtAuthenticationEnabled), "SwtAuthenticationEnabled=0", false),
129-
(nameof(FunctionsHostingConfigOptions.SwtAuthenticationEnabled), "SwtAuthenticationEnabled=unparseable", true), // default
130-
(nameof(FunctionsHostingConfigOptions.SwtAuthenticationEnabled), string.Empty, true), // default
129+
(nameof(FunctionsHostingConfigOptions.SwtAuthenticationEnabled), "SwtAuthenticationEnabled=unparseable", false), // default
130+
(nameof(FunctionsHostingConfigOptions.SwtAuthenticationEnabled), string.Empty, false), // default
131131

132132
// Supports True/False/1/0
133133
(nameof(FunctionsHostingConfigOptions.SwtIssuerEnabled), "SwtIssuerEnabled=False", false),
@@ -251,8 +251,8 @@ public void SwtAuthenticationEnabled_ReturnsExpectedValue()
251251
{
252252
FunctionsHostingConfigOptions options = new FunctionsHostingConfigOptions();
253253

254-
// defaults to true
255-
Assert.True(options.SwtAuthenticationEnabled);
254+
// defaults to false
255+
Assert.False(options.SwtAuthenticationEnabled);
256256

257257
// returns true when explicitly enabled
258258
options.Features[ScriptConstants.HostingConfigSwtAuthenticationEnabled] = "1";

test/WebJobs.Script.Tests/Security/Authentication/ArmAuthenticationHandlerTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.AspNetCore.Authentication;
88
using Microsoft.AspNetCore.Http;
99
using Microsoft.Azure.WebJobs.Extensions.Http;
10+
using Microsoft.Azure.WebJobs.Script.Config;
1011
using Microsoft.Azure.WebJobs.Script.WebHost.Security;
1112
using Microsoft.Azure.WebJobs.Script.WebHost.Security.Authentication;
1213
using Microsoft.Extensions.DependencyInjection;
@@ -19,6 +20,11 @@ public class ArmAuthenticationHandlerTests
1920
private static DefaultHttpContext GetContext()
2021
{
2122
var services = new ServiceCollection().AddLogging();
23+
24+
// SWT auth is disabled by default so we must enable to test
25+
services.AddOptions<FunctionsHostingConfigOptions>()
26+
.Configure(o => o.SwtAuthenticationEnabled = true);
27+
2228
services.AddAuthentication(o =>
2329
{
2430
o.DefaultScheme = ArmAuthenticationDefaults.AuthenticationScheme;

0 commit comments

Comments
 (0)