Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bobby 1 post 71 karma points notactivated
    Jul 27, 2023 @ 14:03
    Bobby
    0

    ASP Cookie Consent and Umbraco Cloud Login

    I am seeking assistance with an issue related to Microsoft's app.useCookiePolicy() and my Umbraco Project using version 12

    To provide some context, I have implemented Microsoft's app.useCookiePolicy() in my application, which manages cookie policies effectively. The problem arises when I attempt to use this functionality to enable login access to my cloud backoffice. Instead of gaining access, the URL gets stuck in a perpetual login loop, and displays a blank screen.

    I suspect there might be a conflict between app.useCookiePolicy() and the cloud backoffice's authentication mechanism, but I can't pinpoint the exact cause.

    If anyone has encountered a similar issue or has expertise with Microsoft's app.useCookiePolicy() and cloud backoffice logins, I would greatly appreciate your insights and guidance on resolving this problem. Additionally, if you could provide step by step instructions on properly integrating app.useCookiePolicy() , it would be greatly appriciated :)

    my startup.cs code:

    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Rewrite;
    using System.Net;
    using Umbraco.Cms.Core.Services;
    using Microsoft.Extensions.Configuration;
    using Umbraco.Extensions;
    using Microsoft.Net.Http.Headers;
    using System.Configuration;
    
    namespace UmbracoProject
    {
        public class Startup
        {
            private readonly IWebHostEnvironment _env;
            private readonly IConfiguration _config;
    
    
        /// <summary>
        /// Initializes a new instance of the <see cref="Startup" /> class.
        /// </summary>
        /// <param name="webHostEnvironment">The web hosting environment.</param>
        /// <param name="config">The configuration.</param>
        /// <remarks>
        /// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337.
        /// </remarks>
        public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config)
        {
            _env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
            _config = config ?? throw new ArgumentNullException(nameof(config));
    
        }
    
    
    
        /// <summary>
        /// Configures the services.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <remarks>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940.
        /// </remarks>
        public void ConfigureServices(IServiceCollection services)
        {
    
            services.AddControllersWithViews();
    
            services.Configure<CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded = context => true;
                options.Secure = CookieSecurePolicy.Always;
                options.MinimumSameSitePolicy = Microsoft.AspNetCore.Http.SameSiteMode.Lax;
            });
    
            services.Configure<CookieTempDataProviderOptions>(options =>
            {
                options.Cookie.IsEssential = true;
            });
    
            services.AddSession(options =>
            {
                options.Cookie.IsEssential = true;
            });
    
            services.AddUmbraco(_env, _config)
    
                .AddBackOffice()
                .AddWebsite()
                .AddComposers()
                .Build();
        }
    
    
        /// <summary>
        /// Configures the application.
        /// </summary>
        /// <param name="app">The application builder.</param>
        /// <param name="env">The web hosting environment.</param>
    
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
    
            app.UseHttpsRedirection();
            app.UseCookiePolicy();
    
            app.UseUmbraco()
                    .WithMiddleware(u =>
                    {
                        u.UseBackOffice();
                        u.UseWebsite();
    
                    })
                    .WithEndpoints(u =>
                    {
                        u.UseInstallerEndpoints();
                        u.UseBackOfficeEndpoints();
                        u.UseWebsiteEndpoints();
                    });
        }
    }
    

    }

  • kitana 1 post 71 karma points
    Aug 02, 2023 @ 08:49
    kitana
    0

    As i know integrating app.useCookiePolicy() from Microsoft into an Umbraco project can sometimes lead to unexpected behavior, especially when interacting with authentication mechanisms. It's important to ensure that the cookie policy implementation doesn't interfere with the authentication flow.

    Umbraco-Specific Considerations: Since you're working with Umbraco, there might be specific interactions with its cloud backoffice that could cause this issue. Check the Umbraco documentation or community forums for any known issues or solutions related to integrating third-party middleware like app.useCookiePolicy().

    Temporarily Disable Cookie Policy: As a troubleshooting step, you could temporarily comment out or disable the app.useCookiePolicy() middleware to see if the login loop issue persists. If it goes away, then you can be more certain that the cookie policy is indeed causing the problem.

    Seek Community Help: If none of the above steps resolve the issue, consider reaching out to the Umbraco community or forums. how to mirror zoom meeting on tv Other developers who have worked with Umbraco and similar authentication setups might have encountered and solved similar issues.

    Remember that debugging complex issues like this often involves a process of trial and error. Make small changes, test thoroughly, and gather as much information as you can about the behavior of your application.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies