PWA with Windows Authentication - .net-core

On the high level, I have a PWA with React frontend and .netcore backend. I use service worker for caching and offline ability, in conjunction with workbox plugins for some precaching feature.
The app uses Windows Authentication. Which works fine if it wasn't a PWA app. It also works fine the first time the PWA app launches, I get the username, password login popup.
However from the second time visiting the app, it wouldn't show the login popup, the app fails at pulling data from the backend because it is unauthenticated. One weird behavior is that, if I open Chrome Dev Tools(by F12), then the login popup immediately shows up.
I thought it's caching related and somehow the service worker interfered with the server side authentication workflow. Maybe because the index page is cached by the workbox precache plugins, and it did not cache with the fetch header of 'credentials': 'include'? I tried adding the fetch option to other api routes, which are cached by workbox plugin RegisterRoute. However I didn't find a way to add it to the precacheAndRoute(self.__WB__MANIFEST). Wondering if that's the problem. But I'm also not sure why having Dev Tools open would trigger the popup to display.
Any input is appreciated.

Related

Teams: Personal Tab => successful authentication redirects back to login page (Due to cookie not being set)

So we have this web application running, but we wanted to make a Teams app (personal tab) from it. We used App Studio to create the app (manifest and all), but when running it from the sidebar we won't get past the login screen. On successful login, you get redirected back to the login page (everything happens on the same domain).
But when we tried to run the "app" as a tab within a group, this worked. So we need to find out why this doesn't work when we run it as a Teams "app".
Any ideas would be appreciated :)
The problem was that since it's running inside an iframe (in practice), the cookie set by ASP.NET State needs to state SameSite="None" and Secure="true".
Applications that use <iframe> may experience issues with sameSite=Lax or sameSite=Strict cookies because <iframe> is treated as cross-site scenarios. - https://learn.microsoft.com/en-us/aspnet/samesite/system-web-samesite
So I had to upgrade the .NET Target Framework to 4.7.2, and make the changes stated in this document: https://learn.microsoft.com/en-us/aspnet/samesite/system-web-samesite

Disable service worker in <Iframe>

I need to disable service workers in <iframe>
I build offline PWAs for clients and have a number of demo PWAs running for my potential clients to test on their devices. I also wish to put these PWAs on my website in iframes, but when I do this, the viewer receives a browser notification stating that the app is installed on their device. This causes some alarm because the viewer might not be expecting this as they click through my website. I want to display the apps in an iframe without service worker activation, and with links inviting them to open the app in a new tab which they can then get the full PWA experience if they wish.
Thanks.

Can I use Firebase Dynamic Links for a web app?

I don't see any option for Web under "receiving dynamic links" in Firebase Dynamic links page.
Without the SDK, there's no way to connect a post-install user with a pre-install click.
I have a desktop app that runs on node.js like a web app, using nw.js. What I'm trying to do is create referral links for users. After someone clicks a referral link, I need to be able to track his referrer. But the problem is that link is only going to take him to the download page, after he downloads and opens up the app for the first time, how can I reach his referrer info? The desktop app has no connection with the website that users download from.
I understand that this can be done with Dynamic Links SDK but can I use that SDK in a web app?(desktop app actually but runs with HTML/node.js)
The post-install deeplinking in Dynamic Links is just for Android and iOS - so there isn't an equivalent for a desktop app.

Auth0 Authorization Stops Working When API is Published (.Net Web API / Angular)

I am currently using Auth0 with Loc7 in Angular and an ASP .Net Web API v2.
The project works fine locally. The user can log in using the widget and the API sees the User as authorised with no issue.
When the app is published the API returns 401 unauthorised when a call is made.
There is no issue with Angular app no matter where on the web space it is placed so I do not believe it is an issue with the Allowed Callback URLs in the Auth0 dashboard.
The config works fine locally and there are no major changes when being published except the database connection string.
The database is an exact copy of the local database.
The API MVC Template works fine but does not do anything aside from load and show routes. I have not changed the template since it was generated.
There are no errors on the server.
The API is in a newly created app directory on the server.
Auth0 Dash reports the login from the Angular code successful. The profile is returned with a valid token viewed through the dev console.
Has anyone else had a similar issue? Could this be an issue with how the hosting is set up?
Happy to post more info, I am not really sure what to post it is a fair amount of code.

Firebase deploy - Not loading new page

I am deploying a PWA to firebase using the tutorial from the polymer project website. I have no issues deploying to firebase, but if I deploy a second time the new page does not load. It will load the old page until I clear the cookies. I see understand that the way a PWA site works is like an application where it stores parts in memory for faster load times. Is there a setting I need to change to make it load most recently deployed webpage? I appreciate all the help, thanks in advance!
You might be seeing an effect of your service worker. Try deleting the currently registered service worker from your browser so that the new one can take over.
In Chrome 51/52, open DevTools while on your site, and go to the Resources tab, and then Service Workers on the left panel. Click Delete to remove the service worker. You could also check the box for Update on reload, which allows you to update the service worker simply by refreshing the page.

Resources