Skip to content

Instantly share code, notes, and snippets.

@moo2u2
Last active February 24, 2021 01:40
Show Gist options
  • Save moo2u2/d50a9cfb9a957fec4e7d2f8631658a12 to your computer and use it in GitHub Desktop.
Save moo2u2/d50a9cfb9a957fec4e7d2f8631658a12 to your computer and use it in GitHub Desktop.
Version of Sitecore's CustomGetStartUrl processor for sites using CallbackAuthority setting
using Sitecore.Abstractions;
using Sitecore.Owin.Authentication.IdentityServer.Extensions;
using Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.SignedIn;
using Sitecore.Pipelines.GetStartUrl;
using Sitecore.Sites;
using System;
namespace Identity.Pipelines.CookieAuthentication.SignedIn
{
public class CustomGetStartUrl : Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.SignedIn.GetStartUrl
{
BaseSettings Settings { get; }
public CustomGetStartUrl(BaseCorePipelineManager corePipelineManager, BaseSiteContextFactory siteContextFactory, BaseLog log, BaseSettings settings)
: base(corePipelineManager, siteContextFactory, log)
{
Settings = settings;
}
public override void Process(SignedInArgs args)
{
SiteContext site = args.Site;
if (site.IsBackend)
site = SiteContextFactory.GetSiteContext("shell");
string callbackAuthority = Settings.IdentityServer().CallbackAuthority;
Uri baseUrl = args.Context.Request.Uri;
if(!string.IsNullOrEmpty(callbackAuthority))
Uri.TryCreate(callbackAuthority, UriKind.Absolute, out baseUrl);
GetStartUrlArgs newArgs = new GetStartUrlArgs(args.User.InnerUser, site, baseUrl, args.Context.Options.ReturnUrlParameter)
{
AppendClientLanguage = true
};
GetStartUrlPipeline.Run(CorePipelineManager, newArgs, Log);
args.StartUrl = newArgs.Result.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment