I'm trying to pass a custom parameter to returnURL used in login page IdentityServer 4 from angular oidc-client.
Based on the parameter i receive from the returnURL I want to bypass the login website and redirect them to IDP. I'm intending to add the parameter to a specific page from angular and from there I want to redirect to login.
Below links talks about them but those I'm not able to follow. Can you guys please help. Thanks in advance.
Pass custom parameter to returnUrl used in login page Identity Server 4
https://github.com/IdentityServer/IdentityServer4/issues/909
C# AccountController.cs
public async Task<IActionResult> Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
var vm = await _account.BuildLoginViewModelAsync(returnUrl);
if (vm.IsExternalLoginOnly)
return ExternalLogin(vm.ExternalProviders.First().AuthenticationScheme, returnUrl);
return View(vm);
}
Angular auth.service.ts
const settings: any = {
authority: environment.oauthUrl,
client_id: 'website',
redirect_uri: `${environment.applicationUrl}/auth.html`,
post_logout_redirect_uri: `${environment.applicationUrl}`,
response_type: 'id_token token',
scope: 'openid profile email profile nucleus',
silent_redirect_uri: `${environment.applicationUrl}/silent-renew.html`,
automaticSilentRenew: true,
monitorSession: true,
checkSessionInterval: 2000,
revokeAccessTokenOnSignout: true,
filterProtocolClaims: true,
loadUserInfo: true,
changePasswordUrl: `${environment.oauthUrl}/Manage/ChangePassword?returnUrl=${environment.applicationUrl}`
};
I expect a parameter from returnurl and add a condition like this in Login method of AccountController.cs.
if (vm.IsExternalLoginOnly || returnUrl.Contains("customparameter"))