Skip to content

Commit 0c1faa7

Browse files
MapControllers correctly
1 parent 754246a commit 0c1faa7

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/ServiceControl.Hosting/Auth/HostApplicationBuilderExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public static void AddServiceControlAuthentication(this IHostApplicationBuilder
9393
}
9494
};
9595
});
96+
97+
hostBuilder.Services.AddAuthorization(configure =>
98+
configure.FallbackPolicy = new Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder()
99+
.RequireAuthenticatedUser()
100+
.Build());
96101
}
97102

98103
static string GetErrorMessage(JwtBearerChallengeContext context)

src/ServiceControl.Hosting/Auth/WebApplicationExtensions.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ public static class WebApplicationExtensions
66
{
77
public static void UseServiceControlAuthentication(this WebApplication app, bool authenticationEnabled = false)
88
{
9-
if (authenticationEnabled)
9+
if (!authenticationEnabled)
1010
{
11-
app.UseAuthentication();
12-
app.UseAuthorization();
13-
app.MapControllers().RequireAuthorization();
14-
}
15-
else
16-
{
17-
app.MapControllers();
11+
return;
1812
}
13+
14+
app.UseAuthentication();
15+
app.UseAuthorization();
1916
}
2017
}
2118
}

src/ServiceControl/WebApplicationExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ public static void UseServiceControl(this WebApplication app, ForwardedHeadersSe
1818
app.UseHttpLogging();
1919
app.MapHub<MessageStreamerHub>("/api/messagestream");
2020
app.UseCors();
21+
app.MapControllers();
2122
}
2223
}

0 commit comments

Comments
 (0)