re-adds test scheme for test authn/authz
This commit is contained in:
@@ -14,8 +14,9 @@ namespace Umbraco.Tests.Integration.TestServerTest
|
||||
{
|
||||
public class TestAuthHandler : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||
{
|
||||
private readonly IBackOfficeSignInManager _backOfficeSignInManager;
|
||||
public const string TestAuthenticationScheme = "Test";
|
||||
|
||||
private readonly IBackOfficeSignInManager _backOfficeSignInManager;
|
||||
|
||||
private readonly BackOfficeIdentityUser _fakeUser;
|
||||
public TestAuthHandler(IOptionsMonitor<AuthenticationSchemeOptions> options,
|
||||
@@ -33,7 +34,7 @@ namespace Umbraco.Tests.Integration.TestServerTest
|
||||
{
|
||||
|
||||
var principal = await _backOfficeSignInManager.CreateUserPrincipalAsync(_fakeUser);
|
||||
var ticket = new AuthenticationTicket(principal, Constants.Security.BackOfficeAuthenticationType);
|
||||
var ticket = new AuthenticationTicket(principal, TestAuthenticationScheme);
|
||||
|
||||
return AuthenticateResult.Success(ticket);
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace Umbraco.Tests.Integration.TestServerTest
|
||||
builder.ConfigureTestServices(services =>
|
||||
{
|
||||
// Add a test auth scheme with a test auth handler to authn and assign the user
|
||||
services.AddAuthentication(Constants.Security.BackOfficeAuthenticationType)
|
||||
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>(Constants.Security.BackOfficeAuthenticationType, options => { });
|
||||
services.AddAuthentication(TestAuthHandler.TestAuthenticationScheme)
|
||||
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>(TestAuthHandler.TestAuthenticationScheme, options => { });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Umbraco.Tests.Integration.TestServerTest
|
||||
.AddRuntimeMinifier()
|
||||
.AddBackOffice()
|
||||
.AddBackOfficeIdentity()
|
||||
.AddBackOfficeAuthorizationPolicies()
|
||||
.AddBackOfficeAuthorizationPolicies(TestAuthHandler.TestAuthenticationScheme)
|
||||
.AddPreviewSupport()
|
||||
//.WithMiniProfiler() // we don't want this running in tests
|
||||
.AddMvcAndRazor(mvcBuilding: mvcBuilder =>
|
||||
|
||||
@@ -62,9 +62,9 @@ namespace Umbraco.Extensions
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static IUmbracoBuilder AddBackOfficeAuthorizationPolicies(this IUmbracoBuilder builder)
|
||||
public static IUmbracoBuilder AddBackOfficeAuthorizationPolicies(this IUmbracoBuilder builder, string backOfficeAuthenticationScheme = Umbraco.Core.Constants.Security.BackOfficeAuthenticationType)
|
||||
{
|
||||
builder.Services.AddBackOfficeAuthorizationPolicies(Umbraco.Core.Constants.Security.BackOfficeAuthenticationType);
|
||||
builder.Services.AddBackOfficeAuthorizationPolicies(backOfficeAuthenticationScheme);
|
||||
// TODO: See other TODOs in things like UmbracoApiControllerBase ... AFAIK all of this is only used for the back office
|
||||
// so IMO these controllers and the features auth policies should just be moved to the back office project and then this
|
||||
// ext method can be removed.
|
||||
|
||||
Reference in New Issue
Block a user