If a user accesses a hyperlink like: http://localhost:4200/?__tenant=5a896a41-adb2-872d-7330-3a141289a314
The Angular UI will correctly recognize the Tenant Id, look up the tenant and set the Tenant cookie and http header. However, if the user is not yet logged in, when it redirects to the Auth Server, it does not pass the tenant Id in the http header or query string. The user is then required to select the tenant, even though the Angular UI already knows what tenant the user is trying to access.
This creates a problem when a separate application is redirecting a user into our ABP application. We already know the tenantId and can pass it via the query string, so the user should not have to know the name of the Tenant or select it when logging in.
The AuthServer already supports Tenant resolution via the various methods, so if I manually add the __tenant query string parameter like so: https://localhost:44372/Account/Login?__tenant=5a896a41-adb2-872d-7330-3a141289a314&ReturnUrl=%2Fconnect%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3DSample_App%26state%3DQl9hQWsyZEpzSnBmUkMyejMuaDlILTZLemFUeERDNVBKaVdYaGVmT3ItX3pL%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4200%26scope%3Dopenid%2520offline_access%2520Sample%26code_challenge%3DG84U3eHCgDgoJP3vtsZuYV6gHdKUoAEh3Bgxt_oKz7Q%26code_challenge_method%3DS256%26nonce%3DQl9hQWsyZEpzSnBmUkMyejMuaDlILTZLemFUeERDNVBKaVdYaGVmT3ItX3pL%26culture%3Den%26ui-culture%3Den
The AuthServer will correctly select the Tenant. Is there a way to make the Angular UI send the tenant header or query string parameter?
- ABP Framework version: v8.1.1
- UI Type: Angular
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
- Steps to reproduce the issue:
3 Answer(s)
-
0
Hi,
you can try this
https://manfredsteyer.github.io/angular-oauth2-oidc/docs/additional-documentation/custom-query-parameters.html
-
0
I did see that, but not sure where to to hook that in on the Angular side. Can you point me to where I can add this?
It seems to me that the correct fix would be to update the navigateToLogin method in the oath.service.ts to something like this:
` navigateToLogin(queryParams?: Params) {
//Add the tenantId to the query string parameters so the login page has a chance to set the current tenant by default const tenant = this.sessionStateService.getTenant(); if(tenant?.id) queryParams = {...{ [this.tenantKey]: tenant.id }, ...queryParams}; this.strategy.navigateToLogin(queryParams);
}`
-
0
you can try add it to the home module