I'm writing a suite of tools with a Laravel backend that pulls exclusively from a 3rd party API. It also authenticates end users against the 3rd party site (using OAuth 2), but I also have it create/authenticate a local Laravel user so I can leverage all of the Auth object's helpers.
I'm now looking into writing an electron app with Vue.js so I can deploy the app to staff without having to worry which browser they are using (and to enable use of local resources when it makes sense). Unfortunately, consuming the 3rd party's Oauth2 is confusing me a bit on the best course of action for authenticating my Electron app.
Here's my plan on paper:
- user clicks login on Electron app and a popup window goes to a login window on my Laravel App, which uses the 3rd party's Oauth middleware to log the user in on their website and redirects to the Laravel app's callback.
- My middleware then checks to see if that user exists locally and if so it logs them in manually (if not, it creates their local account and logs them in)
- I now have a local user, so I'm thinking I can somehow trigger Passport (still researching this) to generate the API token to pass to my electron app for the locally logged in user.
- Somehow I pass the the API token back to my electron app and proceed using passport like you normally would.
Here's where I am stuck:
I have no clue how to make the popup window in electron pass the variable back to the main window (to trigger a vuex commit and a few other things) and then close the popup, especially considering the contents of the popup will be an online resource, not a local resource from within the electron app.
I feel like this has got to be common, when you consider traditional social media logins, but I'm not sure how to implement that myself.
The more I think of it the more I think this will involve using cookies, but I'm not really sure how...