Starts in:
0 DAY
20 HRS
2 MIN
36 SEC
Starts in:
0 D
20 H
2 M
36 S
Open Closed

Issue with Azure AD SSO using open id connect #5328


User avatar
0
Dev2ng created

Hi,

I am implementing the azure AD SSO using open id connect. By default abp framework has provided the implementation.

In this we see one button at the bottom of the login page of AuthServer project like this:-

abp_sso.PNG

But in our use case, we are using angular as frontend and at the time of initial load of the Angular App we don't want to show this login page and then on next step clicking on the "Azure AD OpenId" button to get the sso done.

we need this button's url to be hit on the initial load of the Angular app to get the sso done.

we can see some form submission on the button click to Account/login, but don't know how to control the flow.

Please provide assistance, hoping for quick response. Thanks !!


4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can custom the login page to redirect to external login.

    For example:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(LoginModel))]
    public class MyLoginModel : LoginModel
    {
        public MyLoginModel(IAuthenticationSchemeProvider schemeProvider, IOptions<AbpAccountOptions> accountOptions, IAbpRecaptchaValidatorFactory recaptchaValidatorFactory, IAccountExternalProviderAppService accountExternalProviderAppService, ICurrentPrincipalAccessor currentPrincipalAccessor, IOptions<IdentityOptions> identityOptions, IOptionsSnapshot<reCAPTCHAOptions> reCaptchaOptions) : base(schemeProvider, accountOptions, recaptchaValidatorFactory, accountExternalProviderAppService, currentPrincipalAccessor, identityOptions, reCaptchaOptions)
        {
        }
    
        [UnitOfWork]
        public override async Task<IActionResult> OnGetAsync()
        {
            await GetExternalProviders();
    
            var azureAdProvider = VisibleExternalProviders.First();
            
            var redirectUrl = Url.Page("./Login", pageHandler: "ExternalLoginCallback", values: new { ReturnUrl, ReturnUrlHash });
            var properties = SignInManager.ConfigureExternalAuthenticationProperties(azureAdProvider.AuthenticationScheme, redirectUrl);
            properties.Items["scheme"] = azureAdProvider.AuthenticationScheme;
    
            return await Task.FromResult(Challenge(properties, azureAdProvider.AuthenticationScheme));
            
        }
    }
    
  • User Avatar
    0
    Dev2ng created

    Hi,

    I am getting azureAdProvider as null in this.

    var azureAdProvider = VisibleExternalProviders.First();

  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, please try:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(LoginModel))]
    public class MyLoginModel : LoginModel
    {
        public MyLoginModel(IAuthenticationSchemeProvider schemeProvider, IOptions<AbpAccountOptions> accountOptions, IAbpRecaptchaValidatorFactory recaptchaValidatorFactory, IAccountExternalProviderAppService accountExternalProviderAppService, ICurrentPrincipalAccessor currentPrincipalAccessor, IOptions<IdentityOptions> identityOptions, IOptionsSnapshot<reCAPTCHAOptions> reCaptchaOptions) : base(schemeProvider, accountOptions, recaptchaValidatorFactory, accountExternalProviderAppService, currentPrincipalAccessor, identityOptions, reCaptchaOptions)
        {
        }
    
        [UnitOfWork]
        public override async Task<IActionResult> OnGetAsync()
        {
            ExternalProviders = await GetExternalProviders();
    
            var azureAdProvider = VisibleExternalProviders.First();
            
            var redirectUrl = Url.Page("./Login", pageHandler: "ExternalLoginCallback", values: new { ReturnUrl, ReturnUrlHash });
            var properties = SignInManager.ConfigureExternalAuthenticationProperties(azureAdProvider.AuthenticationScheme, redirectUrl);
            properties.Items["scheme"] = azureAdProvider.AuthenticationScheme;
    
            return await Task.FromResult(Challenge(properties, azureAdProvider.AuthenticationScheme));
            
        }
    }
    
  • User Avatar
    0
    Dev2ng created

    Thank you !! It's working fine.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06