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:-
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)
-
0
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)); } }
-
0
Hi,
I am getting azureAdProvider as null in this.
var azureAdProvider = VisibleExternalProviders.First();
-
1
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)); } }
-
0
Thank you !! It's working fine.