2

we are integrating OKTA authentication with Sitecore CD. For this we are using sitecore federated auth.we have written custom identifier class and its working fine. Also we have written sitecore pipelne on HttpBeginRequest which should redirect to okta if user is not authenticated. But below code is not redirecting to okta site for authentication

namespace OKTA.Pipelines.HttpBeginRequest
{
    public class CustomProcessor : HttpRequestProcessor
    {
        public override void Process(HttpRequestArgs args)
        {

            if (!Context.User.Identity.IsAuthenticated)
            {
                HttpContext.Current.GetOwinContext().Authentication.Challenge(
                    new AuthenticationProperties { RedirectUri = "/" },
                    OpenIdConnectAuthenticationDefaults.AuthenticationType);

            }
        }
   }

}
1

There is a slight difference in how Sitecore gets the appropriate string[] collection. In your case you can pass the name of the id parameter , set in the federated auth config file for Okta. Also,ensure to test this in incognito or clear browser cache.

<identityProviders hint="list:AddIdentityProvider">
        <identityProvider id="Okta"

Similar code for Azure Adb2C - How to get Sitecore.Context.User after redirect from Azure ADb2c login?

[Route("LoginForm/SignIn")]
        public void SignIn()
        {
            if (!Request.IsAuthenticated)
            {
                HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties() { RedirectUri = "/" },
                    new string[] { "Okta", Startup.SignInSignUpPolicyId });
            }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.