I’m developing an application with Angular 8 (And .Net framework), where I integrated an OKTA authentication layer, the okta client it’s SPA type, and it works perfectly in local, while serving the app from visual studio. But for some reason, after deploying the app to one of our servers (And re configuring the redirect parameters), it doesn’t work properly. It loads the okta login page, and after logged, it tries to resolve the “URL/callback#tokenID” URL, but it gets stuck, if I refresh it, I get a 404.
Could I be missing some kind of rewrite or redirection rule or configuration on IIS?
I’m using windows server 2012 R2 and IIS version 8.5xxxx
I think the issues are on IIS, it could be breaking the params from the “url/callback#idToken=xxxxxxxxx”. Basically, that’s returning a 404, I’ve been trying using a rewrite rule to receive whatever url containing “callback”, and send to “url/callback”.
I’m still investigating about this, with no better results, tried several things on IIS config, different okta config. But similar result. The callback with id returned by Okta, is not getting processed properly by the app. Could be that the callback is not getting returned properly to the client side (Angular).
I’m using this library: import { OktaAuthService } from “@okta/okta-angular”;
And I’ve seen another choice from my side could be trying out this another one:
import * as OktaAuth from ‘@okta/okta-auth-js’;
Any clues from somebody? We’re talking about angular 8 and IIS, there has to be someone used to that config…
I would half wonder if its worth testing if this is specific to the hash fragment, or if you’d also have trouble receiving a query parameter at the callback route, but to do so, you would need to switch to using PKCE flow, since implicit flow will always use fragments.
Hey, I’m handling the token and all the okta layer in the Angular side, not in .Net. And about the hash fragment, I managed to remove the “#” (HashLocationStrategy), now the url for the callback it’s being sent, but apparently the response is not getting processed properly, this is the url where it gets stuck:
I was using the angular okta library (@okta/okta-angular") and for the callback, the “OktaCallbackComponent” from the same library. That DOESN’T work with IIS, unless there’s a specific config required for that (Not present in any doc), I’ve tried using another library: “@okta/okta-auth-js”, and doing manually what the callbackComponent should be doing, I made it work on IIS. Is there an explanation for that? Is Okta, using the angular library, fully compatible with IIS? Is it tested in all the IIS versions?
Of course, it works locally served with visual studio (no errors), so it’s not an Okta/Angular config issue (Unless IIS requires some extra or specific config that I’m missing), but after removing the okta-angular library and not using the OktaCallbackComponent, using the code taken from this repo: GitHub - beyondJohn/OktaAngularIntegration: Using Okta OAuth to secure an Angular 8 app using {useHash:true} routing strategy .
It works after deploying it on IIS. Now I have to investigate (Or hopefully someone from the OKTA team could provide some guidance to us, as we’re clients), if IIS+Angular8+Okta-angular doesn’t work at all, or there’s a workaround.
I’ll be waiting for some more clues, in the meanwhile, I’m working and investigating the code to use the “okta-js” library.
Find here a piece of the code I’m using which doesn’t work (All the config matches with the okta client):
Hey Andrea, That’s possible the piece I’m missing here, as I don’t know which is the specific config required on IIS to handle the callback. I’ve tried a couple of rewrite rules and config, but nothing worked, if you have some clues about what has to be done, it could be very helpful,
Hi again, is there anything I could check to fix this situation in terms of documentation? I’m surprised that there’s no documentation for Okta SPA + IIS, as I can see several posts about IIS issues while working with OKTA, so it’s obvious it doesn’t work properly while combining IIS and OKTA.
There should be something I could use as support/guidance.
Hi deni4diaz,
Have you solved troulbe yet?
I have same trouble. Okta doesn’t work with IIS now. Please help me. maivinhthong@gmail.com
thongmv@fsoft.com.vn
For those who land on this post looking for web server configurations for their Angular apps, please check out the Deployment guide from Angular linked below.
There are rewrite rule configurations for various web servers such as IIS, Apache, Nginx, etc.