Currently we are having problem in upgrading to Sitecore 9.1 Problem started to happen after Sitecore 9.1 introduced IdentityServer based authentication.
Sitecore 9.1 uses <add key="owin:appStartup" value="Sitecore.Owin.Startup, Sitecore.Owin" />
which becomes a problem because we have our own Identity server which is being used to authenticate our user for our website. We rather loaded our own Startup
from custom assembly.
<add key="owin:appStartup" value="AssemblyA.Identity.Startup, AssemblyA.Identity" />
.
Our users are completely separate from Sitecore users. They don't need to participate in any sitecore content related activities. As for now the startup is already occupied by Sitecore.Owin
, we cannot load our assemblies and as a result website login is broken.
But we also don't want to disable the Sitecore's own identity based login for experience editor.
Can we keep both system running side by side? Right now this is a hinder for upgrading Sitecore 9.1
I used XP0-SingleDeveloper.ps1
scirpt for installation.
I tried to inject our CookieAuthenticationOptions through pipeline.
My patch:
<owin.initialize>
<processor type="ABC.Core.Identity.CookieAuthentication, ABC.Core.Identity" resolve="true" patch:before="processor[@method='Authenticate']" />
</owin.initialize>
Processor code:
public override void Process(InitializeArgs args)
{
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>();
args.App.UseCookieAuthentication(new CookieAuthenticationOptions
{
CookieName = "abc.private.cookies",
AuthenticationType = "Cookies"
});
args.App.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "TempCookie",
AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive,
});
}
after applying this code I am getting following error:
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Sitecore.Owin.Authentication
at Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.SignIn.RemoveTicket.Process(SignInArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Owin.Authentication.Security.Cookies.DefaultCookieAuthenticationProvider.ResponseSignIn(CookieResponseSignInContext context)
I have also tried to avoid this error by aborting pipeline using patch.
<owin.cookieAuthentication.signIn>
<processor type="ABC.Core.Identity.ABCSignIn, ABC.Core.Identity" resolve="true" patch:before="*" />
</owin.cookieAuthentication.signIn>
public override void Process(SignInArgs args)
{
if (args.Context.AuthenticationType == "Cookies")
{
string currentTicketId = TicketManager.GetCurrentTicketId();
args.AbortPipeline();
}
}
It skips the pipeline but gives another error:
[ArgumentNullException: Null ids are not allowed.
Parameter name: name]
Sitecore.Diagnostics.Assert.ArgumentNotNullOrEmpty(String argument, String argumentName) +105
Sitecore.Security.Accounts.Account..ctor(String name, AccountType accountType) +37
Sitecore.Security.Accounts.User..ctor(IPrincipal innerUser) +87
Sitecore.Security.Accounts.User.FromPrincipal(IPrincipal principal) +59
Sitecore.Pipelines.HttpRequest.BeginDiagnostics.ResolveUser() +60
Sitecore.Pipelines.HttpRequest.BeginDiagnostics.Process(HttpRequestArgs args) +43
(Object , Object ) +14
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
Sitecore.Web.RequestEventsHandler.OnPostAuthenticateRequest(HttpContextBase context) +214
Sitecore.Nexus.Web.HttpModule.(Object , EventArgs ) +307
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +91
Sitecore.Owin.Startup
to create a startup class that executes both Sitecore's and your own code?