Copied to clipboard

Flag this post as spam?

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


  • Santhosh Sivan 7 posts 77 karma points
    Nov 26, 2024 @ 10:22
    Santhosh Sivan
    0

    Umbraco 13 Azure SSO does not show error & not getting login

    I am working on Azure SSO login, but when I hit the SSO login, it simply changes the URL to:

    https://localhost:44314/umbraco#/login/false?returnPath=%252Fumbraco%2523%252Fcontent
    

    I've attached the code below for your reference. Can anyone help me resolve this issue?

    BackofficeAuthenticationExtensions.cs

    using Microsoft.AspNetCore.Authentication.MicrosoftAccount;
    using Microsoft.Extensions.Configuration; // Import this namespace
    
    namespace ManarEthara {
        public static class BackofficeAuthenticationExtensions {
            public static IUmbracoBuilder ConfigureAuthentication(this IUmbracoBuilder builder, IConfiguration configuration) {
                builder.AddBackOfficeExternalLogins(logins => {
                    const string schema = MicrosoftAccountDefaults.AuthenticationScheme;
    
                    logins.AddBackOfficeLogin(backOfficeAuthenticationBuilder => {
                        backOfficeAuthenticationBuilder.AddMicrosoftAccount(
                            backOfficeAuthenticationBuilder.SchemeForBackOffice(schema) ?? string.Empty,
                            options => {
                                options.CallbackPath = configuration["AzureAd:CallbackPath"];
    
                                // Retrieve the ClientId from the IConfiguration instance
                                options.ClientId = configuration["AzureAd:ClientId"];
                                options.ClientSecret = configuration["AzureAd:ClientSecret"];
                                options.TokenEndpoint = configuration["AzureAd:TokenEndpoint"];
                                options.AuthorizationEndpoint = configuration["AzureAd:AuthorizationEndpoint"];
                                options.SaveTokens = true;
                            });
                    });
                });
    
                return builder;
            }
        }
    }
    

    Program.cs file

    using ManarEthara.Components.Amenities;
    using ManarEthara.Components.Layout;
    using ManarEthara.Components.Page;
    using ManarEthara.Components.Program;
    using ManarEthara.Components.Shared;
    using ManarEthara.Controllers.Validators;
    using ManarEthara.Factories;
    using ManarEthara.Factory;
    using ManarEthara.Repository;
    using ManarEthara.Services;
    using Azure.Storage.Queues;
    using Azure.Storage.Blobs;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.Azure;
    using Azure.Core.Extensions;
    using ManarEthara;
    using Azure.Identity;
    using Umbraco.Cms.Core.Events;
    using Umbraco.Cms.Core.Notifications;
    
    WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
    
    var configuration = builder.Configuration;
    
    builder.CreateUmbracoBuilder()
        .AddBackOffice()
        .AddWebsite()
        .AddDeliveryApi()
        .AddComposers()
        .AddAzureBlobMediaFileSystem()
        .ConfigureAuthentication(configuration)
        .Build();
    
    builder.Services.AddSingleton<CaptchaValidator>(new CaptchaValidator(configuration["ApiConfig:recaptchakey"]));
    
    builder.Services.AddTransient<ComponentService>();
    builder.Services.AddTransient<ComponentFactory>();
    builder.Services.AddTransient<ComponentRepository>();
    builder.Services.AddTransient<LayoutService>();
    builder.Services.AddTransient<LayoutFactory>();
    builder.Services.AddTransient<ContentQueryRepository>();
    
    builder.Services.AddScoped<INotificationHandler<ContentPublishedNotification>, ExternalAPIHandler>();
    builder.Services.AddHttpContextAccessor();
    
    
    var imageFactory = new ImageFactory(configuration);
    
    Gallery.Initialize(imageFactory);
    Seo.Initialize(imageFactory);
    Banner.Initialize(imageFactory);
    Carousel.Initialize(imageFactory);
    MenuItems.Initialize(imageFactory);
    SecondaryMenuItems.Initialize(imageFactory);
    StoreLinks.Initialize(imageFactory);
    image.Initialize(imageFactory);
    Amenities.Initialize(imageFactory);
    ProgramData.Initialize(imageFactory);
    PageBanner.Initialize(imageFactory);
    InfoContent.Initialize(imageFactory);
    MapView.Initialize(imageFactory);
    
    builder.Services.AddControllers().AddNewtonsoftJson();
    //builder.ConfigureKeyVault();
    
    WebApplication app = builder.Build();
    
    await app.BootUmbracoAsync();
    
    app.UseUmbraco()
        .WithMiddleware(u =>
        {
            u.UseBackOffice();
            u.UseWebsite();
        })
        .WithEndpoints(u =>
        {
            u.UseInstallerEndpoints();
            u.UseBackOfficeEndpoints();
            u.UseWebsiteEndpoints();
        });
    
    await app.RunAsync();
    

    This is callback url i use ==> https://localhost:44314/umbraco-b2c-members-signin & Microsoft.AspNetCore.Authentication.MicrosoftAccount is the package i used

  • 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" button below.

    Continue discussion

Please Sign in or register to post replies